Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

feat(model-editor): enhance model type selection and localization support

wizardchenaf08a65821bb
diff --git a/frontend/src/components/ModelEditorDialog.vue b/frontend/src/components/ModelEditorDialog.vue
index 5e97d3eef..8ae7d1d8c 100644
--- a/frontend/src/components/ModelEditorDialog.vue
+++ b/frontend/src/components/ModelEditorDialog.vue
@@ -29,6 +29,25 @@
<t-form ref="formRef" :data="formData" :rules="rules" layout="vertical">
+ <section v-if="!isEdit" class="setting-drawer__section">
+ <h4 class="setting-drawer__section-title">{{ $t('model.editor.sectionType') }}</h4>
+ <div class="model-type-options" role="radiogroup" :aria-label="$t('model.editor.typeLabel')">
+ <button
+ v-for="opt in modelTypeChoices"
+ :key="opt.value"
+ type="button"
+ class="model-type-option"
+ :class="{ 'is-active': activeModelType === opt.value }"
+ role="radio"
+ :aria-checked="activeModelType === opt.value"
+ @click="selectModelType(opt.value)"
+ >
+ <t-icon :name="opt.icon" class="model-type-option__icon" />
+ <span class="model-type-option__label">{{ opt.label }}</span>
+ </button>
+ </div>
+ </section>
+
<!--
Section 1 — 模型来源 + 模型名称(来源直接决定下方字段,所以放一节)
-->
@@ -44,36 +63,36 @@
<button
type="button"
class="source-option"
- :class="{ 'is-active': formData.source === 'local', 'is-disabled': ollamaServiceStatus === false || modelType === 'rerank' }"
- :disabled="ollamaServiceStatus === false || modelType === 'rerank'"
+ :class="{ 'is-active': formData.source === 'remote' }"
role="radio"
- :aria-checked="formData.source === 'local'"
- @click="formData.source = 'local'"
+ :aria-checked="formData.source === 'remote'"
+ @click="formData.source = 'remote'"
>
- <t-icon name="server" class="source-option__icon" />
- <span class="source-option__label">{{ $t('model.editor.sourceLocal') }}</span>
+ <t-icon name="cloud" class="source-option__icon" />
+ <span class="source-option__label">{{ $t('model.editor.sourceRemote') }}</span>
</button>
<button
type="button"
class="source-option"
- :class="{ 'is-active': formData.source === 'remote' }"
+ :class="{ 'is-active': formData.source === 'local', 'is-disabled': ollamaServiceStatus === false || activeModelType === 'rerank' }"
+ :disabled="ollamaServiceStatus === false || activeModelType === 'rerank'"
role="radio"
- :aria-checked="formData.source === 'remote'"
- @click="formData.source = 'remote'"
+ :aria-checked="formData.source === 'local'"
+ @click="formData.source = 'local'"
>
- <t-icon name="cloud" class="source-option__icon" />
- <span class="source-option__label">{{ $t('model.editor.sourceRemote') }}</span>
+ <t-icon name="server" class="source-option__icon" />
+ <span class="source-option__label">{{ $t('model.editor.sourceLocal') }}</span>
</button>
</div>
<!-- ReRank模型不支持Ollama的提示信息 -->
- <div v-if="modelType === 'rerank'" class="ollama-unavailable-tip rerank-tip">
+ <div v-if="activeModelType === 'rerank'" class="ollama-unavailable-tip rerank-tip">
<t-icon name="info-circle-filled" class="tip-icon info" />
<span class="tip-text">{{ $t('model.editor.ollamaNotSupportRerank') }}</span>
</div>
<!-- Ollama不可用时的提示信息 -->
- <div v-else-if="shouldShowOllamaUnavailableTip(formData.source, modelType, ollamaServiceStatus)"
+ <div v-else-if="shouldShowOllamaUnavailableTip(formData.source, activeModelType, ollamaServiceStatus)"
class="ollama-unavailable-tip">
<t-icon name="error-circle-filled" class="tip-icon" />
<span class="tip-text">{{ $t('model.editor.ollamaUnavailable') }}</span>
@@ -294,11 +313,11 @@
</template>
<!-- Section 3 — 高级选项(仅在有内容时渲染,避免空 section 出现底部分隔线) -->
- <section v-if="modelType === 'embedding' || modelType === 'chat'" class="setting-drawer__section">
+ <section v-if="activeModelType === 'embedding' || activeModelType === 'chat'" class="setting-drawer__section">
<h4 class="setting-drawer__section-title">{{ $t('model.editor.sectionAdvanced') }}</h4>
<!-- Embedding 专用:维度 -->
- <div v-if="modelType === 'embedding'" class="form-item">
+ <div v-if="activeModelType === 'embedding'" class="form-item">
<label class="form-label">{{ $t('model.editor.dimensionLabel') }}</label>
<div class="dimension-control">
<t-input v-model.number="formData.dimension" type="number" :min="128" :max="4096"
@@ -317,7 +336,7 @@
</div>
<!-- Chat: supports vision toggle (VLLM models are inherently multimodal) -->
- <div v-if="modelType === 'chat'" class="form-item">
+ <div v-if="activeModelType === 'chat'" class="form-item">
<label class="form-label">{{ $t('model.editor.supportsVisionLabel') }}</label>
<div class="vision-toggle">
<t-switch v-model="formData.supportsVision" />
@@ -407,9 +426,11 @@ interface ModelFormData {
lkeapRegion?: string
}
+type EditorModelType = 'chat' | 'embedding' | 'rerank' | 'vllm' | 'asr'
+
interface Props {
visible: boolean
- modelType: 'chat' | 'embedding' | 'rerank' | 'vllm' | 'asr'
+ modelType: EditorModelType
modelData?: ModelFormData | null
}
@@ -423,9 +444,25 @@ const props = withDefaults(defineProps<Props>(), {
const emit = defineEmits<{
'update:visible': [value: boolean]
- 'confirm': [data: ModelFormData]
+ 'confirm': [data: ModelFormData & { modelType?: EditorModelType }]
}>()
+const draftModelType = ref<EditorModelType>(props.modelType)
+
+const isEdit = computed(() => !!props.modelData)
+
+const activeModelType = computed(() => (
+ isEdit.value ? props.modelType : draftModelType.value
+))
+
+const modelTypeChoices = computed(() => ([
+ { value: 'chat' as const, label: t('modelSettings.typeShort.chat'), icon: 'chat' },
+ { value: 'embedding' as const, label: t('modelSettings.typeShort.embedding'), icon: 'chart-bubble' },
+ { value: 'rerank' as const, label: t('modelSettings.typeShort.rerank'), icon: 'filter-sort' },
+ { value: 'vllm' as const, label: t('modelSettings.typeShort.vllm'), icon: 'image' },
+ { value: 'asr' as const, label: t('modelSettings.typeShort.asr'), icon: 'sound' },
+]))
+
// API 返回的 Provider 列表
const apiProviderOptions = ref<ModelProviderOption[]>([])
const loadingProviders = ref(false)
@@ -557,7 +594,7 @@ const fallbackProviderOptions = computed(() => [
const loadProviders = async () => {
loadingProviders.value = true
try {
- const providers = await listModelProviders(props.modelType)
+ const providers = await listModelProviders(activeModelType.value)
if (providers.length > 0) {
apiProviderOptions.value = providers
}
@@ -585,7 +622,7 @@ const providerOptions = computed(() => {
}
// 回退到硬编码值,按 modelTypes 过滤
return fallbackProviderOptions.value.filter(p =>
- p.modelTypes.includes(props.modelType)
+ p.modelTypes.includes(activeModelType.value)
)
})
@@ -594,10 +631,8 @@ const dialogVisible = computed({
set: (val) => emit('update:visible', val)
})
-const isEdit = computed(() => !!props.modelData)
-
const showThinkingControlField = computed(() =>
- props.modelType === 'chat' && formData.value.source === 'remote',
+ activeModelType.value === 'chat' && formData.value.source === 'remote',
)
const resolvedThinkingControl = (): ThinkingControlValue =>
@@ -622,7 +657,7 @@ const syncThinkingControlToForm = (force = false) => {
}
const applyThinkingControlFromModelData = () => {
- if (!props.modelData || props.modelType !== 'chat' || formData.value.source !== 'remote') return
+ if (!props.modelData || activeModelType.value !== 'chat' || formData.value.source !== 'remote') return
thinkingControlManual.value = !!props.modelData.thinkingControl
formData.value.thinkingControl = resolveThinkingControl(
props.modelData.thinkingControl,
@@ -652,11 +687,11 @@ const modelTypeIcon = computed(() => {
vllm: 'image',
asr: 'sound',
}
- return map[props.modelType] || 'setting'
+ return map[activeModelType.value] || 'setting'
})
const isLkeapRerank = computed(
- () => props.modelType === 'rerank' && formData.value.provider === 'lkeap',
+ () => activeModelType.value === 'rerank' && formData.value.provider === 'lkeap',
)
// Credential resource binding for the shared <CredentialResource> component.
@@ -764,8 +799,8 @@ const goToWeKnoraCloudSettings = async () => {
const formData = ref<ModelFormData>({
id: '',
name: '',
- source: 'local',
- provider: 'openai',
+ source: 'remote',
+ provider: 'generic',
modelName: '',
displayName: '',
baseUrl: '',
@@ -822,18 +857,18 @@ const rules = computed(() => ({
// 获取弹窗描述文字
const getModalDescription = () => {
- const key = `model.editor.description.${props.modelType}` as const
+ const key = `model.editor.description.${activeModelType.value}` as const
return t(key) || t('model.editor.description.default')
}
// 获取模型名称占位符
const getModelNamePlaceholder = () => {
- if (props.modelType === 'vllm') {
+ if (activeModelType.value === 'vllm') {
return formData.value.source === 'local'
? t('model.editor.modelNamePlaceholder.localVllm')
: t('model.editor.modelNamePlaceholder.remoteVllm')
}
- if (props.modelType === 'asr') {
+ if (activeModelType.value === 'asr') {
return t('model.editor.modelNamePlaceholder.remoteAsr')
}
return formData.value.source === 'local'
@@ -842,10 +877,10 @@ const getModelNamePlaceholder = () => {
}
const getBaseUrlPlaceholder = () => {
- if (props.modelType === 'vllm') {
+ if (activeModelType.value === 'vllm') {
return t('model.editor.baseUrlPlaceholderVllm')
}
- if (props.modelType === 'asr') {
+ if (activeModelType.value === 'asr') {
return t('model.editor.baseUrlPlaceholderAsr')
}
return t('model.editor.baseUrlPlaceholder')
@@ -894,6 +929,41 @@ const goToOllamaSettings = async () => {
// 上一次打开时的 modelData id:用来判断切换模型/新增 vs. 同一次新增的连续打开
const lastOpenedModelId = ref<string | null>(null)
+const selectModelType = async (type: EditorModelType) => {
+ if (isEdit.value || draftModelType.value === type) return
+ draftModelType.value = type
+
+ if (type === 'rerank') {
+ formData.value.source = 'remote'
+ }
+ if (type !== 'embedding') {
+ formData.value.dimension = undefined
+ dimensionChecked.value = false
+ dimensionSuccess.value = false
+ dimensionMessage.value = ''
+ }
+ if (type !== 'chat') {
+ formData.value.supportsVision = false
+ thinkingControlManual.value = false
+ }
+ remoteChecked.value = false
+ remoteAvailable.value = false
+ remoteMessage.value = ''
+
+ await loadProviders()
+ const supported = providerOptions.value.some(p => p.value === formData.value.provider)
+ if (!supported) {
+ formData.value.provider = 'generic'
+ formData.value.baseUrl = ''
+ } else {
+ handleProviderChange(formData.value.provider)
+ }
+ if (showThinkingControlField.value && !isEdit.value) {
+ thinkingControlManual.value = false
+ syncThinkingControlToForm(true)
+ }
+}
+
// 监听 visible 变化,初始化表单
watch(() => props.visible, (val) => {
if (val) {
@@ -915,6 +985,7 @@ watch(() => props.visible, (val) => {
dimensionMessage.value = ''
const currentId = props.modelData?.id ?? null
+ draftModelType.value = props.modelType
hydratingForm.value = true
try {
@@ -939,7 +1010,7 @@ watch(() => props.visible, (val) => {
lastOpenedModelId.value = currentId
// ReRank 模型强制使用 remote 来源(Ollama 不支持 ReRank)
- if (props.modelType === 'rerank') {
+ if (activeModelType.value === 'rerank') {
formData.value.source = 'remote'
}
@@ -966,7 +1037,7 @@ const resetForm = () => {
formData.value = {
id: generateId(),
name: '', // 保留字段但不使用,保存时用 modelName
- source: 'local',
+ source: 'remote',
provider: 'generic',
modelName: '',
displayName: '',
@@ -997,11 +1068,11 @@ const handleProviderChange = (value: string) => {
const provider = providerOptions.value.find(opt => opt.value === value)
if (provider && provider.defaultUrls) {
// 根据当前模型类型获取对应的默认 URL
- const defaultUrl = provider.defaultUrls[props.modelType]
+ const defaultUrl = provider.defaultUrls[activeModelType.value]
if (defaultUrl) {
formData.value.baseUrl = defaultUrl
}
- if (value === 'lkeap' && props.modelType === 'rerank' && !formData.value.modelName?.trim()) {
+ if (value === 'lkeap' && activeModelType.value === 'rerank' && !formData.value.modelName?.trim()) {
formData.value.modelName = 'lke-reranker-base'
}
// 重置校验状态
@@ -1014,7 +1085,7 @@ const handleProviderChange = (value: string) => {
checkWkcCredentialStatus()
}
if (hydratingForm.value) return
- if (props.modelType !== 'chat' || formData.value.source !== 'remote') return
+ if (activeModelType.value !== 'chat' || formData.value.source !== 'remote') return
if (!isEdit.value) {
thinkingControlManual.value = false
syncThinkingControlToForm(true)
@@ -1029,7 +1100,7 @@ watch(
() => [formData.value.source, formData.value.provider, formData.value.modelName] as const,
([source, provider, modelName], [prevSource, prevProvider, prevModelName]) => {
if (hydratingForm.value || isEdit.value) return
- if (props.modelType !== 'chat' || source !== 'remote') return
+ if (activeModelType.value !== 'chat' || source !== 'remote') return
if (source === prevSource && provider === prevProvider && modelName === prevModelName) return
const providerChanged = provider !== prevProvider
@@ -1152,7 +1223,7 @@ const checkModelStatus = async () => {
// 检查 Ollama 本地 Embedding 模型维度
const checkOllamaDimension = async () => {
- if (!formData.value.modelName || formData.value.source !== 'local' || props.modelType !== 'embedding') {
+ if (!formData.value.modelName || formData.value.source !== 'local' || activeModelType.value !== 'embedding') {
return
}
@@ -1230,7 +1301,7 @@ const checkRemoteAPI = async () => {
? { modelId: props.modelData.id as string }
: {}
- switch (props.modelType) {
+ switch (activeModelType.value) {
case 'chat':
// 对话模型(KnowledgeQA)
result = await checkRemoteModel({
@@ -1388,7 +1459,10 @@ const handleConfirm = async () => {
formData.value.id = generateId()
}
- emit('confirm', { ...formData.value })
+ emit('confirm', {
+ ...formData.value,
+ ...(isEdit.value ? {} : { modelType: activeModelType.value }),
+ })
dialogVisible.value = false
// 保存成功后重置草稿,下次打开新增模型时是空白
resetForm()
@@ -1419,7 +1493,7 @@ watch(() => formData.value.modelName, async (newValue, oldValue) => {
}
// 如果是 embedding 模型且选择的是 Ollama 本地模型,且模型名称发生了实际变化
- if (props.modelType === 'embedding' &&
+ if (activeModelType.value === 'embedding' &&
formData.value.source === 'local' &&
newValue !== oldValue &&
oldValue !== '') {
@@ -1521,7 +1595,7 @@ watch(() => formData.value.source, () => {
!hydratingForm.value
&& !isEdit.value
&& formData.value.source === 'remote'
- && props.modelType === 'chat'
+ && activeModelType.value === 'chat'
) {
thinkingControlManual.value = false
syncThinkingControlToForm(true)
@@ -1578,6 +1652,54 @@ const handleCancel = () => {
}
}
+.model-type-options {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 8px;
+}
+
+.model-type-option {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ padding: 6px 12px;
+ min-height: 32px;
+ border: 1px solid var(--td-component-stroke);
+ border-radius: 8px;
+ background: var(--td-bg-color-container);
+ color: var(--td-text-color-secondary);
+ font-size: 13px;
+ line-height: 1.4;
+ cursor: pointer;
+ transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
+
+ &__icon {
+ font-size: 15px;
+ flex-shrink: 0;
+ }
+
+ &__label {
+ white-space: nowrap;
+ }
+
+ &:hover:not(.is-active) {
+ border-color: var(--td-brand-color-3, var(--td-brand-color));
+ color: var(--td-text-color-primary);
+ }
+
+ &.is-active {
+ border-color: var(--td-brand-color);
+ background: color-mix(in srgb, var(--td-brand-color) 10%, transparent);
+ color: var(--td-brand-color);
+ font-weight: 500;
+ }
+
+ &:focus-visible {
+ outline: 2px solid var(--td-brand-color);
+ outline-offset: 2px;
+ }
+}
+
// 模型来源分段:紧凑单行 pill 形 segmented。容器自身是浅底圆角条,
// 选中按钮通过实色背景 + 主题色描边浮出,未选中态接近透明,节省纵向空间。
.source-options {
diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts
index b4f5f2c89..cb533b133 100755
--- a/frontend/src/i18n/locales/en-US.ts
+++ b/frontend/src/i18n/locales/en-US.ts
@@ -3378,6 +3378,8 @@ export default {
editor: {
addTitle: 'Add Model',
editTitle: 'Edit Model',
+ sectionType: 'Model Type',
+ typeLabel: 'Model Type',
sectionSource: 'Source',
sectionProvider: 'Provider Settings',
sectionAdvanced: 'Advanced Options',
diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts
index 97d76c031..f6868164f 100755
--- a/frontend/src/i18n/locales/ko-KR.ts
+++ b/frontend/src/i18n/locales/ko-KR.ts
@@ -2605,6 +2605,8 @@ export default {
editor: {
addTitle: "모델 추가",
editTitle: "모델 편집",
+ sectionType: "모델 유형",
+ typeLabel: "모델 유형",
sectionSource: "모델 소스",
sectionProvider: "연결 설정",
sectionAdvanced: "고급 옵션",
diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts
index a781cafaf..49bba6509 100755
--- a/frontend/src/i18n/locales/ru-RU.ts
+++ b/frontend/src/i18n/locales/ru-RU.ts
@@ -2322,6 +2322,8 @@ export default {
editor: {
addTitle: 'Добавить модель',
editTitle: 'Редактировать модель',
+ sectionType: 'Тип модели',
+ typeLabel: 'Тип модели',
sectionSource: 'Источник',
sectionProvider: 'Настройки провайдера',
sectionAdvanced: 'Дополнительные параметры',
diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts
index 7dcf0660b..7432fc5b3 100755
--- a/frontend/src/i18n/locales/zh-CN.ts
+++ b/frontend/src/i18n/locales/zh-CN.ts
@@ -2595,6 +2595,8 @@ export default {
editor: {
addTitle: "添加模型",
editTitle: "编辑模型",
+ sectionType: "模型类型",
+ typeLabel: "模型类型",
sectionSource: "模型来源",
sectionProvider: "接入配置",
sectionAdvanced: "高级选项",
diff --git a/frontend/src/views/settings/ModelSettings.vue b/frontend/src/views/settings/ModelSettings.vue
index cbf1f6393..024390401 100644
--- a/frontend/src/views/settings/ModelSettings.vue
+++ b/frontend/src/views/settings/ModelSettings.vue
@@ -1,19 +1,8 @@
<template>
<div class="model-settings">
<div class="section-header">
- <div class="section-header__top" data-guide="settings-models">
- <div class="section-header__text">
- <h2>{{ $t('modelSettings.title') }}</h2>
- <p class="section-description">{{ $t('modelSettings.description') }}</p>
- </div>
- <t-dropdown v-if="authStore.hasRole('admin')" :options="addModelOptions" placement="bottom-right"
- @click="(data: any) => openAddDialog(data.value)">
- <t-button theme="primary" variant="outline" size="small" data-guide="settings-add-model">
- <template #icon><add-icon /></template>
- {{ $t('modelSettings.actions.addModel') }}
- </t-button>
- </t-dropdown>
- </div>
+ <h2>{{ $t('modelSettings.title') }}</h2>
+ <p class="section-description">{{ $t('modelSettings.description') }}</p>
<div class="builtin-models-hint" role="note">
<p class="builtin-hint-label">{{ $t('modelSettings.builtinModels.title') }}</p>
@@ -26,7 +15,7 @@
</div>
</div>
- <t-tabs v-model="activeTypeFilter" class="model-type-tabs">
+ <t-tabs v-model="activeTypeFilter" class="model-type-tabs" data-guide="settings-models">
<t-tab-panel value="all" :label="`${$t('common.all')}(${allLegacyModels.length})`" />
<t-tab-panel value="chat" :label="`${$t('modelSettings.typeShort.chat')}(${countByType('chat')})`" />
<t-tab-panel value="embedding"
@@ -104,16 +93,26 @@
</p>
</div>
</div>
+ <button
+ v-if="authStore.hasRole('admin')"
+ type="button"
+ class="model-card model-card--add"
+ data-guide="settings-add-model"
+ @click="openAddDialog"
+ >
+ <span class="model-card--add__icon" aria-hidden="true">
+ <add-icon />
+ </span>
+ <span class="model-card--add__label">{{ $t('modelSettings.actions.addModel') }}</span>
+ </button>
</div>
<div v-else-if="!loading" class="empty-state">
<t-empty :description="emptyHint">
- <t-dropdown v-if="authStore.hasRole('admin')" :options="addModelOptions" placement="bottom"
- @click="(data: any) => openAddDialog(data.value)">
- <t-button theme="primary" variant="outline" size="small">
- <template #icon><add-icon /></template>
- {{ $t('modelSettings.actions.addModel') }}
- </t-button>
- </t-dropdown>
+ <t-button v-if="authStore.hasRole('admin')" theme="primary" variant="outline" size="small"
+ data-guide="settings-add-model" @click="openAddDialog">
+ <template #icon><add-icon /></template>
+ {{ $t('modelSettings.actions.addModel') }}
+ </t-button>
</t-empty>
</div>
</t-loading>
@@ -197,15 +196,6 @@ const filteredModels = computed(() => {
const countByType = (type: ModelType) => allLegacyModels.value.filter(m => m._modelType === type).length
-// "+新增模型" 下拉菜单
-const addModelOptions = computed(() => ([
- { content: t('modelSettings.typeShort.chat'), value: 'chat' },
- { content: t('modelSettings.typeShort.embedding'), value: 'embedding' },
- { content: t('modelSettings.typeShort.rerank'), value: 'rerank' },
- { content: t('modelSettings.typeShort.vllm'), value: 'vllm' },
- { content: t('modelSettings.typeShort.asr'), value: 'asr' }
-]))
-
// 类型徽章图标。沿用 TDesign 自带 icon name,避免再引第三方图标包。
const typeIcon = (type: ModelType): string => {
const map: Record<ModelType, string> = {
@@ -298,9 +288,9 @@ const loadModels = async () => {
}
}
-// 打开添加对话框
-const openAddDialog = (type: ModelType) => {
- currentModelType.value = type
+// 打开添加对话框;类型在抽屉内选择,此处仅按当前 Tab 预填默认值
+const openAddDialog = () => {
+ currentModelType.value = activeTypeFilter.value === 'all' ? 'chat' : activeTypeFilter.value
editingModel.value = null
showDialog.value = true
}
@@ -340,6 +330,9 @@ const editModel = (type: ModelType, model: any) => {
// 保存模型
const handleModelSave = async (modelData: any) => {
+ const saveType: ModelType = modelData.modelType ?? currentModelType.value
+ currentModelType.value = saveType
+
try {
if (!modelData.modelName || !modelData.modelName.trim()) {
MessagePlugin.warning(t('modelSettings.toasts.nameRequired'))
@@ -370,7 +363,7 @@ const handleModelSave = async (modelData: any) => {
}
}
- if (currentModelType.value === 'embedding') {
+ if (saveType === 'embedding') {
if (!modelData.dimension || modelData.dimension < 128 || modelData.dimension > 4096) {
MessagePlugin.warning(t('modelSettings.toasts.dimensionInvalid'))
return
@@ -398,11 +391,11 @@ const handleModelSave = async (modelData: any) => {
const appSecretFields: { app_secret?: string } =
!editingModel.value && trimmedAppSecret ? { app_secret: trimmedAppSecret } : {}
const extraConfig: Record<string, string> = {}
- if (modelData.provider === 'lkeap' && currentModelType.value === 'rerank') {
+ if (modelData.provider === 'lkeap' && saveType === 'rerank') {
extraConfig.region = (modelData.lkeapRegion || 'ap-guangzhou').trim()
}
if (
- currentModelType.value === 'chat'
+ saveType === 'chat'
&& modelData.source === 'remote'
&& modelData.thinkingControl
) {
@@ -415,7 +408,7 @@ const handleModelSave = async (modelData: any) => {
const apiModelData: ModelConfig = {
name: modelData.modelName.trim(),
display_name: modelData.displayName?.trim() || '',
- type: getModelType(currentModelType.value),
+ type: getModelType(saveType),
source: modelData.source,
description: '',
parameters: {
@@ -425,15 +418,15 @@ const handleModelSave = async (modelData: any) => {
provider: modelData.provider || '',
...extraConfigFields,
...(Object.keys(customHeadersMap).length > 0 ? { custom_headers: customHeadersMap } : {}),
- ...(currentModelType.value === 'embedding' && modelData.dimension ? {
+ ...(saveType === 'embedding' && modelData.dimension ? {
embedding_parameters: {
dimension: modelData.dimension,
truncate_prompt_tokens: 0
}
} : {}),
- ...(currentModelType.value === 'vllm' ? {
+ ...(saveType === 'vllm' ? {
supports_vision: true
- } : currentModelType.value === 'chat' ? {
+ } : saveType === 'chat' ? {
supports_vision: modelData.supportsVision ?? false
} : {})
}
@@ -580,10 +573,24 @@ onMounted(() => {
.section-header {
margin-bottom: 28px;
+
+ h2 {
+ font-size: 20px;
+ font-weight: 600;
+ color: var(--td-text-color-primary);
+ margin: 0 0 8px 0;
+ }
+
+ .section-description {
+ font-size: 14px;
+ color: var(--td-text-color-secondary);
+ margin: 0;
+ line-height: 1.6;
+ }
}
.builtin-models-hint {
- margin-top: 4px;
+ margin-top: 12px;
padding: 10px 12px;
background: var(--td-bg-color-secondarycontainer);
border: 1px solid var(--td-component-stroke);
@@ -609,38 +616,6 @@ onMounted(() => {
font-size: 13px;
}
-.section-header__top {
- display: flex;
- align-items: flex-start;
- justify-content: space-between;
- gap: 16px;
- margin-bottom: 8px;
-
- .section-header__text {
- flex: 1;
- min-width: 0;
- }
-
- h2 {
- font-size: 20px;
- font-weight: 600;
- color: var(--td-text-color-primary);
- margin: 0 0 8px 0;
- }
-
- .section-description {
- font-size: 14px;
- color: var(--td-text-color-secondary);
- margin: 0;
- line-height: 1.6;
- }
-
- :deep(.t-button) {
- flex-shrink: 0;
- margin-top: 4px;
- }
-}
-
.model-list-loading {
min-height: 120px;
}
@@ -679,6 +654,11 @@ onMounted(() => {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 12px;
+
+ .model-card--add {
+ width: 100%;
+ height: 100%;
+ }
}
// 模型卡片 —— 可选类型徽章(仅「全部」Tab)+ 标题 + 一行副标题
@@ -699,6 +679,51 @@ onMounted(() => {
box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}
+ &--add {
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
+ min-height: 68px;
+ border-style: dashed;
+ background: transparent;
+ color: var(--td-text-color-placeholder);
+ cursor: pointer;
+ font: inherit;
+ text-align: center;
+
+ &:hover,
+ &:focus-visible {
+ color: var(--td-brand-color);
+ border-color: var(--td-brand-color);
+ background: color-mix(in srgb, var(--td-brand-color) 6%, transparent);
+ box-shadow: none;
+ }
+
+ &:focus-visible {
+ outline: 2px solid var(--td-brand-color);
+ outline-offset: 2px;
+ }
+
+ &__icon {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 32px;
+ height: 32px;
+ border-radius: 8px;
+ background: color-mix(in srgb, var(--td-brand-color) 10%, transparent);
+ color: var(--td-brand-color);
+ font-size: 18px;
+ }
+
+ &__label {
+ font-size: 13px;
+ font-weight: 500;
+ line-height: 1.4;
+ }
+ }
+
&--builtin {
background: var(--td-bg-color-secondarycontainer);