feat: Add support for structured output (response_format) in GoogleGenAIChatGenerator#2946
Merged
anakin87 merged 6 commits intodeepset-ai:mainfrom Mar 12, 2026
Merged
Conversation
bd6715a to
a1a6981
Compare
anakin87
requested changes
Mar 12, 2026
Member
anakin87
left a comment
There was a problem hiding this comment.
Thank you for the contribution!
I left some comments
…/generators/google_genai/chat/utils.py Co-authored-by: Stefano Fiorucci <stefanofiorucci@gmail.com>
Contributor
Author
thank you for taking the time to review ! |
anakin87
reviewed
Mar 12, 2026
…/generators/google_genai/chat/utils.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related Issues
Proposed Changes:
Add support for response_format in GoogleGenAIChatGenerator's generation_kwargs, enabling structured output with cross-provider portability (matching the OpenAI integration's API)
How did you test it?
Unit tests (test_chat_generator_utils.py): test_process_response_format covers Pydantic model, dict schema, missing key, native key precedence, unsupported type error, and input immutability.
Unit tests (test_chat_generator.py):
test_to_dict_with_response_format_pydantic, test_to_dict_with_response_format_dict, and test_serde_with_response_format for serialization/deserialization.
Integration tests (test_chat_generator.py):
test_live_run_with_structured_output_pydantic, test_live_run_with_structured_output_dict_schema (sync), and test_live_run_async_with_structured_output (async), all verified with a Google Studio API key
Notes for the reviewer
Google's SDK natively accepts Pydantic BaseModel classes for response_schema, so no manual JSON schema conversion is needed at runtime — only for serialization in to_dict().
Checklist