feat: 引入deepseek结构化输出
This commit is contained in:
@@ -16,6 +16,7 @@ from app.agents.chat.prompts_profile import (
|
||||
get_profile_followup_prompt,
|
||||
get_profile_greeting_prompt,
|
||||
)
|
||||
from app.features.memoir.memoir_images.json_payload import extract_json_payload
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
@@ -58,9 +59,13 @@ class ProfileAgent:
|
||||
prompt = get_profile_extraction_prompt(
|
||||
user_message, missing_fields, recent_dialogue=recent_dialogue or None
|
||||
)
|
||||
response = await self.llm.ainvoke(prompt)
|
||||
json_llm = self.llm.bind(
|
||||
model_kwargs={"response_format": {"type": "json_object"}},
|
||||
max_tokens=512,
|
||||
)
|
||||
response = await json_llm.ainvoke(prompt)
|
||||
content = response.content.strip()
|
||||
parsed = json.loads(content)
|
||||
parsed = json.loads(extract_json_payload(content))
|
||||
result = {}
|
||||
if "birth_year" in parsed and parsed["birth_year"] is not None:
|
||||
raw = parsed["birth_year"]
|
||||
|
||||
Reference in New Issue
Block a user