Skip to content

Add a more explicit error when no parts returned #180

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

Merged
merged 2 commits into from
Jan 30, 2024

Conversation

markmcd
Copy link
Member

@markmcd markmcd commented Jan 29, 2024

When a response has been blocked, the API will return a Candidate (with finish_reason, safety_ratings, etc) that does not have any Parts. Given blocking is common enough, and we can identify this case, I've added a more explicit (and helpful?) error message to guide users if this happens.

LMK (or just push) if you think this could be worded clearer.

This should also fix the TypeError: argument of type 'Part' is not iterable error thrown in another (unknown?) case.

When a response has been blocked, the API will return a `Candidate`
(with `finish_reason`, `safety_ratings`, etc) that does not have
`Part`s.  Given blocking is common enough, and we can identify this
case, I've added a more explicit (and helpful?) error message to guide
users if this happens.
@markmcd markmcd requested a review from a team as a code owner January 29, 2024 07:32
@github-actions github-actions bot added status:awaiting review PR awaiting review from a maintainer component:python sdk Issue/PR related to Python SDK labels Jan 29, 2024
These appear to be new changes, unrelated to this PR, but sure why not.
Copy link
Collaborator

@MarkDaoust MarkDaoust left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks!

In the future we can include more objects with the error message, but this is a clear improvement.

@MarkDaoust MarkDaoust merged commit 1e67f3d into google-gemini:main Jan 30, 2024
@github-actions github-actions bot removed the status:awaiting review PR awaiting review from a maintainer label Jan 30, 2024
@markmcd markmcd deleted the candidate_but_no_parts branch March 6, 2024 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:python sdk Issue/PR related to Python SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants