feat: 引入deepseek结构化输出

This commit is contained in:
yangshilin
2026-03-19 11:27:43 +08:00
parent f3629efec3
commit 4c75c6f4f4
10 changed files with 74 additions and 26 deletions

View File

@@ -69,7 +69,11 @@ class NarrativeAgent:
user_profile=user_profile,
birth_year=birth_year,
)
response = llm.invoke(prompt)
json_llm = llm.bind(
model_kwargs={"response_format": {"type": "json_object"}},
max_tokens=4096,
)
response = json_llm.invoke(prompt)
return (response.content or "").strip()
except Exception as e:
logger.warning("NarrativeAgent 生成叙事失败: %s", e)