(models): Enable JSON Schema Support for Gemini 1.5 Flash Models #5708
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Gemini 1.5 Flash models now support JSON schema through model configuration.
Changelog - https://ai.google.dev/gemini-api/docs/changelog
From docs - https://ai.google.dev/gemini-api/docs/structured-output?lang=python
Also here - https://ai.google.dev/gemini-api/docs/models/gemini#gemini-1.5-flash
Below is the script i made to check which models work with schema, all models except gemini-1.5-flash-8b-exp-0827 support it.
Additionally, I observed some unexpected behavior regarding the check for response_schema support. Currently, it seems to rely on the Vertex AI provider configuration. However, certain models like "gemini-1.5-flash-latest" lack specific Vertex configurations, potentially leading to an inaccurate assessment of their schema support, despite Gemini itself supporting it. It might be necessary to modify this hardcoded provider check to utilize "custom_llm_provider" instead for a more reliable evaluation.
litellm/litellm/llms/vertex_ai_and_google_ai_studio/gemini/transformation.py
Lines 47 to 51 in 2efdd2a