chore/ 删除无用文件
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
InterviewAgent:正式访谈 Specialist
|
||||
负责状态感知回复、开场白,不负责 Redis 持久化(由 Orchestrator 统一处理)
|
||||
"""
|
||||
|
||||
from typing import Any, List
|
||||
|
||||
from app.core.dependencies import get_llm_provider
|
||||
@@ -36,11 +37,81 @@ class InterviewAgent:
|
||||
"""根据关键词检测用户正在谈论的人生阶段"""
|
||||
message = user_message.lower()
|
||||
stage_keywords = {
|
||||
"childhood": ["童年", "小时候", "出生", "家乡", "小镇", "爸妈", "父亲", "母亲", "爷爷", "奶奶", "外公", "外婆", "幼儿园"],
|
||||
"education": ["上学", "学校", "老师", "同学", "教育", "大学", "高中", "初中", "小学", "考试", "毕业", "读书", "高考", "课堂"],
|
||||
"career": ["工作", "职业", "事业", "公司", "同事", "创业", "升职", "跳槽", "老板", "行业", "项目", "加班", "薪水", "面试"],
|
||||
"family": ["伴侣", "孩子", "家庭", "家人", "结婚", "爱人", "老婆", "老公", "丈夫", "妻子", "儿子", "女儿", "婚礼", "恋爱"],
|
||||
"belief": ["信念", "价值观", "座右铭", "坚持", "原则", "信仰", "意义", "感悟", "遗憾", "骄傲"],
|
||||
"childhood": [
|
||||
"童年",
|
||||
"小时候",
|
||||
"出生",
|
||||
"家乡",
|
||||
"小镇",
|
||||
"爸妈",
|
||||
"父亲",
|
||||
"母亲",
|
||||
"爷爷",
|
||||
"奶奶",
|
||||
"外公",
|
||||
"外婆",
|
||||
"幼儿园",
|
||||
],
|
||||
"education": [
|
||||
"上学",
|
||||
"学校",
|
||||
"老师",
|
||||
"同学",
|
||||
"教育",
|
||||
"大学",
|
||||
"高中",
|
||||
"初中",
|
||||
"小学",
|
||||
"考试",
|
||||
"毕业",
|
||||
"读书",
|
||||
"高考",
|
||||
"课堂",
|
||||
],
|
||||
"career": [
|
||||
"工作",
|
||||
"职业",
|
||||
"事业",
|
||||
"公司",
|
||||
"同事",
|
||||
"创业",
|
||||
"升职",
|
||||
"跳槽",
|
||||
"老板",
|
||||
"行业",
|
||||
"项目",
|
||||
"加班",
|
||||
"薪水",
|
||||
"面试",
|
||||
],
|
||||
"family": [
|
||||
"伴侣",
|
||||
"孩子",
|
||||
"家庭",
|
||||
"家人",
|
||||
"结婚",
|
||||
"爱人",
|
||||
"老婆",
|
||||
"老公",
|
||||
"丈夫",
|
||||
"妻子",
|
||||
"儿子",
|
||||
"女儿",
|
||||
"婚礼",
|
||||
"恋爱",
|
||||
],
|
||||
"belief": [
|
||||
"信念",
|
||||
"价值观",
|
||||
"座右铭",
|
||||
"坚持",
|
||||
"原则",
|
||||
"信仰",
|
||||
"意义",
|
||||
"感悟",
|
||||
"遗憾",
|
||||
"骄傲",
|
||||
],
|
||||
}
|
||||
for stage, keywords in stage_keywords.items():
|
||||
if any(word in message for word in keywords):
|
||||
@@ -81,12 +152,16 @@ class InterviewAgent:
|
||||
) -> List[str]:
|
||||
"""生成状态感知的访谈回复,不持久化(由 Orchestrator 负责)"""
|
||||
if not self.llm:
|
||||
return ["抱歉,LLM 服务未配置。请设置 DEEPSEEK_API_KEY 或 LLM_API_KEY 环境变量。"]
|
||||
return [
|
||||
"抱歉,LLM 服务未配置。请设置 DEEPSEEK_API_KEY 或 LLM_API_KEY 环境变量。"
|
||||
]
|
||||
try:
|
||||
empty_slots = memoir_state.empty_slots_for_current_stage()
|
||||
filled_slots = {
|
||||
key: value.snippet
|
||||
for key, value in memoir_state.slots.get(memoir_state.current_stage, {}).items()
|
||||
for key, value in memoir_state.slots.get(
|
||||
memoir_state.current_stage, {}
|
||||
).items()
|
||||
if value.snippet
|
||||
}
|
||||
detected_user_stage = self._detect_user_stage(user_message)
|
||||
@@ -110,8 +185,12 @@ class InterviewAgent:
|
||||
history_string = format_history_string(history_messages)
|
||||
full_prompt = f"{system_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)
|
||||
@@ -138,8 +217,12 @@ class InterviewAgent:
|
||||
)
|
||||
full_prompt = f"{prompt}\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[:2] if messages else [response_text]
|
||||
except Exception as e:
|
||||
logger.error("生成开场白失败: %s", e, exc_info=True)
|
||||
|
||||
Reference in New Issue
Block a user