fix(model): hide Ollama tip for remote models

This commit is contained in:
wolfkill
2026-05-14 15:21:11 +08:00
committed by lyingbug
parent a27f12a6cb
commit 5a81441637
3 changed files with 35 additions and 1 deletions
@@ -30,7 +30,10 @@
</div>
<!-- Ollama不可用时的提示信息 -->
<div v-else-if="ollamaServiceStatus === false" class="ollama-unavailable-tip">
<div
v-else-if="shouldShowOllamaUnavailableTip(formData.source, modelType, ollamaServiceStatus)"
class="ollama-unavailable-tip"
>
<t-icon name="error-circle-filled" class="tip-icon" />
<span class="tip-text">{{ $t('model.editor.ollamaUnavailable') }}</span>
<t-button
@@ -334,6 +337,7 @@ import { getWeKnoraCloudStatus } from '@/api/model'
import { useI18n } from 'vue-i18n'
import { useUIStore } from '@/stores/ui'
import SettingDrawer from '@/components/settings/SettingDrawer.vue'
import { shouldShowOllamaUnavailableTip } from '@/components/modelEditorSourceState'
interface CustomHeaderItem {
key: string
@@ -0,0 +1,19 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import { shouldShowOllamaUnavailableTip } from './modelEditorSourceState.ts'
test('hides Ollama unavailable tip while configuring a remote model', () => {
assert.equal(shouldShowOllamaUnavailableTip('remote', 'chat', false), false)
})
test('shows Ollama unavailable tip only for local non-rerank models', () => {
assert.equal(shouldShowOllamaUnavailableTip('local', 'chat', false), true)
assert.equal(shouldShowOllamaUnavailableTip('local', 'embedding', false), true)
assert.equal(shouldShowOllamaUnavailableTip('local', 'rerank', false), false)
})
test('does not show Ollama unavailable tip before status is known or when Ollama is available', () => {
assert.equal(shouldShowOllamaUnavailableTip('local', 'chat', null), false)
assert.equal(shouldShowOllamaUnavailableTip('local', 'chat', true), false)
})
@@ -0,0 +1,11 @@
export type ModelEditorSource = 'local' | 'remote'
export type ModelEditorType = 'chat' | 'embedding' | 'rerank' | 'vllm' | 'asr'
export function shouldShowOllamaUnavailableTip(
source: ModelEditorSource,
modelType: ModelEditorType,
ollamaServiceStatus: boolean | null,
): boolean {
return source === 'local' && modelType !== 'rerank' && ollamaServiceStatus === false
}