-
Notifications
You must be signed in to change notification settings - Fork 57
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
Add support for Gemini Structured Outputs #472
Comments
hi @willbakst if this issue's still open, I would love to take this up! |
@AbhishekRP2002 it's open! would love for you to take this if you have any questions let me know! our implementation of OpenAI structured outputs should act as a good reference |
sure, will let you know if there's any blocker in any way. |
hi @willbakst apologies for no updates since past 1 month, been piled with lots of eng work, so couldn't give this much time.
i also noticed we can extract structured outputs via function calling in gemini which seemed more close to the openai implementation under found this example also: https://github.com/Mirascope/mirascope/blob/f4474e505a7bd67741faa44065fd7ba772681c50/examples/learn/response_models/json_mode/gemini/messages.py seems like already implemented ? would be really grateful if u can share your thoughts or help me out here in any way |
Ah I can see the confusion here. Hopefully this explanation will clear things up. There are three types of structured outputs:
We've implemented (1) and (2) across all currently supported providers, but we've only implemented (3) for OpenAI (see here), but Gemini now also supports strict structured outputs. The idea with this issue would be to add the same support for Gemini that we have for OpenAI (by setting |
Description
Recently Google released Structured Outputs for Gemini (much like OpenAI).
Should be fairly simple to enable this by updating
setup_call
forgemini
and updating the warning to includegemini
as a module that supportsstrict
in the response model schema (although it seems like structured outputs for tools is not quite supported).See: https://ai.google.dev/gemini-api/docs/json-mode?lang=python#supply-schema-in-config
Only difficulty I can see right now is that the only two supported inputs are either raw type annotations (so no
BaseModel
) or theirgenai.protos.Schema
type (which will require conversion fromBaseModel
). Should have most of this implemented already I believe, so still shouldn't be terribly difficult.The text was updated successfully, but these errors were encountered: