|
|
@@ -86,7 +86,14 @@ def create_health_coach_graph():
|
|
|
|
|
|
async def generate_answer(state: HealthCoachState) -> dict:
|
|
|
"""带健康知识检索的 LLM 生成"""
|
|
|
- messages = [SystemMessage(content=await get_prompt("health_coach") or DEFAULT_COACH_PROMPT)]
|
|
|
+ # 人格路由:context.coach_id (xibao/fubao) -> 专属prompt,三级回退保证可用性
|
|
|
+ _ctx = state.get("context") or {}
|
|
|
+ _coach_id = _ctx.get("coach_id")
|
|
|
+ if _coach_id not in ("xibao", "fubao"):
|
|
|
+ _coach_id = None
|
|
|
+ _persona_prompt = await get_prompt(f"health_coach_{_coach_id}") if _coach_id else None
|
|
|
+ _base_prompt = await get_prompt("health_coach")
|
|
|
+ messages = [SystemMessage(content=_persona_prompt or _base_prompt or DEFAULT_COACH_PROMPT)]
|
|
|
|
|
|
# 家庭上下文
|
|
|
ctx = state.get("context") or {}
|