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 -2
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)
@@ -115,4 +114,4 @@ async def rewrite_query(
return value or original
__all__ = ["rewrite_query"]
__all__ = ["rewrite_query"]
+1 -2
View File
@@ -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
+2 -2
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)
@@ -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"))