feat(api): 统一 LLM JSON 调用层 llm_json_call,按域 Schema 迁移 chat/memoir agents

This commit is contained in:
Kevin
2026-04-03 13:34:27 +08:00
parent 41518bda11
commit 43d1689e9c
28 changed files with 1006 additions and 352 deletions

View File

@@ -4,6 +4,8 @@
from typing import Dict, List, Optional
from app.agents.chat.output_rules import chat_output_rules
PROFILE_FIELD_NAMES = {
"birth_year": "出生年份",
@@ -40,7 +42,7 @@ def get_profile_greeting_prompt(missing_fields: List[str], nickname: str = "") -
- "你现在是做什么工作的呀?或者之前主要从事什么职业?"
## 严格禁止
- 禁止输出括号注释、思考过程
- {chat_output_rules()}
- 禁止说"我需要收集信息"之类的机械话
- 禁止一次列出所有问题
@@ -71,12 +73,10 @@ def get_profile_extraction_prompt(
return f"""请从以下内容中提取用户已提到的基础资料信息。{dialogue_section}用户本轮回答:
"{user_message}"
**JSON 输出**:接口已启用 `response_format=json_object`DeepSeek JSON 模式),你必须只输出一个合法 JSON 对象。
需要提取的字段(只提取确实在对话中出现过的):
{missing_names}
请返回 JSON 格式,只包含确实提到的字段
输出示例(只含确实提到的字段;无则 {{}}
{{
"birth_year": 1965,
"birth_place": "湖南长沙",
@@ -88,9 +88,7 @@ def get_profile_extraction_prompt(
1. birth_year 填整数(四位数),如"65年出生"转为 1965
2. 如果用户在任一轮说过出生地/成长地/职业等,都要提取
3. 只提取明确提到的信息,不要猜测
4. 如果没有提取到任何信息,返回空对象 {{}}
只返回 JSON不要其他内容。"""
4. 如果没有提取到任何信息,返回空对象 {{}}"""
def get_profile_followup_prompt(
@@ -145,8 +143,7 @@ def get_profile_followup_prompt(
严格禁止:
- **严禁再次询问「已知信息」中已列出的内容**(例如已知出生年份就绝不要再问哪年出生)
- 禁止输出括号注释、思考过程
- 禁止说"我注意到""我需要了解"
- {chat_output_rules()}
回复格式:多条消息用 [SPLIT] 分隔。
直接输出你要说的话:"""