From ce429dbf67fb31cecaf58568ad7250dc217ae174 Mon Sep 17 00:00:00 2001 From: ssongliu Date: Tue, 3 Nov 2026 00:00:49 +0800 Subject: [PATCH] fix(ai): refine model service forms and Ollama drawers --- agent/app/provider/catalog.go | 2 +- .../model/components/account-form/index.vue | 143 +++++++++++------- .../src/views/ai/model/ollama/add/index.vue | 4 +- .../views/ai/model/ollama/models/index.vue | 10 +- .../views/ai/model/ollama/terminal/index.vue | 12 +- 5 files changed, 104 insertions(+), 67 deletions(-) diff --git a/agent/app/provider/catalog.go b/agent/app/provider/catalog.go index 86df61798..b8d6453ab 100644 --- a/agent/app/provider/catalog.go +++ b/agent/app/provider/catalog.go @@ -48,7 +48,7 @@ var catalog = map[string]Meta{ }, // llmman (https://github.com/llmmanorg/llmman): local runner with Ollama/OpenAI-compatible routes on 127.0.0.1:17434. "llmman": { - Key: "llmman", DisplayName: "llmman", Sort: 16, DefaultAPIType: "openai-responses", + Key: "llmman", DisplayName: "llmman", Sort: 75, DefaultAPIType: "openai-responses", APIConfigs: []APIConfig{ {APIType: "openai-responses", BaseURL: "http://127.0.0.1:17434/v1", EditableBaseURL: true}, {APIType: "openai-completions", BaseURL: "http://127.0.0.1:17434/v1", EditableBaseURL: true}, diff --git a/frontend/src/views/ai/model/components/account-form/index.vue b/frontend/src/views/ai/model/components/account-form/index.vue index 72af70abe..b7086dc32 100644 --- a/frontend/src/views/ai/model/components/account-form/index.vue +++ b/frontend/src/views/ai/model/components/account-form/index.vue @@ -42,7 +42,31 @@ :loading="loadingEngines" @change="handleLocalEngineChange" > - + +
+ {{ item.name }} + + {{ item.models[0] }} + + + +
+ + {{ model }} + +
+
+
+
- + - - - - {{ $t('commons.button.add') }} - - - + {{ $t('commons.button.add') }} + @@ -330,8 +347,6 @@ const { isIntl, isProductPro } = useGlobalStore(); const connectionMode = ref<'manual' | 'local'>('manual'); const loadingEngines = ref(false); const enginesLoadFailed = ref(false); -const loadingLocalModels = ref(false); -const localModelsLoadFailed = ref(false); const localEngines = ref>([]); const form = reactive({ @@ -366,10 +381,7 @@ const localModelOptions = computed(() => const disabled = computed( () => connectionMode.value === 'local' && - (loadingEngines.value || - loadingLocalModels.value || - localModelsLoadFailed.value || - !localEngines.value.some((item) => item.id === form.localEngineId)), + (loadingEngines.value || !localEngines.value.some((item) => item.id === form.localEngineId)), ); const selectedAPIConfig = computed(() => selectedProvider.value?.apiTypes.find((item) => item.apiType === form.apiType), @@ -858,12 +870,14 @@ watch([open, () => form.provider, connectionMode], async ([visible, provider, mo const { data: item } = await checkAppInstalled('ollama', ''); if (cancelled) return; if (item.isExist) { + const models = await readPages((page) => searchOllamaModel(page)); + if (cancelled) return; engines = [ { id: item.appInstallId, name: item.name, baseURL: item.modelAccountBaseURL || `http://${item.containerName}:11434/v1`, - models: [], + models: models.filter((model) => model.status === 'Success').map((model) => model.name), }, ]; } @@ -876,31 +890,6 @@ watch([open, () => form.provider, connectionMode], async ([visible, provider, mo } }); -watch( - [open, () => form.provider, connectionMode, () => form.localEngineId], - async ([visible, provider, mode, engineId], _, onCleanup) => { - let cancelled = false; - onCleanup(() => (cancelled = true)); - loadingLocalModels.value = false; - localModelsLoadFailed.value = false; - if (!visible || provider !== 'ollama' || mode !== 'local') return; - const engine = localEngines.value.find((item) => item.id === engineId); - if (!engine) return; - loadingLocalModels.value = true; - try { - const models = await readPages((page) => searchOllamaModel(page)); - if (cancelled) return; - engine.models = models.filter((model) => model.status === 'Success').map((model) => model.name); - resetManualModels(); - } catch { - if (!cancelled) localModelsLoadFailed.value = true; - } finally { - if (!cancelled) loadingLocalModels.value = false; - } - }, - { flush: 'sync' }, -); - const handleAPITypeChange = () => { const config = selectedAPIConfig.value; if (!config) { @@ -951,6 +940,50 @@ defineExpose({ } } +.local-engine-option { + display: flex; + align-items: center; + gap: 8px; + min-width: 0; + + &__name { + flex: 1; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + } + + &__model { + max-width: 55%; + min-width: 0; + + :deep(.el-tag__content) { + overflow: hidden; + text-overflow: ellipsis; + } + } + + &__more { + flex-shrink: 0; + } +} + +.local-engine-models { + display: flex; + flex-wrap: wrap; + gap: 6px; + max-height: 240px; + overflow: auto; + + .el-tag { + height: auto; + padding: 4px 6px; + white-space: normal; + overflow-wrap: anywhere; + max-width: 100%; + } +} + .base-url-warning { margin-top: 8px; } diff --git a/frontend/src/views/ai/model/ollama/add/index.vue b/frontend/src/views/ai/model/ollama/add/index.vue index c2e0b57e4..fa8e2290c 100644 --- a/frontend/src/views/ai/model/ollama/add/index.vue +++ b/frontend/src/views/ai/model/ollama/add/index.vue @@ -1,5 +1,5 @@