Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Addvendor_id andfinish_reason to Gemini/Google model responses#1800

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
DouweM merged 10 commits intopydantic:mainfromdavide-andreoli:feat/add-id-to-gemini
May 27, 2025

Conversation

davide-andreoli
Copy link
Contributor

@davide-andreolidavide-andreoli commentedMay 21, 2025
edited
Loading

Addid andfinish_reason to Gemini

Description

FollowingPR#1761 , this update addsvendor_id andfinish_reason to Gemini answers.

Below the details:

  • vendor_id: maps toresponseId
  • finish_reason:finishReason for the first candidate of the output. The finish reason is added in vendor_details, following the attribute specification

The handling of finish_reasons aligns with the current approach for other response parts, where only the first candidate's reason is considered.

Testing

The changes were validated using my API key, and the behavior matches expectations.

Impact

This update impacts only Gemini Responses, but it is not a breaking change.

@davide-andreoli
Copy link
ContributorAuthor

Hello@DouweM, as agreed inPR#1761, here is the new PR.

@DouweMDouweM closed thisMay 21, 2025
@DouweMDouweM reopened thisMay 21, 2025
@DouweM
Copy link
Contributor

@davide-andreoli Thanks! Can you please have a look at the failing tests, and also implement this in the newmodels/google.py (assuming it makes sense there as well)?

@davide-andreoli
Copy link
ContributorAuthor

@DouweM The test failures are due to the vendor_details field.
Since gemini tests are configured to always send afinish_reason (which makes sense, as it's a non-optional field in the response) the vendor_details field is awlays present in the GeminiModelResponses.
However, the snapshot comparison fails because vendor_details is marked withrepr=False in theModelResponse class.

I see two potential ways to address this:

  1. Removerepr=False from thevendor_details field in theModelResponse class. This would be the cleanest solution, but I want to make sure it doesn't go against the original design intent
  2. Update the tests to excludevendor_details before performing snapshot comparisons. This is a bit less elegant but still effective

Please let me know which approach you’d prefer.

And sure, no problem with adding the fields tomodels/google.py as well.

@DouweM
Copy link
Contributor

DouweM commentedMay 22, 2025
edited
Loading

@davide-andreoli I had a chat about this with@dmontagu and we decided to make it so that dataclass fields with default values are excluded from reps:#1812. So once that merges (should be soon), you can merge/rebase, dropreps=False fromvendor_details and hopefully it won't require too many examples to be updated!

@davide-andreoli
Copy link
ContributorAuthor

Hello@DouweM, work is done and tests are passing.
As agreed I removedrepr=False fromvendor_details and added the fields inmodels/google.py as well.

@DouweMDouweM changed the titleAddid andfinish_reason to GeminiAddvendor_id andfinish_reason to Gemini/Google model responsesMay 27, 2025
@DouweMDouweM merged commit1e22652 intopydantic:mainMay 27, 2025
18 checks passed
@DouweM
Copy link
Contributor

@davide-andreoli Thanks Davide!

davide-andreoli reacted with laugh emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@DouweMDouweMDouweM requested changes

Assignees

@DouweMDouweM

Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@davide-andreoli@DouweM

[8]ページ先頭

©2009-2025 Movatter.jp