feat:修复投顾agent功能
This commit is contained in:
@@ -21,6 +21,24 @@ _REFERENCE_TERMS = (
|
||||
"这个基金", "该基金", "那只基金", "这只基金", "这个结果", "上一轮", "刚才", "前面",
|
||||
)
|
||||
|
||||
_CUSTOMER_RISK_LABELS = {
|
||||
"保守型": "C1",
|
||||
"稳健型": "C2",
|
||||
"平衡型": "C3",
|
||||
"进取型": "C4",
|
||||
"激进型": "C5",
|
||||
}
|
||||
|
||||
|
||||
def _normalize_customer_risk_label(question: str) -> str:
|
||||
"""将展示层客户风险标签规范化为数据库 C1-C5 编码。"""
|
||||
normalized = re.sub(r"\s+", "", question)
|
||||
if "客户" not in normalized and "风险" not in normalized:
|
||||
return normalized
|
||||
for label, code in _CUSTOMER_RISK_LABELS.items():
|
||||
normalized = normalized.replace(label, code)
|
||||
return normalized
|
||||
|
||||
|
||||
def _rewrite_explicit_customer_identity(question: str) -> str | None:
|
||||
normalized = re.sub(r"\s+", "", question)
|
||||
@@ -63,7 +81,7 @@ async def rewrite_query(
|
||||
llm_client=llm,
|
||||
) -> str:
|
||||
"""使用有限会话上下文补全问题;改写失败时安全返回原问题。"""
|
||||
original = (question or "").strip()
|
||||
original = _normalize_customer_risk_label((question or "").strip())
|
||||
context = (conversation_context or "").strip()
|
||||
if not original:
|
||||
return original
|
||||
|
||||
Reference in New Issue
Block a user