From 85a6da59491c8283bf55435dfc574e88a1628974 Mon Sep 17 00:00:00 2001 From: Nelson <1475262689@qq.com> Date: Fri, 31 Jul 2026 17:42:25 +0800 Subject: [PATCH] feat: route fixed information chats by model --- .../apps/admin-web/src/App.vue | 14 +- .../src/components/AgentManagementView.vue | 12 +- .../admin-web/src/config/systemSettings.ts | 7 + .../apps/admin-web/src/styles.css | 1 + .../apps/admin-web/src/types/api.ts | 4 + .../app/services/agent_debug_service.py | 46 ++++- .../apps/backend/app/services/chat_service.py | 21 ++- .../app/services/chat_stream_service.py | 57 +++++- .../app/services/model_routing_service.py | 51 +++++- .../backend/app/services/model_service.py | 51 +++++- .../app/services/model_stream_service.py | 166 +++++++++++++++--- .../tests/test_agent_runtime_config.py | 84 ++++++++- .../apps/backend/tests/test_model_routing.py | 145 ++++++++++++++- .../deployment/DEPLOYMENT_GUIDE.md | 4 + .../docs/qianwen_product_todo.md | 1 + 15 files changed, 607 insertions(+), 57 deletions(-) diff --git a/ai_knowledge_base_v2/apps/admin-web/src/App.vue b/ai_knowledge_base_v2/apps/admin-web/src/App.vue index e39e234..64b132f 100644 --- a/ai_knowledge_base_v2/apps/admin-web/src/App.vue +++ b/ai_knowledge_base_v2/apps/admin-web/src/App.vue @@ -310,6 +310,7 @@ function modelSceneLabel(scene: string) { return ({ background_report: "周期报告", background_summary: "摘要沉淀", + fixed_info: "固定信息问答", knowledge_grounded: "知识问答", general_chat: "通用对话", } as Record)[scene] || scene || "未分类"; @@ -1459,11 +1460,14 @@ function formatRecordDateTime(value: string, boundary: "start" | "end") { -
- 固定信息 - 深度对话 - 摘要沉淀 - 周期报告 +
+
+ 固定信息 + 深度对话 + 摘要沉淀 + 周期报告 +
+ 默认主模型勾选某项能力时会优先承担该场景;如需专用模型接管,请取消主模型的对应能力,并为专用模型开启该能力。
diff --git a/ai_knowledge_base_v2/apps/admin-web/src/components/AgentManagementView.vue b/ai_knowledge_base_v2/apps/admin-web/src/components/AgentManagementView.vue index 3c61b50..7498bb2 100644 --- a/ai_knowledge_base_v2/apps/admin-web/src/components/AgentManagementView.vue +++ b/ai_knowledge_base_v2/apps/admin-web/src/components/AgentManagementView.vue @@ -33,6 +33,7 @@ const historyDetailOpen = ref(false); const selectedHistory = ref(null); const historyDetailLoading = ref(false); const agentDebugTrace = ref[]>([]); +const lastDebugRoute = ref<{ modelName?: string; routeReason?: string } | null>(null); const agentPreviewMessages = ref<{ role: "user" | "assistant" | "system"; content: string; @@ -104,7 +105,9 @@ async function load() { applyPrompt(promptResult); models.value = modelRows; knowledge.value = knowledgeRows; - agentForm.modelId = modelRows.find((item) => item.enabled === 1)?.id ?? modelRows[0]?.id; + agentForm.modelId = modelRows.find((item) => item.isDefault === 1)?.id + ?? modelRows.find((item) => item.enabled === 1)?.id + ?? modelRows[0]?.id; applyRuntimeConfig(formalConfig); applyDebugModelDefaults(agentForm.modelId); agentForm.knowledgeIds = knowledgeRows @@ -313,6 +316,7 @@ async function debugAgent() { agentForm.question = ""; agentDebugging.value = true; agentDebugTrace.value = []; + lastDebugRoute.value = null; agentDebugAbortController.value = new AbortController(); scrollAgentPreview(); try { @@ -348,7 +352,8 @@ async function debugAgent() { }, (result) => { agentDebugTrace.value = result.retrievalTrace || []; - ElMessage.success(result.message || "Agent 调试完成"); + lastDebugRoute.value = { modelName: result.modelName, routeReason: result.routeReason }; + ElMessage.success(`${result.message || "Agent 调试完成"} · ${result.modelName || selectedModelName.value}`); }, agentDebugAbortController.value.signal, ); @@ -383,6 +388,7 @@ function scrollAgentPreview() { function clearAgentPreview() { agentPreviewMessages.value = [{ role: "assistant", content: "预览已清空,可以继续发起新的 Agent 调试。" }]; agentDebugTrace.value = []; + lastDebugRoute.value = null; } function changeTypeLabel(value?: string) { @@ -588,7 +594,7 @@ function errorMessage(error: unknown, fallback: string) {