Skip to content

fix(llm_client): remove response_format json_object for local LLM compatibility#122

Open
ImL1s wants to merge 1 commit into666ghj:mainfrom
ImL1s:fix/lm-studio-json-object-compat
Open

fix(llm_client): remove response_format json_object for local LLM compatibility#122
ImL1s wants to merge 1 commit into666ghj:mainfrom
ImL1s:fix/lm-studio-json-object-compat

Conversation

@ImL1s
Copy link

@ImL1s ImL1s commented Mar 10, 2026

Problem

chat_json() uses response_format={"type": "json_object"}, but LM Studio and Ollama do not support this parameter (only json_schema or text), causing API calls to fail when using local LLMs.

Related references:

Solution

Remove response_format from chat_json(). The method already has robust markdown code fence cleanup logic (L93-97) that correctly parses JSON from raw LLM output, making response_format unnecessary.

This follows the same approach as commit 985f89f (handling <think> tags from reasoning models) — improving compatibility with diverse model outputs.

Changed Files

  • backend/app/utils/llm_client.py: Remove response_format in chat_json(), rely on prompt instructions + markdown cleanup

Testing

  • LM Studio + qwen3.5-9b: Full prediction pipeline (ontology → graph → prepare → simulate → report) passes
  • Does not affect OpenAI API users (removing response_format is backwards compatible)

…patibility

LM Studio and Ollama do not support response_format: json_object,
only json_schema or text. This causes errors when using local LLMs.

The existing markdown fence cleanup logic in chat_json() already
handles parsing JSON from raw LLM output, making response_format
unnecessary. This change follows the same pattern as commit 985f89f
which improved compatibility with diverse model outputs.

Tested with: LM Studio + qwen3.5-9b (full predict pipeline passes)
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. LLM API Any questions regarding the LLM API labels Mar 10, 2026
@ImL1s ImL1s changed the title fix(llm_client): 移除 response_format json_object 以兼容本地 LLM fix(llm_client): remove response_format json_object for local LLM compatibility Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LLM API Any questions regarding the LLM API size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant