-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Fixed Ollama Structured Response not working #10616 #10617
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
The response_format parameter conversion is already handled in utils.py's get_optional_params function, making the duplicate check in ollama_chat.py unnecessary. This change removes the redundant code while maintaining the same functionality.
Hi @imdigitalashish and @krrishdholakia, the lack of structured output in ollama via litellm drove me crazy far enough that I looked into it today. I see you check for type I just added additional if and then it worked as expected:
I am using pydantic '2.11.4' and litellm '1.69.1' Let me know what you think! |
Hey @yelonek is this an alternative to @imdigitalashish's PR? if so - can you file it separately with a unit test in |
I think it is complementary. |
What's the issue you see? @yelonek |
Title
feat(ollama): Allow direct Pydantic model usage in response_format for ollama_chat
Relevant issues
Fixes #10616
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/
directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit
Type
🐛 Bug Fix
Changes
The key changes are:
KeyError: 'schema'
when users attempted to use Pydantic models without the precise nested structure, as reported in [Bug]: Structured Output not working with Ollama #10616. The PR ensures the schema is correctly processed bylitellm
before being passed to the Ollama API.These changes enhance the developer experience for using structured outputs with Ollama via
litellm
and address the incompatibility noted in the referenced issue.