Problem
KnowledgeExtractorAgent passes response_format={"type": "json_object"} to the LLM. DeepSeek API does not support this parameter and returns JSON wrapped in markdown code fences (```json ... ```), causing json.loads() to fail.
Steps to Reproduce
- Configure LLM to use DeepSeek (
LLM_BINDING=deepseek, LLM_MODEL=deepseek-chat)
- Upload a document and trigger knowledge point extraction
- Extraction fails with JSON decode error
Expected
The extractor should handle markdown-wrapped JSON responses gracefully.
Suggested Fix
In deeptutor/agents/knowledge_extractor/extractor_agent.py, strip markdown fences before parsing:
cleaned = response.strip()
if cleaned.startswith("```"):
first_newline = cleaned.find("\n")
if first_newline != -1:
cleaned = cleaned[first_newline + 1:]
if cleaned.rstrip().endswith("```"):
cleaned = cleaned.rstrip()[:-3].rstrip()
result = json.loads(cleaned)
Also consider removing response_format={"type": "json_object"} for providers that don't support it, or making it configurable.
Environment
- LLM: DeepSeek (deepseek-chat)
- Python 3.14, Windows 11
Problem
KnowledgeExtractorAgentpassesresponse_format={"type": "json_object"}to the LLM. DeepSeek API does not support this parameter and returns JSON wrapped in markdown code fences (```json ... ```), causingjson.loads()to fail.Steps to Reproduce
LLM_BINDING=deepseek,LLM_MODEL=deepseek-chat)Expected
The extractor should handle markdown-wrapped JSON responses gracefully.
Suggested Fix
In
deeptutor/agents/knowledge_extractor/extractor_agent.py, strip markdown fences before parsing:Also consider removing
response_format={"type": "json_object"}for providers that don't support it, or making it configurable.Environment