Closed pentney closed 1 year ago
How are you making the request? cURL? Python?
It's hard to tell without seeing the full context, but my guess is that something is literally interpreting the \n
before it makes the web request, so it breaks up the JSON into invalid chunks.
After experimenting some more, I realized this was happening only when I made repeated calls with similar, but slightly different text for the prompt, in succession. I could not reproduce it in other circumstances. Is there an intentional restriction on this? The request was made through the REST API.
If you're getting Invalid JSON payload received
, then yes, that's intentional if the JSON is malformed. Can you provide the text that is failing, and exactly how you executed it (e.g. show the full curl
command, or code used to build the request)?
Parsing terminated before end of input.\n\"}}\n {\"prompt\": {\"text\": \n ^",
That phrase seems to be from a proto parsing library.
Its not totally clear how the snippet after is meant to be parsed. But it looks like there's something in the json string before {"prompt"
. That doesn't make any sense since for generate_text
, prompt is a top level key.
I'm able to reproduce the error by pasting two queries into curl:
curl -H 'Content-Type: application/json' \
-H "x-goog-api-key: ${PALM_API_KEY}" \
-d '{"prompt": {text: "hello"} } {"prompt": {text: "hello2"} }' \
"https://generativelanguage.googleapis.com/v1beta2/models/text-bison-001:generateText"
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Parsing terminated before end of input.\n {text: \"hello\"} } {\"prompt\": {text: \"h\n ^",
"status": "INVALID_ARGUMENT"
}
}
I think this is a copy-paste error.
I know that I am successfully sending requests to the PaLM API because other prompts have succeeded. This one, however, returns an error:
This parses as valid JSON, has what I believe to be a valid number of tokens, and is in the same format as other successful prompts, but I get this response.
Am I missing something here?