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
fix(chat): improve model selection handling in chat component
wizardchen4f7893950fa1
diff --git a/frontend/src/components/Input-field.vue b/frontend/src/components/Input-field.vueindex ca31f8a80..8d6dfb55c 100644--- a/frontend/src/components/Input-field.vue+++ b/frontend/src/components/Input-field.vue@@ -805,15 +805,29 @@ const ensureModelSelection = () => {};// 智能体身份或其数据到位时,把对话模型同步到智能体配置的 model_id。-// 修复场景:导航离开再返回时,onMounted 中的 initChatModelSelection 会用-// localStorage 的 lastPick(用户上一次手动挑选)覆盖 store 中的 selectedChatModelId,-// 把共享智能体绑定的源租户 model_id 冲掉,UI 显示「未配置」。-// 该 watch 在 loadAgents/sharedAgents 异步返回让 agentModelId 由空变非空时也会触发,-// 与 handleSelectAgent 中的同步逻辑保持一致:智能体「拥有」其模型选择。+// 修复场景:导航离开再返回时,initChatModelSelection 会用 localStorage 的 lastPick+// 覆盖共享智能体绑定的源租户 model_id,UI 显示「未配置」——此时需要拉回 agent 模型。+// 但若用户在本页手动改过模型(lastPick 与 agent 默认不同且当前选中即为 lastPick),+// 则保留用户选择,避免 creatChat → chat 跳转后把模型 B 冲回智能体默认 A。watch([selectedAgentId, () => settingsStore.selectedAgentSourceTenantId, agentModelId],- ([, , newModelId]) => {- if (newModelId && newModelId.trim() !== '' && newModelId !== selectedModelId.value) {+ ([, sourceTenantId, newModelId]) => {+ if (!newModelId || newModelId.trim() === '') return;++ const lastPick = readLastChatModelID();+ const isSharedAgent = !!sourceTenantId;+ const agentModelInList = availableModels.value.some(m => m.id === newModelId);++ if (+ lastPick &&+ selectedModelId.value === lastPick &&+ lastPick !== newModelId &&+ (!isSharedAgent || agentModelInList)+ ) {+ return;+ }++ if (newModelId !== selectedModelId.value) {selectedModelId.value = newModelId;}},diff --git a/frontend/src/views/chat/index.vue b/frontend/src/views/chat/index.vueindex 5118b309c..cb902d319 100644--- a/frontend/src/views/chat/index.vue+++ b/frontend/src/views/chat/index.vue@@ -1407,7 +1407,14 @@ onMounted(async () => {if (firstQuery.value) {scrollLock.value = true;historyLoading.value = false;- sendMsg(firstQuery.value, firstModelId.value || '', firstMentionedItems.value || [], firstImageFiles.value || [], firstAttachmentFiles.value || []);+ if (firstModelId.value) {+ useSettingsStoreInstance.updateConversationModels({+ summaryModelId: firstModelId.value,+ selectedChatModelId: firstModelId.value,+ rerankModelId: '',+ });+ }+ sendMsg(firstQuery.value, firstModelId.value || '', firstMentionedItems.value || [], firstImageFiles.value || [], firstAttachmentFiles.value || []);usemenuStore.changeFirstQuery('', [], '', [], []);} else {scrollLock.value = false;