-
Notifications
You must be signed in to change notification settings - Fork 902
Feat: Add id
and finish_reason
to ModelResponse
#1761
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
Feat: Add id
and finish_reason
to ModelResponse
#1761
Conversation
Co-authored-by: Douwe Maan <douwe@pydantic.dev>
@davide-andreoli We just added a new |
Co-authored-by: Douwe Maan <douwe@pydantic.dev>
PR Change SummaryEnhanced the ModelResponse structure by adding new fields for improved request tracking and response clarity.
Modified Files
How can I customize these reviews?Check out the Hyperlint AI Reviewer docs for more information on how to customize the review. If you just want to ignore it on this PR, you can add the Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add |
Hello @DouweM I’ve rebased, but it looks like the changes didn’t apply cleanly and are pulling in intermediate commits. Sorry about that, it's my first time rebasing. |
@davide-andreoli That works, sorry for the trouble. I'll close this then and will await the new PR. |
Add
id
andfinish_reason
toModelResponse
Description
Following issue #886, this update adds
id
andfinish_reasons
toModelResponse
.Below the details:
id
: id of the request, defaults to a random UUIDfinish_reasons
: list of reasons why the generation ended, defaults to an empty listGemini implementation
Included in the PR there is an implementation of the fields for Gemini.
id
: maps toresponseId
finish_reasons
: list containingfinishReason
for the first candidate of the outputThe handling of finish_reasons aligns with the current approach for other response parts, where only the first candidate's reason is considered. Note that only those finish reasons defined in the Literal type will be included.
Implementations for other model providers are currently missing due to lack of testing access.
Testing
The changes were validated using my API key, and the behavior matches expectations.
Impact
This update potentially affects all providers. However, with sensible default values in place, the change should have no immediate impact. Provider-specific implementations can be added independently later.