fix(model): hide Ollama tip for remote models
This commit is contained in:
@@ -30,7 +30,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Ollama不可用时的提示信息 -->
|
<!-- 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" />
|
<t-icon name="error-circle-filled" class="tip-icon" />
|
||||||
<span class="tip-text">{{ $t('model.editor.ollamaUnavailable') }}</span>
|
<span class="tip-text">{{ $t('model.editor.ollamaUnavailable') }}</span>
|
||||||
<t-button
|
<t-button
|
||||||
@@ -334,6 +337,7 @@ import { getWeKnoraCloudStatus } from '@/api/model'
|
|||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { useUIStore } from '@/stores/ui'
|
import { useUIStore } from '@/stores/ui'
|
||||||
import SettingDrawer from '@/components/settings/SettingDrawer.vue'
|
import SettingDrawer from '@/components/settings/SettingDrawer.vue'
|
||||||
|
import { shouldShowOllamaUnavailableTip } from '@/components/modelEditorSourceState'
|
||||||
|
|
||||||
interface CustomHeaderItem {
|
interface CustomHeaderItem {
|
||||||
key: string
|
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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user