diff --git a/src/app/core/setting/ai/modelSelect.tsx b/src/app/core/setting/ai/modelSelect.tsx index 73c7050c..8d889fe8 100644 --- a/src/app/core/setting/ai/modelSelect.tsx +++ b/src/app/core/setting/ai/modelSelect.tsx @@ -15,7 +15,7 @@ import { CommandItem, CommandList, } from "@/components/ui/command"; -import { AiConfig } from "../config"; +import { AiConfig, baseAiConfig } from "../config"; import { Store } from "@tauri-apps/plugin-store"; import emitter from "@/lib/emitter"; @@ -56,7 +56,22 @@ export default function ModelSelect( if (requestId !== currentRequestIdRef.current) return if (!models) return - setList(models) + // 如果API返回空列表,尝试使用静态模型列表作为后备 + if (models.length === 0 && model) { + const baseConfig = baseAiConfig.find(c => c.baseURL === model.baseURL) + if (baseConfig?.staticModels?.length) { + setList(baseConfig.staticModels.map(id => ({ + id, + object: 'model' as const, + created: 0, + owned_by: baseConfig.key, + }))) + } else { + setList(models) + } + } else { + setList(models) + } // 如果没有传入aiConfig,则从store中设置model值 if (!aiConfig && setModel) { diff --git a/src/app/core/setting/ai/page.tsx b/src/app/core/setting/ai/page.tsx index 2ceccd71..108444ab 100644 --- a/src/app/core/setting/ai/page.tsx +++ b/src/app/core/setting/ai/page.tsx @@ -47,6 +47,11 @@ export default function AiPage() { // 当前选中的AI配置 const currentConfig = userCustomModels.find(model => model.key === selectedAiConfig) + + const getConfigDisplayTitle = (config?: AiConfig) => { + if (!config) return t('selectConfig') + return baseAiConfig.find(item => item.baseURL === config.baseURL)?.title || config.title + } const parseHeadersToKeyValue = (headers: Record = {}) => { return Object.entries(headers).map(([key, value]) => ({ @@ -282,13 +287,13 @@ export default function AiPage() {