refactor: 统一智能体未就绪消息处理逻辑
This commit is contained in:
@@ -1168,7 +1168,7 @@ const selectAgentMode = (mode: 'quick-answer' | 'smart-reasoning') => {
|
|||||||
if (builtinAgent) {
|
if (builtinAgent) {
|
||||||
const notReadyReasons = getBuiltinAgentNotReadyReasons(builtinAgent, mode === 'smart-reasoning');
|
const notReadyReasons = getBuiltinAgentNotReadyReasons(builtinAgent, mode === 'smart-reasoning');
|
||||||
if (notReadyReasons.length > 0) {
|
if (notReadyReasons.length > 0) {
|
||||||
showBuiltinAgentNotReadyMessage(mode, notReadyReasons);
|
showAgentNotReadyMessage(builtinAgent, notReadyReasons);
|
||||||
showAgentModeSelector.value = false;
|
showAgentModeSelector.value = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1189,26 +1189,18 @@ const handleSelectAgent = (agent: CustomAgent) => {
|
|||||||
// 根据智能体的 agent_mode 判断是否为 Agent 模式
|
// 根据智能体的 agent_mode 判断是否为 Agent 模式
|
||||||
const isAgentType = agent.config?.agent_mode === 'smart-reasoning';
|
const isAgentType = agent.config?.agent_mode === 'smart-reasoning';
|
||||||
|
|
||||||
// 内置智能体检查 - 从实际的智能体配置来判断
|
// 统一检查智能体是否就绪(内置和自定义智能体使用相同逻辑)
|
||||||
if (agent.is_builtin) {
|
const actualAgent = agent.is_builtin
|
||||||
// 从 agents 列表中获取实际的内置智能体数据,如果没找到则使用传入的 agent (此时应该包含合并后的配置)
|
? (agents.value.find(a => a.id === agent.id) || agent)
|
||||||
const builtinAgent = agents.value.find(a => a.id === agent.id) || agent;
|
: agent;
|
||||||
if (builtinAgent) {
|
|
||||||
const notReadyReasons = getBuiltinAgentNotReadyReasons(builtinAgent, isAgentType);
|
|
||||||
if (notReadyReasons.length > 0) {
|
|
||||||
showBuiltinAgentNotReadyMessage(isAgentType ? 'smart-reasoning' : 'quick-answer', notReadyReasons);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 自定义智能体检查
|
const notReadyReasons = agent.is_builtin
|
||||||
if (!agent.is_builtin) {
|
? getBuiltinAgentNotReadyReasons(actualAgent, isAgentType)
|
||||||
const notReadyReasons = getCustomAgentNotReadyReasons(agent);
|
: getCustomAgentNotReadyReasons(actualAgent);
|
||||||
if (notReadyReasons.length > 0) {
|
|
||||||
showCustomAgentNotReadyMessage(agent, notReadyReasons);
|
if (notReadyReasons.length > 0) {
|
||||||
return;
|
showAgentNotReadyMessage(agent, notReadyReasons);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedAgentId.value = agent.id;
|
selectedAgentId.value = agent.id;
|
||||||
@@ -1363,17 +1355,16 @@ const getCustomAgentNotReadyReasons = (agent: CustomAgent): string[] => {
|
|||||||
return reasons
|
return reasons
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示自定义智能体未就绪的消息
|
// 显示智能体未就绪的消息(统一处理内置和自定义智能体)
|
||||||
const showCustomAgentNotReadyMessage = (agent: CustomAgent, reasons: string[]) => {
|
const showAgentNotReadyMessage = (agent: CustomAgent, reasons: string[]) => {
|
||||||
const reasonsText = reasons.join('、')
|
const reasonsText = reasons.join('、')
|
||||||
|
|
||||||
const messageContent = h('div', { style: 'display: flex; flex-direction: column; gap: 8px; max-width: 320px;' }, [
|
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', {
|
h('a', {
|
||||||
href: '#',
|
href: '#',
|
||||||
onClick: (e: Event) => {
|
onClick: (e: Event) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
// 跳转到智能体编辑页面
|
|
||||||
router.push(`/platform/agents?edit=${agent.id}`);
|
router.push(`/platform/agents?edit=${agent.id}`);
|
||||||
},
|
},
|
||||||
style: 'color: #07C05F; text-decoration: none; font-weight: 500; cursor: pointer; align-self: flex-start;',
|
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 = () => {
|
const toggleWebSearch = () => {
|
||||||
// 互斥:虽然不是弹出层,但操作时关闭其他弹出层体验更好
|
// 互斥:虽然不是弹出层,但操作时关闭其他弹出层体验更好
|
||||||
showMention.value = false;
|
showMention.value = false;
|
||||||
|
|||||||
@@ -961,6 +961,7 @@ export default {
|
|||||||
customAgentMissingSummaryModel: 'Chat Model (Summary Model)',
|
customAgentMissingSummaryModel: 'Chat Model (Summary Model)',
|
||||||
customAgentMissingRerankModel: 'Rerank Model',
|
customAgentMissingRerankModel: 'Rerank Model',
|
||||||
goToAgentEditor: 'Go to configure →',
|
goToAgentEditor: 'Go to configure →',
|
||||||
|
agentNotReadyDetail: 'Agent "{agentName}" is not ready. Please configure: {reasons}',
|
||||||
builtinAgentNotReadyDetail: 'Built-in agent "{agentName}" is not ready. Please configure: {reasons}',
|
builtinAgentNotReadyDetail: 'Built-in agent "{agentName}" is not ready. Please configure: {reasons}',
|
||||||
builtinAgentSettingName: 'Intelligent Reasoning',
|
builtinAgentSettingName: 'Intelligent Reasoning',
|
||||||
builtinNormalSettingName: 'Quick Q&A',
|
builtinNormalSettingName: 'Quick Q&A',
|
||||||
|
|||||||
@@ -1681,6 +1681,7 @@ export default {
|
|||||||
customAgentMissingSummaryModel: "对话模型(Summary Model)",
|
customAgentMissingSummaryModel: "对话模型(Summary Model)",
|
||||||
customAgentMissingRerankModel: "重排模型(Rerank Model)",
|
customAgentMissingRerankModel: "重排模型(Rerank Model)",
|
||||||
goToAgentEditor: "前往配置 →",
|
goToAgentEditor: "前往配置 →",
|
||||||
|
agentNotReadyDetail: "智能体「{agentName}」未就绪,需要配置以下内容:{reasons}",
|
||||||
builtinAgentNotReadyDetail: "内置智能体「{agentName}」未就绪,需要配置以下内容:{reasons}",
|
builtinAgentNotReadyDetail: "内置智能体「{agentName}」未就绪,需要配置以下内容:{reasons}",
|
||||||
builtinAgentSettingName: "智能推理",
|
builtinAgentSettingName: "智能推理",
|
||||||
builtinNormalSettingName: "快速问答",
|
builtinNormalSettingName: "快速问答",
|
||||||
|
|||||||
Reference in New Issue
Block a user