feat:修复投顾agent功能

This commit is contained in:
2026-09-14 21:41:40 +08:00
parent fc1d74570f
commit 058f45115d
14 changed files with 142 additions and 33 deletions
+6 -1
View File
@@ -16,6 +16,11 @@ _SYSTEM_PROMPT = """你是基金平台 NL2SQL 的问题改写器。
不能扩大权限范围,不能臆造查询结果;上下文不足时保留原问题。
"""
_REFERENCE_TERMS = (
"他", "她", "它", "他们", "她们", "它们", "这个客户", "该客户", "那个客户",
"这个基金", "该基金", "那只基金", "这只基金", "这个结果", "上一轮", "刚才", "前面",
)
def _rewrite_explicit_customer_identity(question: str) -> str | None:
normalized = re.sub(r"\s+", "", question)
@@ -68,7 +73,7 @@ async def rewrite_query(
contextual_identity = _rewrite_customer_name_follow_up(original, context)
if contextual_identity:
return contextual_identity
if not context or llm_client is None:
if not context or llm_client is None or not any(term in original for term in _REFERENCE_TERMS):
return original
prompt = (