From 102cae669295e99db752752f7567d16331989cd9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AC=A7=E9=98=B3=E6=B4=8B?= <2443479321@qq.com>
Date: Tue, 15 Sep 2026 11:42:26 +0800
Subject: [PATCH] =?UTF-8?q?fix:=E5=AE=A2=E6=9C=8Dagent=E5=A2=9E=E5=8A=A0?=
=?UTF-8?q?=E8=BD=AC=E4=BA=BA=E5=B7=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
agent/advisor_agent/intent/classifier.py | 3 +-
frontend/next-env.d.ts | 4 +-
frontend/package-lock.json | 84 ------------------------
nl2sql/query_rewriter.py | 3 +-
nl2sql/result.py | 3 +-
nl2sql/sql_agent.py | 4 +-
rag/intent.py | 5 +-
scripts/check_advisor_llm.py | 3 +-
service/client_agent/memory_extractor.py | 4 +-
service/customer_agent/chat.py | 9 ++-
10 files changed, 22 insertions(+), 100 deletions(-)
diff --git a/agent/advisor_agent/intent/classifier.py b/agent/advisor_agent/intent/classifier.py
index c93e946..0e847a0 100644
--- a/agent/advisor_agent/intent/classifier.py
+++ b/agent/advisor_agent/intent/classifier.py
@@ -195,7 +195,6 @@ async def classify_advisor_intent(
{"role": "user", "content": prompt},
],
temperature=0,
- max_tokens=120,
),
timeout=timeout,
)
@@ -221,4 +220,4 @@ async def classify_advisor_intent(
return _rule_fallback(query)
-__all__ = ["IntentClassification", "classify_advisor_intent", "resolve_advisor_intent"]
+__all__ = ["IntentClassification", "classify_advisor_intent", "resolve_advisor_intent"]
\ No newline at end of file
diff --git a/frontend/next-env.d.ts b/frontend/next-env.d.ts
index ce4e94a..a419cbe 100644
--- a/frontend/next-env.d.ts
+++ b/frontend/next-env.d.ts
@@ -1,7 +1,7 @@
///
///
-import "./.next/types/routes.d.ts";
-import "./.next/types/root-params.d.ts";
+import "./.next/dev/types/routes.d.ts";
+import "./.next/dev/types/root-params.d.ts";
// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index bda5b64..bb4274d 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -157,9 +157,6 @@
"cpu": [
"arm"
],
- "libc": [
- "glibc"
- ],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -176,9 +173,6 @@
"cpu": [
"arm64"
],
- "libc": [
- "glibc"
- ],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -195,9 +189,6 @@
"cpu": [
"ppc64"
],
- "libc": [
- "glibc"
- ],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -214,9 +205,6 @@
"cpu": [
"riscv64"
],
- "libc": [
- "glibc"
- ],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -233,9 +221,6 @@
"cpu": [
"s390x"
],
- "libc": [
- "glibc"
- ],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -252,9 +237,6 @@
"cpu": [
"x64"
],
- "libc": [
- "glibc"
- ],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -271,9 +253,6 @@
"cpu": [
"arm64"
],
- "libc": [
- "musl"
- ],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -290,9 +269,6 @@
"cpu": [
"x64"
],
- "libc": [
- "musl"
- ],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
@@ -309,9 +285,6 @@
"cpu": [
"arm"
],
- "libc": [
- "glibc"
- ],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -334,9 +307,6 @@
"cpu": [
"arm64"
],
- "libc": [
- "glibc"
- ],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -359,9 +329,6 @@
"cpu": [
"ppc64"
],
- "libc": [
- "glibc"
- ],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -384,9 +351,6 @@
"cpu": [
"riscv64"
],
- "libc": [
- "glibc"
- ],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -409,9 +373,6 @@
"cpu": [
"s390x"
],
- "libc": [
- "glibc"
- ],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -434,9 +395,6 @@
"cpu": [
"x64"
],
- "libc": [
- "glibc"
- ],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -459,9 +417,6 @@
"cpu": [
"arm64"
],
- "libc": [
- "musl"
- ],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -484,9 +439,6 @@
"cpu": [
"x64"
],
- "libc": [
- "musl"
- ],
"license": "Apache-2.0",
"optional": true,
"os": [
@@ -689,9 +641,6 @@
"cpu": [
"arm64"
],
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -708,9 +657,6 @@
"cpu": [
"arm64"
],
- "libc": [
- "musl"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -727,9 +673,6 @@
"cpu": [
"x64"
],
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -746,9 +689,6 @@
"cpu": [
"x64"
],
- "libc": [
- "musl"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -932,9 +872,6 @@
"arm64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -952,9 +889,6 @@
"arm64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -972,9 +906,6 @@
"x64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -992,9 +923,6 @@
"x64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MIT",
"optional": true,
"os": [
@@ -1341,9 +1269,6 @@
"arm64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -1365,9 +1290,6 @@
"arm64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -1389,9 +1311,6 @@
"x64"
],
"dev": true,
- "libc": [
- "glibc"
- ],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -1413,9 +1332,6 @@
"x64"
],
"dev": true,
- "libc": [
- "musl"
- ],
"license": "MPL-2.0",
"optional": true,
"os": [
diff --git a/nl2sql/query_rewriter.py b/nl2sql/query_rewriter.py
index 5598919..ea84a53 100644
--- a/nl2sql/query_rewriter.py
+++ b/nl2sql/query_rewriter.py
@@ -106,7 +106,6 @@ async def rewrite_query(
{"role": "user", "content": prompt},
],
temperature=0,
- max_tokens=512,
)
except Exception: # noqa: BLE001 改写失败不阻断原查询
logger.warning("NL2SQL 查询问题改写失败,继续使用原问题", exc_info=True)
@@ -115,4 +114,4 @@ async def rewrite_query(
return value or original
-__all__ = ["rewrite_query"]
+__all__ = ["rewrite_query"]
\ No newline at end of file
diff --git a/nl2sql/result.py b/nl2sql/result.py
index 480fe25..034569e 100644
--- a/nl2sql/result.py
+++ b/nl2sql/result.py
@@ -67,8 +67,7 @@ async def render_answer(
{"role": "user", "content": prompt},
],
temperature=0,
- max_tokens=256,
)
except Exception: # noqa: BLE001 摘要失败回退固定文本
return fallback
- return answer.strip() or fallback
+ return answer.strip() or fallback
\ No newline at end of file
diff --git a/nl2sql/sql_agent.py b/nl2sql/sql_agent.py
index aac11d6..42e2665 100644
--- a/nl2sql/sql_agent.py
+++ b/nl2sql/sql_agent.py
@@ -74,7 +74,7 @@ async def generate_sql(
},
]
try:
- output = await llm_client.chat(messages, temperature=0, max_tokens=256)
+ output = await llm_client.chat(messages, temperature=0)
except Exception as exc: # noqa: BLE001 统一收敛模型异常
raise SqlGenerationError("SQL 模型调用失败") from exc
sql = _clean_model_output(output)
@@ -86,4 +86,4 @@ async def generate_sql(
raise SqlGenerationError("模型返回的 SQL 无法解析") from exc
if len(statements) != 1 or not isinstance(statements[0], exp.Select):
raise SqlGenerationError("模型只允许返回单条 SELECT")
- return GeneratedSql(sql=statements[0].sql(dialect="mysql"))
+ return GeneratedSql(sql=statements[0].sql(dialect="mysql"))
\ No newline at end of file
diff --git a/rag/intent.py b/rag/intent.py
index 99b75c0..2c232b1 100644
--- a/rag/intent.py
+++ b/rag/intent.py
@@ -20,6 +20,7 @@ class Intent(StrEnum):
COMPANY_INFO = "company_info"
CHITCHAT = "chitchat"
OFF_TOPIC = "off_topic"
+ TRANSFER_HUMAN = "transfer_human"
NO_MATCH = "no_match"
@@ -61,6 +62,8 @@ INTENT_SYSTEM_PROMPT = (
"- chitchat: 普通寒暄,如问候、致谢、告别、询问你是谁/你能做什么、在吗等一两句话的闲聊\n"
"- off_topic: 用户要求你实质性地处理与金融、基金、公司业务无关的事情,"
"如写代码、讲笑话、写作文、问天气、聊政治、情感咨询、做数学题等\n"
+ "- transfer_human: 用户明确要求转接人工客服,或表达不满、投诉、对智能客服不信任,"
+ "希望由真人处理,如“转人工”“找人工客服”“我要投诉”“人工服务”“我要见真人”“别跟我说废话找客服”等\n"
"- no_match: 无法归入以上任何一类\n"
"注意:寒暄性质的一两句话归为 chitchat;一旦用户提出金融之外的实质性请求,归为 off_topic。\n"
"只输出一行 JSON,格式:{\"intent\": \"<小写英文标签>\", \"query\": \"<完整问题>\"},"
@@ -164,4 +167,4 @@ async def intent_recognize(
except Exception:
logger.exception("intent recognition failed")
return IntentResult(Intent.NO_MATCH, query, bool(rendered))
- return parse_intent_result(raw, fallback_query=query, used_history=bool(rendered))
+ return parse_intent_result(raw, fallback_query=query, used_history=bool(rendered))
\ No newline at end of file
diff --git a/scripts/check_advisor_llm.py b/scripts/check_advisor_llm.py
index cd33df9..2a16874 100644
--- a/scripts/check_advisor_llm.py
+++ b/scripts/check_advisor_llm.py
@@ -18,7 +18,6 @@ async def check() -> None:
{"role": "user", "content": "只回复:连接正常"},
],
temperature=0,
- max_tokens=16,
)
print("chat: ok", answer[:32])
except Exception as exc:
@@ -32,4 +31,4 @@ async def check() -> None:
if __name__ == "__main__":
- asyncio.run(check())
+ asyncio.run(check())
\ No newline at end of file
diff --git a/service/client_agent/memory_extractor.py b/service/client_agent/memory_extractor.py
index 97be13c..cdd6a32 100644
--- a/service/client_agent/memory_extractor.py
+++ b/service/client_agent/memory_extractor.py
@@ -42,7 +42,7 @@ source 只能是 dialogue_confirmed、dialogue_stated、dialogue_inferred。
)
interest_signal = self._interest_fallback(query)
try:
- response = await self.llm_client.chat(prompt, temperature=0, max_tokens=800)
+ response = await self.llm_client.chat(prompt, temperature=0)
result = self._parse(response)
except Exception:
if interest_signal:
@@ -123,4 +123,4 @@ source 只能是 dialogue_confirmed、dialogue_stated、dialogue_inferred。
return result
-__all__ = ["DialogueMemoryExtractor"]
+__all__ = ["DialogueMemoryExtractor"]
\ No newline at end of file
diff --git a/service/customer_agent/chat.py b/service/customer_agent/chat.py
index d99d7b6..801ff48 100644
--- a/service/customer_agent/chat.py
+++ b/service/customer_agent/chat.py
@@ -103,6 +103,13 @@ class AnonymousCustomerAgent:
"我是华夏科技的智能客服,只能解答基金与公司业务相关的问题,"
"您可以问我基金知识、开户流程或公司信息~",
)
+ elif intent == Intent.TRANSFER_HUMAN:
+ answer = await _config(
+ self.config_getter,
+ "agent.customer.template.transfer_human",
+ "好的,正在为您转接人工客服,请稍候。"
+ "您也可以拨打官方客服热线 400-XXX-XXXX 直接联系我们。",
+ )
elif intent == Intent.CHITCHAT:
answer = await self._chitchat(session_id)
elif intent == Intent.NL2SQL_REQUEST:
@@ -248,4 +255,4 @@ class AnonymousCustomerAgent:
return bool(
re.search(r"(?