Skip to content

Conversation

@ansh-info
Copy link

@ansh-info ansh-info commented Dec 11, 2025

Fixes #17807 (Ollama /api/chat returns non-JSON, breaking structured output/tool calls)

Pre-Submission checklist

  • I have Added testing in the tests/litellm/ (https://github.com/BerriAI/litellm/tree/main/tests/litellm) directory, Adding at least 1 test is a hard requirement - see details (https://docs.litellm.ai/docs/extras/contributing_code)

  • I have added a screenshot of my new test passing locally

  • My PR passes all unit tests on make test-unit (https://docs.litellm.ai/docs/extras/contributing_code)

  • My PR's scope is as isolated as possible, it only solves 1 specific problem

    Type

    🐛 Bug Fix

    Changes

    • Add a best-effort JSON coercion in ollama_chat when format/structured output is requested but /api/chat returns mixed natural text + JSON; applies to sync/async paths.
    • Add a regression test covering mixed text + JSON to ensure coercion extracts a valid JSON object.
    • Goal: prevent structured-output/tool-call parsing from failing when the model includes a JSON fragment in otherwise natural-language replies.

… in LiteLLM

Co-authored-by: Apoorva Gupta <apoorvaagupta.info@gmail.com>
@vercel
Copy link

vercel bot commented Dec 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
litellm Error Error Dec 11, 2025 9:57am

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ansh-info can you share a screenshot of your code being run on an ollama_chat call?

i think this is a dead/unused file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

3 participants