Fix: Set output_schema correctly for LiteLllm #580
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.
Fixes #217
Description
This PR fixes an issue with schema validation when using non-Google models through the LiteLlm wrapper. Previously, when using models like
openai/gpt-4o
with a specified output schema, the model would either not return JSON or would return JSON that didn't follow the required schema, resulting in Pydantic validation errors.Changes
response_schema
configuration fromLlmRequest
to the LiteLlm client'sresponse_format
parameter.Testing
Tested with a sample agent that uses:
openai/gpt-4o
Before the fix, the agent would fail with Pydantic validation errors. After the fix, the model properly returns JSON in the expected format that passes validation.
Related Issues
Fixes an issue where structured output validation fails with non-Google models when using the LiteLlm wrapper.
Test File: