chore/ 删除无用文件
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
ProfileAgent:用户资料收集 Specialist
|
||||
负责提取资料、资料追问、资料收集开场白,不负责 Redis 持久化(由 Orchestrator 统一处理)
|
||||
"""
|
||||
|
||||
import json
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
@@ -47,7 +48,9 @@ class ProfileAgent:
|
||||
recent_dialogue = ""
|
||||
if conversation_id:
|
||||
history_messages = await get_history_messages(conversation_id)
|
||||
recent = history_messages[-4:] if len(history_messages) > 4 else history_messages
|
||||
recent = (
|
||||
history_messages[-4:] if len(history_messages) > 4 else history_messages
|
||||
)
|
||||
parts = []
|
||||
for msg in recent:
|
||||
if isinstance(msg, HumanMessage):
|
||||
@@ -105,10 +108,16 @@ class ProfileAgent:
|
||||
)
|
||||
history_messages = await get_history_messages(conversation_id)
|
||||
history_string = format_history_string(history_messages)
|
||||
full_prompt = f"{prompt}\n\n{history_string}\n\nHuman: {user_message}\n\nAssistant:"
|
||||
full_prompt = (
|
||||
f"{prompt}\n\n{history_string}\n\nHuman: {user_message}\n\nAssistant:"
|
||||
)
|
||||
response = await self.llm.ainvoke(full_prompt)
|
||||
response_text = response.content if hasattr(response, "content") else str(response)
|
||||
messages = [msg.strip() for msg in response_text.split("[SPLIT]") if msg.strip()]
|
||||
response_text = (
|
||||
response.content if hasattr(response, "content") else str(response)
|
||||
)
|
||||
messages = [
|
||||
msg.strip() for msg in response_text.split("[SPLIT]") if msg.strip()
|
||||
]
|
||||
return messages[:3] if messages else [response_text]
|
||||
except Exception as e:
|
||||
logger.error("生成资料跟进回复失败: %s", e)
|
||||
@@ -129,9 +138,15 @@ class ProfileAgent:
|
||||
history_string = format_history_string(history_messages)
|
||||
full_prompt = f"{prompt}\n\n{history_string}" if history_string else prompt
|
||||
response = await self.llm.ainvoke(full_prompt)
|
||||
response_text = response.content if hasattr(response, "content") else str(response)
|
||||
messages = [msg.strip() for msg in response_text.split("[SPLIT]") if msg.strip()]
|
||||
response_text = (
|
||||
response.content if hasattr(response, "content") else str(response)
|
||||
)
|
||||
messages = [
|
||||
msg.strip() for msg in response_text.split("[SPLIT]") if msg.strip()
|
||||
]
|
||||
return messages[:2] if messages else [response_text]
|
||||
except Exception as e:
|
||||
logger.error("生成资料收集开场白失败: %s", e)
|
||||
return ["你好!在我们开始聊人生故事之前,能先简单介绍一下你自己吗?比如你是哪一年出生的?"]
|
||||
return [
|
||||
"你好!在我们开始聊人生故事之前,能先简单介绍一下你自己吗?比如你是哪一年出生的?"
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user