fix(genai): drop format flag; extract trailing JSON #41
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/ollama-extract-json"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Reasoning models need free streaming; we just take the outermost {...}.
qwen3:14b (and deepseek-r1, other reasoning models) wrap their output in <think>…</think> chains-of-thought before emitting real output. With format=json the constrained sampler terminated immediately at `{}` because the thinking block wasn't valid JSON; without format the model thinks normally and appends the actual JSON at the end. OllamaClient now omits the format flag and extracts the outermost balanced `{…}` block from the response (brace depth counter, string- literal aware). Works for reasoning models, ```json``` code-fenced outputs, and plain JSON alike. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>