Skip to content

Switch gemini request to camelCase as required by API #1456

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 4 commits into from
Apr 15, 2025

Conversation

piercefreeman
Copy link
Contributor

From the gemini docs https://ai.google.dev/api/generate-content#text_gen_text_only_prompt-SHELL, request parameters are expected to camelCase instead of the current snake_case that's being uploaded directly:

safetySettings[]
systemInstruction
generationConfig
cachedContent

@piercefreeman piercefreeman force-pushed the bug/fix-gemini-request-casing branch from 3743bd6 to 393ab13 Compare April 11, 2025 17:48
@Kludex
Copy link
Member

Kludex commented Apr 15, 2025

You do have a point... But it's working, right? 👀

I'm on the transition to refactor the GeminiModel to use the google.genai.Client: #1373, so this will be solved there.

@piercefreeman
Copy link
Contributor Author

@Kludex From what I'm seeing, it's not working. In the current release safety settings are not respected and always fail with MEDIUM or higher (the default value when unprovided). When I run against this branch it successfully reduces errors to NONE.

Your call on whether to merge in now or wait until your refactor!

@dmontagu dmontagu enabled auto-merge (squash) April 15, 2025 19:49
@dmontagu
Copy link
Contributor

@piercefreeman thanks for this! We'll merge and release it now, just noting that as Marcelo has indicated, the plan is to switch to using an official Google SDK in the near future. (When we do that, you'll presumably want to confirm everything still behaves properly, but also, it's probably more likely to given it will be the actual Google SDK ...)

@dmontagu dmontagu merged commit 044ca13 into pydantic:main Apr 15, 2025
14 checks passed
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.

3 participants