Files
life-echo/api/app/agents/chat/occupation_context.py

36 lines
1.6 KiB
Python
Raw Normal View History

"""default 路径下根据用户职业自由文本注入轻量提示(与 cadre/military 专属块正交)。"""
from __future__ import annotations
from app.agents.chat.background_voice import normalize_background_voice
def get_occupation_chat_hint(occupation: str | None, background_voice: str) -> str:
"""default 路径的通用职业上下文cadre/military 已有专属块,返回空串。"""
if normalize_background_voice(background_voice) != "default":
return ""
occ = (occupation or "").strip()
if not occ:
return ""
return (
f"## 用户职业背景\n"
f"用户从事过「{occ}」相关工作。聊天时自然贴合这一背景,"
f"在用语和追问方向上适度靠近用户的职业经历与知识面,但不要刻意。"
)
def get_occupation_narrative_hint(occupation: str | None, background_voice: str) -> str:
"""default 路径的叙事职业上下文。"""
if normalize_background_voice(background_voice) != "default":
return ""
occ = (occupation or "").strip()
if not occ:
return ""
return (
f"## 用户职业背景(仅供文体微调,须遵守事实边界)\n"
f"用户从事过「{occ}」相关工作。叙事时可适度使用该领域常见的书面用语,"
f"让正文贴近讲述者的身份感。\n"
f"**禁止**因职业背景而补充口述未出现的岗位职责、行业流程、单位层级或专业术语细节;"
f"只有当用户口述里已出现相关表达时,才可顺势书面化。"
)