Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
refactor: 统一智能体未就绪消息处理逻辑
wizardchen8c5263aef952
diff --git a/frontend/src/components/Input-field.vue b/frontend/src/components/Input-field.vueindex 74b72726c..aa35d644e 100644--- a/frontend/src/components/Input-field.vue+++ b/frontend/src/components/Input-field.vue@@ -1168,7 +1168,7 @@ const selectAgentMode = (mode: 'quick-answer' | 'smart-reasoning') => {if (builtinAgent) {const notReadyReasons = getBuiltinAgentNotReadyReasons(builtinAgent, mode === 'smart-reasoning');if (notReadyReasons.length > 0) {- showBuiltinAgentNotReadyMessage(mode, notReadyReasons);+ showAgentNotReadyMessage(builtinAgent, notReadyReasons);showAgentModeSelector.value = false;return;}@@ -1189,26 +1189,18 @@ const handleSelectAgent = (agent: CustomAgent) => {// 根据智能体的 agent_mode 判断是否为 Agent 模式const isAgentType = agent.config?.agent_mode === 'smart-reasoning';- // 内置智能体检查 - 从实际的智能体配置来判断- if (agent.is_builtin) {- // 从 agents 列表中获取实际的内置智能体数据,如果没找到则使用传入的 agent (此时应该包含合并后的配置)- const builtinAgent = agents.value.find(a => a.id === agent.id) || agent;- if (builtinAgent) {- const notReadyReasons = getBuiltinAgentNotReadyReasons(builtinAgent, isAgentType);- if (notReadyReasons.length > 0) {- showBuiltinAgentNotReadyMessage(isAgentType ? 'smart-reasoning' : 'quick-answer', notReadyReasons);- return;- }- }- }+ // 统一检查智能体是否就绪(内置和自定义智能体使用相同逻辑)+ const actualAgent = agent.is_builtin+ ? (agents.value.find(a => a.id === agent.id) || agent)+ : agent;- // 自定义智能体检查- if (!agent.is_builtin) {- const notReadyReasons = getCustomAgentNotReadyReasons(agent);- if (notReadyReasons.length > 0) {- showCustomAgentNotReadyMessage(agent, notReadyReasons);- return;- }+ const notReadyReasons = agent.is_builtin+ ? getBuiltinAgentNotReadyReasons(actualAgent, isAgentType)+ : getCustomAgentNotReadyReasons(actualAgent);++ if (notReadyReasons.length > 0) {+ showAgentNotReadyMessage(agent, notReadyReasons);+ return;}selectedAgentId.value = agent.id;@@ -1363,17 +1355,16 @@ const getCustomAgentNotReadyReasons = (agent: CustomAgent): string[] => {return reasons}-// 显示自定义智能体未就绪的消息-const showCustomAgentNotReadyMessage = (agent: CustomAgent, reasons: string[]) => {+// 显示智能体未就绪的消息(统一处理内置和自定义智能体)+const showAgentNotReadyMessage = (agent: CustomAgent, reasons: string[]) => {const reasonsText = reasons.join('、')const messageContent = h('div', { style: 'display: flex; flex-direction: column; gap: 8px; max-width: 320px;' }, [- h('span', { style: 'color: #333; line-height: 1.5;' }, t('input.customAgentNotReadyDetail', { reasons: reasonsText })),+ h('span', { style: 'color: #333; line-height: 1.5;' }, t('input.agentNotReadyDetail', { agentName: agent.name, reasons: reasonsText })),h('a', {href: '#',onClick: (e: Event) => {e.preventDefault();- // 跳转到智能体编辑页面router.push(`/platform/agents?edit=${agent.id}`);},style: 'color: #07C05F; text-decoration: none; font-weight: 500; cursor: pointer; align-self: flex-start;',@@ -1392,39 +1383,6 @@ const showCustomAgentNotReadyMessage = (agent: CustomAgent, reasons: string[]) =});}-// 显示内置智能体未就绪的消息-const showBuiltinAgentNotReadyMessage = (mode: 'smart-reasoning' | 'quick-answer', reasons: string[]) => {- const agentName = mode === 'smart-reasoning'- ? t('input.builtinAgentSettingName')- : t('input.builtinNormalSettingName');- const builtinAgentId = mode === 'smart-reasoning' ? BUILTIN_SMART_REASONING_ID : BUILTIN_QUICK_ANSWER_ID;- const reasonsText = reasons.join('、')-- const messageContent = h('div', { style: 'display: flex; flex-direction: column; gap: 8px; max-width: 320px;' }, [- h('span', { style: 'color: #333; line-height: 1.5;' }, t('input.builtinAgentNotReadyDetail', { agentName, reasons: reasonsText })),- h('a', {- href: '#',- onClick: (e: Event) => {- e.preventDefault();- // 跳转到内置智能体编辑页面- router.push(`/platform/agents?edit=${builtinAgentId}`);- },- style: 'color: #07C05F; text-decoration: none; font-weight: 500; cursor: pointer; align-self: flex-start;',- onMouseenter: (e: Event) => {- (e.target as HTMLElement).style.textDecoration = 'underline';- },- onMouseleave: (e: Event) => {- (e.target as HTMLElement).style.textDecoration = 'none';- }- }, t('input.goToAgentEditor'))- ]);-- MessagePlugin.warning({- content: () => messageContent,- duration: 5000- });-}-const toggleWebSearch = () => {// 互斥:虽然不是弹出层,但操作时关闭其他弹出层体验更好showMention.value = false;diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.tsindex 6ef980429..7bcb90550 100755--- a/frontend/src/i18n/locales/en-US.ts+++ b/frontend/src/i18n/locales/en-US.ts@@ -961,6 +961,7 @@ export default {customAgentMissingSummaryModel: 'Chat Model (Summary Model)',customAgentMissingRerankModel: 'Rerank Model',goToAgentEditor: 'Go to configure →',+ agentNotReadyDetail: 'Agent "{agentName}" is not ready. Please configure: {reasons}',builtinAgentNotReadyDetail: 'Built-in agent "{agentName}" is not ready. Please configure: {reasons}',builtinAgentSettingName: 'Intelligent Reasoning',builtinNormalSettingName: 'Quick Q&A',diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.tsindex 8bb5e616c..e1bdd2be8 100755--- a/frontend/src/i18n/locales/zh-CN.ts+++ b/frontend/src/i18n/locales/zh-CN.ts@@ -1681,6 +1681,7 @@ export default {customAgentMissingSummaryModel: "对话模型(Summary Model)",customAgentMissingRerankModel: "重排模型(Rerank Model)",goToAgentEditor: "前往配置 →",+ agentNotReadyDetail: "智能体「{agentName}」未就绪,需要配置以下内容:{reasons}",builtinAgentNotReadyDetail: "内置智能体「{agentName}」未就绪,需要配置以下内容:{reasons}",builtinAgentSettingName: "智能推理",builtinNormalSettingName: "快速问答",