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

Missing content field when finishReason is other than STOP #235

Open
jelni opened this issue Jan 22, 2024 · 3 comments
Open

Missing content field when finishReason is other than STOP #235

jelni opened this issue Jan 22, 2024 · 3 comments
Labels
component:support How to do xyz? type:bug Something isn't working

Comments

@jelni
Copy link

jelni commented Jan 22, 2024

Description of the bug:

when the Candidate.finishReason response field is not set to STOP, the Candidate.content is missing.

example reproduction

curl --request POST \
  --header "Content-Type: application/json" \
  --data '{"contents":[{"parts":[{"text":"hi!"}]}],"generationConfig":{"maxOutputTokens":1}}' \
  https://generativelanguage.googleapis.com/v1/models/gemini-pro:generateContent?key=YOUR_API_KEY

Actual vs expected behavior:

the response to this request is currently

{
  "candidates": [
    {
      "finishReason": "MAX_TOKENS",
      "index": 0,
      "safetyRatings": [...]
    }
  ],
  "promptFeedback": {
    "safetyRatings": [...]
  }
}

the candidates[0].content field is expected to contain the first generated token (as maxOutputTokens was set to 1), but is missing

Any other information you'd like to share?

this started happening between 2024-01-12 and 2024-01-14 on the v1beta API version

@jelni jelni added the type:bug Something isn't working label Jan 22, 2024
@keertk keertk added the component:support How to do xyz? label Feb 8, 2024
@xslingcn
Copy link

xslingcn commented Mar 8, 2024

I have the same issue. Any updates?

@jelni
Copy link
Author

jelni commented Mar 25, 2024

@xslingcn you could use the streamGenerateContent endpoint and concatenate all returned parts (excluding the last one, which seems to be affected by the issue i described)

@zycheiheihei
Copy link

zycheiheihei commented Apr 7, 2024

I also have the same issue. This makes the query from API very unstable, frequently resulting in null response. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:support How to do xyz? type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants