fix: add model display name
This commit is contained in:
@@ -867,7 +867,7 @@ const selectedModel = computed(() => {
|
||||
|
||||
// 模型展示名:本租户列表中有则用名称;若为共享智能体且其 model_id 不在本租户列表中则显示“共享智能体配置的模型”
|
||||
const selectedModelDisplayName = computed(() => {
|
||||
if (selectedModel.value) return selectedModel.value.name;
|
||||
if (selectedModel.value) return modelDisplayName(selectedModel.value);
|
||||
if (!selectedModelId.value) return t('input.notConfigured');
|
||||
const isSharedAgent = !!settingsStore.selectedAgentSourceTenantId;
|
||||
const modelFromAgent = agentModelId.value && agentModelId.value === selectedModelId.value;
|
||||
@@ -875,6 +875,11 @@ const selectedModelDisplayName = computed(() => {
|
||||
return t('input.notConfigured');
|
||||
});
|
||||
|
||||
const modelDisplayName = (model: ModelConfig) => {
|
||||
const displayName = model.display_name?.trim();
|
||||
return displayName || model.name;
|
||||
};
|
||||
|
||||
const updateModelDropdownPosition = () => {
|
||||
const anchor = modelButtonRef.value;
|
||||
if (!anchor) {
|
||||
@@ -2296,7 +2301,8 @@ defineExpose({
|
||||
<div v-for="model in availableModels" :key="model.id" class="model-option"
|
||||
:class="{ selected: model.id === selectedModelId }" @click="handleModelChange(model.id || '')">
|
||||
<div class="model-option-main">
|
||||
<span class="model-option-name">{{ model.name }}</span>
|
||||
<span class="model-option-name">{{ modelDisplayName(model) }}</span>
|
||||
<span v-if="model.display_name" class="model-option-raw-name">{{ model.name }}</span>
|
||||
<span v-if="model.source === 'remote'" class="model-badge-remote">{{ $t('input.remote') }}</span>
|
||||
<span v-else-if="model.parameters?.parameter_size" class="model-badge-local">
|
||||
{{ model.parameters.parameter_size }}
|
||||
@@ -2404,7 +2410,8 @@ const getImgSrc = (url: string) => {
|
||||
display: inline-flex;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
flex-shrink: 0;
|
||||
flex: 0 1 auto;
|
||||
min-width: 0;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 3px;
|
||||
@@ -3198,13 +3205,23 @@ const getImgSrc = (url: string) => {
|
||||
.model-option-name {
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-primary, #222);
|
||||
flex: 1;
|
||||
flex-shrink: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.model-option-raw-name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 11px;
|
||||
color: var(--td-text-color-placeholder, #b0b6bd);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.model-option-desc {
|
||||
font-size: 11px;
|
||||
color: var(--td-text-color-secondary, #8b9196);
|
||||
|
||||
@@ -143,6 +143,12 @@
|
||||
:disabled="formData.provider === 'weknoracloud' && wkcCredentialState !== 'configured'" />
|
||||
</div>
|
||||
|
||||
<div class="form-item">
|
||||
<label class="form-label">{{ $t('model.editor.displayNameLabel') }}</label>
|
||||
<t-input v-model="formData.displayName" :placeholder="$t('model.editor.displayNamePlaceholder')" />
|
||||
<p class="form-desc">{{ $t('model.editor.displayNameDesc') }}</p>
|
||||
</div>
|
||||
|
||||
<div v-if="formData.provider !== 'weknoracloud'" class="form-item">
|
||||
<label class="form-label required">{{ $t('model.editor.baseUrlLabel') }}</label>
|
||||
<t-input v-model="formData.baseUrl" :placeholder="getBaseUrlPlaceholder()" />
|
||||
@@ -268,6 +274,7 @@ interface ModelFormData {
|
||||
source: 'local' | 'remote'
|
||||
provider?: string // Provider identifier: openai, aliyun, zhipu, generic, etc.
|
||||
modelName: string
|
||||
displayName?: string
|
||||
baseUrl?: string
|
||||
apiKey?: string
|
||||
dimension?: number
|
||||
@@ -556,6 +563,7 @@ const formData = ref<ModelFormData>({
|
||||
source: 'local',
|
||||
provider: 'openai',
|
||||
modelName: '',
|
||||
displayName: '',
|
||||
baseUrl: '',
|
||||
apiKey: '',
|
||||
dimension: undefined,
|
||||
@@ -740,6 +748,7 @@ const resetForm = () => {
|
||||
source: 'local',
|
||||
provider: 'generic',
|
||||
modelName: '',
|
||||
displayName: '',
|
||||
baseUrl: '',
|
||||
apiKey: '',
|
||||
dimension: undefined, // 默认不填,让用户手动输入或通过检测按钮获取
|
||||
|
||||
@@ -14,11 +14,12 @@
|
||||
v-for="model in models"
|
||||
:key="model.id"
|
||||
:value="model.id"
|
||||
:label="model.name"
|
||||
:label="modelDisplayName(model)"
|
||||
>
|
||||
<div class="model-option">
|
||||
<t-icon name="check-circle-filled" class="model-icon" />
|
||||
<span class="model-name">{{ model.name }}</span>
|
||||
<span class="model-name">{{ modelDisplayName(model) }}</span>
|
||||
<span v-if="model.display_name" class="model-raw-name">{{ model.name }}</span>
|
||||
<t-tag v-if="model.is_builtin" size="small" theme="primary">{{ $t('model.builtinTag') }}</t-tag>
|
||||
<t-tag v-if="model.is_default" size="small" theme="success">{{ $t('model.defaultTag') }}</t-tag>
|
||||
</div>
|
||||
@@ -72,6 +73,11 @@ const placeholderText = computed(() => {
|
||||
return props.placeholder || t('model.selectModelPlaceholder')
|
||||
})
|
||||
|
||||
const modelDisplayName = (model: ModelConfig) => {
|
||||
const displayName = model.display_name?.trim()
|
||||
return displayName || model.name
|
||||
}
|
||||
|
||||
// 监听 allModels 变化,自动过滤当前类型的模型
|
||||
watch(() => props.allModels, (newModels) => {
|
||||
if (newModels && Array.isArray(newModels)) {
|
||||
@@ -153,8 +159,22 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.model-name {
|
||||
flex: 1;
|
||||
flex: 0 1 auto;
|
||||
min-width: 0;
|
||||
font-size: 13px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.model-raw-name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&.add {
|
||||
@@ -165,4 +185,3 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user