feat(google): add response_mime_type and response_schema params#5064
Open
Panmax wants to merge 2 commits intolivekit:mainfrom
Open
feat(google): add response_mime_type and response_schema params#5064Panmax wants to merge 2 commits intolivekit:mainfrom
Panmax wants to merge 2 commits intolivekit:mainfrom
Conversation
…M.__init__ Add instance-level output format control to the Google GenAI LLM plugin. Previously, structured output could only be configured per-call via the chat() method's response_format parameter. In scenarios where the LLM is consistently used to produce JSON responses (e.g. extracting structured data, building tool-calling pipelines), having to pass response_format on every chat() call is repetitive and error-prone. With these two new __init__ parameters: - response_mime_type: controls the output MIME type (e.g. "application/json") without requiring a schema, useful for free-form JSON output. - response_schema: constrains the JSON output to a specific structure (Pydantic model or Google SchemaUnion), automatically sets mime type to "application/json" if not explicitly provided. The chat() response_format parameter still takes precedence when provided, preserving full backward compatibility.
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.
Add instance-level output format control to the Google GenAI LLM plugin. Previously, structured output could only be configured per-call via the chat() method's response_format parameter. In scenarios where the LLM is consistently used to produce JSON responses (e.g. extracting structured data, building tool-calling pipelines), having to pass response_format on every chat() call is repetitive and error-prone.
In our scenario, the agent's prompt requires the model to output JSON, which is then parsed in the tts_node to let the agent read out the content, and send an RPC to the frontend, so we need instance-level control over the JSON output.
With these two new init parameters:
The chat() response_format parameter still takes precedence when provided, preserving full backward compatibility.