add .gitattributes: python文件统一LF换行

This commit is contained in:
2026-09-14 13:00:15 +08:00
parent 67d5cfc2b8
commit bc7761d79e
6 changed files with 64 additions and 8 deletions
+9 -1
View File
@@ -49,6 +49,7 @@ _CLASSIFIER_PROMPT = """你是基金投顾工作台的意图分类器,只负
"""
_RECOMMENDATION_TERMS = ("推荐", "组合建议", "配置建议", "买什么", "适合配置", "筛选基金", "投资方案")
_SCOPE_ERROR_MESSAGE = "投顾范围查询仅支持客户数据查询"
def _rule_fallback(query: str | None) -> IntentClassification:
@@ -94,6 +95,13 @@ async def classify_advisor_intent(
return IntentClassification(explicit_intent, 1.0, "explicit", "客户端显式指定")
if not query or not query.strip():
return IntentClassification("", 0.0, "fallback", "空输入")
if re.sub(r"\s+", "", query) == _SCOPE_ERROR_MESSAGE:
return IntentClassification(
AGENT_INTENT_CASUAL_CHAT,
1.0,
"rule",
"识别为系统提示文本而非业务查询",
)
if llm_client is not None:
try:
raw = await asyncio.wait_for(
@@ -114,7 +122,7 @@ async def classify_advisor_intent(
rule_intent = recognize_advisor_intent(query)
if (
rule_intent == AGENT_INTENT_DATA_QUERY
and parsed.intent == AGENT_INTENT_RECOMMEND
and parsed.intent != AGENT_INTENT_DATA_QUERY
and not any(term in (query or "") for term in _RECOMMENDATION_TERMS)
):
return IntentClassification(
+11
View File
@@ -40,6 +40,8 @@ _REBALANCE_TERMS = ("调仓", "再平衡", "组合调整", "配置偏离", "偏
_FUND_ANALYSIS_TERMS = ("基金分析", "分析基金", "基金表现", "净值走势", "最大回撤", "夏普比率", "年化波动")
_DIALOGUE_TERMS = ("话术", "沟通", "怎么跟客户说", "如何向客户解释", "安抚客户", "投诉处理")
_RECOMMEND_TERMS = ("推荐", "组合建议", "配置建议", "买什么", "适合配置", "筛选基金", "投资方案")
_CUSTOMER_IDENTITY_TERMS = ("是谁", "姓名", "实名", "基本信息", "联系方式", "手机号")
_SCOPE_ERROR_MESSAGE = "投顾范围查询仅支持客户数据查询"
def _contains_any(text: str, terms: tuple[str, ...]) -> bool:
@@ -57,6 +59,8 @@ def recognize_advisor_intent(query: str | None, explicit_intent: str | None = No
text = re.sub(r"\s+", "", query or "")
if not text:
return None
if text == _SCOPE_ERROR_MESSAGE:
return None
# 先处理最明确的任务词,避免“查询基金收益”被误判成普通数据查询。
if _contains_any(text, _REBALANCE_TERMS):
@@ -68,6 +72,13 @@ def recognize_advisor_intent(query: str | None, explicit_intent: str | None = No
has_action = any(term in text for term in _QUERY_ACTIONS)
has_data = any(term in text for term in _DATA_TERMS)
has_customer_identity = (
"客户" in text
and _contains_any(text, _CUSTOMER_IDENTITY_TERMS)
and not _contains_any(text, _RECOMMEND_TERMS)
)
if has_customer_identity:
return AGENT_INTENT_DATA_QUERY
if has_data and (has_action or "客户" in text or "近一年" in text or "本月" in text):
return AGENT_INTENT_DATA_QUERY
if _contains_any(text, _RECOMMEND_TERMS):