Skip to content

fix: correctly determine finish reason in gemini streaming - #1216

Open
PartTimeHackerman wants to merge 1 commit into
musistudio:mainfrom
PartTimeHackerman:fix/gemini-transformer-fix
Open

PartTimeHackerman wants to merge 1 commit into
musistudio:mainfrom
PartTimeHackerman:fix/gemini-transformer-fix

Conversation

@PartTimeHackerman

Copy link
Copy Markdown

This change addresses an issue where the finish reason was not being correctly determined in Gemini streaming mode, particularly when multiple response chunks were received.

Previously, the logic only considered the first candidate of the first response, which could lead to a null finish_reason if that initial chunk was not the final one.

The updated implementation now correctly handles multiple response chunks by iterating through them to find the candidate that contains a finishReason. This ensures that the final response is properly identified and the finish_reason is accurately reported.

This change improves the reliability of response handling in streaming scenarios and prevents potential issues with incomplete or misidentified responses.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant