diff --git a/electron/main/ai/llm/index.ts b/electron/main/ai/llm/index.ts index 4ac3a2df..6c8a1775 100644 --- a/electron/main/ai/llm/index.ts +++ b/electron/main/ai/llm/index.ts @@ -58,11 +58,13 @@ export function getProviderDefinitionById(id: string): ProviderDefinition | null return getBuiltinProviderById(id) || loadCustomProviders().find((p) => p.id === id) || null } -/** 按 providerId + modelId 查找模型定义(内置优先,再查自定义) */ +/** 按 providerId + modelId 查找模型定义(内置优先,再查自定义,最后跨 provider 兜底) */ export function findModelDefinition(providerId: string, modelId: string): ModelDefinition | null { return ( getBuiltinModelById(providerId, modelId) || loadCustomModels().find((m) => m.providerId === providerId && m.id === modelId) || + BUILTIN_MODELS.find((m) => m.id === modelId) || + loadCustomModels().find((m) => m.id === modelId) || null ) } diff --git a/src/components/AIChat/chat/ChatStatusBar.vue b/src/components/AIChat/chat/ChatStatusBar.vue index 48df38df..70b1f251 100644 --- a/src/components/AIChat/chat/ChatStatusBar.vue +++ b/src/components/AIChat/chat/ChatStatusBar.vue @@ -85,7 +85,9 @@ const contextTokens = computed(() => { const modelContextWindow = computed(() => { if (!activeConfig.value) return 128000 - const model = llmStore.getModelById(activeConfig.value.provider, activeConfig.value.model) + const model = + llmStore.getModelById(activeConfig.value.provider, activeConfig.value.model) || + llmStore.findModelAcrossProviders(activeConfig.value.model) return model?.contextWindow ?? 128000 }) diff --git a/src/components/common/Settings/AI/AIModelEditModal.vue b/src/components/common/Settings/AI/AIModelEditModal.vue index 11c7b9c1..8a265d54 100644 --- a/src/components/common/Settings/AI/AIModelEditModal.vue +++ b/src/components/common/Settings/AI/AIModelEditModal.vue @@ -58,6 +58,7 @@ const { canFetchModels, showEditModelDialog, editModelContextWindow, + editModelName, selectProvider, onConnectionModeChange, openAddModelDialog, @@ -225,6 +226,13 @@ function closeModal() { }}

+

+ + {{ t('settings.aiConfig.modal.contextWindowMissing') }} +

+
+ + +