Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing issues when body contains a single quote #12

Closed
avin45h opened this issue Oct 1, 2024 · 5 comments
Closed

Parsing issues when body contains a single quote #12

avin45h opened this issue Oct 1, 2024 · 5 comments
Assignees

Comments

@avin45h
Copy link

avin45h commented Oct 1, 2024

Hi
Curl parsing is failing when request body contains a single quote

curl -X POST -H 'Content-Type: application/json' -H 'key: <redacted>' --data '{
  "instance": "{\n  \"conversation_id\": \"sambaverse-conversation-id\",\n  \"messages\": [\n    {\n      \"message_id\": 0,\n      \"role\": \"user\",\n      \"content\": \"write a letter\"\n    },\n    {\n      \"message_id\": 1,\n      \"role\": \"assistant\",\n      \"content\": \"to a friend about a problem'\''? ANSWER: How to Make a Letter to a Friend About a Problem\"\n    },\n    {\n      \"message_id\": 2,\n      \"role\": \"user\",\n      \"content\": \"write a letterto a friend about a problem'\''? ANSWER: How to Make a Letter to a Friend About a Problem\"\n    }\n  ]\n}",
  "params": {
    "do_sample": {
      "type": "bool",
      "value": "false"
    },
    "max_tokens_to_generate": {
      "type": "int",
      "value": "100"
    },
    "repetition_penalty": {
      "type": "float",
      "value": "1"
    },
    "return_logits": {
      "type": "int",
      "value": "0"
    },
    "stop_sequences": {
      "type": "str",
      "value": ""
    },
    "temperature": {
      "type": "float",
      "value": "1"
    },
    "top_k": {
      "type": "int",
      "value": "50"
    },
    "top_p": {
      "type": "float",
      "value": "1"
    }
  }
}' 'http://localhost:3000/api/predict/generic/76ee2921-c54e-4988-9464-064a4face27e/200426b8-fb57-4535-9110-f68e923dba1b'

image
@AmitFeldman
Copy link

+1

@jf990
Copy link
Collaborator

jf990 commented Dec 5, 2024

I don't see the single quote as an issue, the single quoted strings are handled as expected. But it appears the parse is not properly handling the escaped single quote

you have this sequence:

--data '{ "instan ... ent\": \"to a friend about a problem'\''? ANSWER: ...

the --data string is opened with a single quote, so the first closing quote encountered closes that string. then there is an escaped single quote which isn't part of the curl command parameters so that might throw off the parser. then there is a new open quote for the next string.

if you change it to this sequence it works fine:

--data '{ "instan ... ent\": \"to a friend about a problem? ANSWER: ...

I'll look into the escaped single quote to see if we can fix that.

@jf990 jf990 mentioned this issue Dec 7, 2024
@jf990
Copy link
Collaborator

jf990 commented Dec 7, 2024

@avin45h @AmitFeldman this issue should be addressed. I added a few test cases for the escaped single quote and it seems to parse correctly now.

@jf990 jf990 closed this as completed Dec 7, 2024
@jf990 jf990 self-assigned this Dec 7, 2024
@AmitFeldman
Copy link

AmitFeldman commented Dec 8, 2024

I don't think you published 1.4.0
@jf990

@jf990
Copy link
Collaborator

jf990 commented Dec 9, 2024

@AmitFeldman looks like the HLJS build failed I need to figure out what happened to the build system when I upgraded to 11.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants