fix:客服agent增加转人工

This commit is contained in:
2026-09-15 11:42:26 +08:00
parent 177a28b1de
commit 102cae6692
10 changed files with 22 additions and 100 deletions
-1
View File
@@ -195,7 +195,6 @@ async def classify_advisor_intent(
{"role": "user", "content": prompt},
],
temperature=0,
max_tokens=120,
),
timeout=timeout,
)
+2 -2
View File
@@ -1,7 +1,7 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
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.
-84
View File
@@ -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": [
-1
View File
@@ -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)
-1
View File
@@ -67,7 +67,6 @@ async def render_answer(
{"role": "user", "content": prompt},
],
temperature=0,
max_tokens=256,
)
except Exception: # noqa: BLE001 摘要失败回退固定文本
return fallback
+1 -1
View File
@@ -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)
+3
View File
@@ -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\": \"<完整问题>\"},"
-1
View File
@@ -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:
+1 -1
View File
@@ -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:
+7
View File
@@ -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: