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

@@ -798,7 +798,11 @@ def generate_chapter_content(self, user_id: str, stage: str, new_content: str):
new_content=new_content,
existing_content=existing_content,
)
response = llm.invoke(prompt)
json_llm = llm.bind(
model_kwargs={"response_format": {"type": "json_object"}},
max_tokens=4096,
)
response = json_llm.invoke(prompt)
new_narrative = response.content.strip()
if _is_json_narrative(new_narrative):
narrative = new_narrative