feat(models): let system admins edit builtin model config

Allow platform system administrators to update builtin model parameters
and credentials from the management UI while keeping secrets masked in API
responses. UI edits clear YAML ownership so startup reconciliation no
longer overwrites runtime overrides.
This commit is contained in:
wizardchen
2026-07-14 15:51:32 +08:00
committed by lyingbug
parent f409bd756b
commit e1572b71b9
20 changed files with 328 additions and 35 deletions
+2 -2
View File
@@ -41,8 +41,8 @@ export interface ModelConfig {
is_default?: boolean;
is_builtin?: boolean;
status?: string;
// Per-field configured? metadata from the main response. Absent for
// builtin models.
// Per-field configured? metadata from the main response. For builtin
// models it is returned only to system administrators.
credentials?: Record<ModelCredentialField, { configured: boolean }>;
created_at?: string;
updated_at?: string;
+1
View File
@@ -4713,6 +4713,7 @@ export default {
builtinModels: {
title: 'Built-in Models',
description: 'Built-in models are visible to all tenants. Sensitive information is hidden, and they cannot be edited or deleted.',
descriptionAdmin: 'Built-in models are visible to all tenants. System administrators can edit configuration and credentials; deletion remains deployment-managed.',
viewGuide: 'View Built-in Models Guide',
},
builtinTag: 'Built-in',
+1
View File
@@ -4719,6 +4719,7 @@ export default {
builtinModels: {
title: "기본 제공 모델",
description: "기본 제공 모델은 모든 테넌트에게 표시됩니다. 민감한 정보는 숨겨지며, 편집하거나 삭제할 수 없습니다.",
descriptionAdmin: "기본 제공 모델은 모든 테넌트에게 표시됩니다. 시스템 관리자는 구성과 자격 증명을 편집할 수 있으며, 삭제는 배포 구성에서 관리됩니다.",
viewGuide: "기본 제공 모델 관리 가이드 보기",
},
builtinTag: "기본제공",
+1
View File
@@ -4373,6 +4373,7 @@ export default {
builtinModels: {
title: 'Встроенные модели',
description: 'Встроенные модели видны всем тенантам. Конфиденциальная информация скрыта, их нельзя редактировать или удалять.',
descriptionAdmin: 'Встроенные модели видны всем тенантам. Системные администраторы могут изменять конфигурацию и учетные данные; удаление управляется конфигурацией развертывания.',
viewGuide: 'Посмотреть руководство по управлению встроенными моделями'
},
builtinTag: 'Встроенная',
+1
View File
@@ -4725,6 +4725,7 @@ export default {
builtinModels: {
title: "内置模型",
description: "内置模型对所有租户可见,敏感信息会被隐藏,且不可编辑或删除。",
descriptionAdmin: "内置模型对所有租户可见。系统管理员可编辑配置和凭据;删除仍由部署配置管理。",
viewGuide: "查看内置模型管理指南",
},
builtinTag: "内置",
+26 -8
View File
@@ -22,7 +22,11 @@
<div class="builtin-models-hint" role="note">
<p class="builtin-hint-label">{{ $t('modelSettings.builtinModels.title') }}</p>
<p class="builtin-hint-text">{{ $t('modelSettings.builtinModels.description') }}</p>
<p class="builtin-hint-text">
{{ $t(authStore.isSystemAdmin
? 'modelSettings.builtinModels.descriptionAdmin'
: 'modelSettings.builtinModels.description') }}
</p>
<a class="doc-link" href="https://github.com/Tencent/WeKnora/blob/main/docs/BUILTIN_MODELS.md" target="_blank"
rel="noopener noreferrer">
{{ $t('modelSettings.builtinModels.viewGuide') }}
@@ -64,7 +68,7 @@
<h3 class="model-card__title">{{ modelDisplayName(model) }}</h3>
<span v-if="model.isBuiltin" class="model-card__lock" :title="$t('modelSettings.builtinTag')"
:aria-label="$t('modelSettings.builtinTag')">
<t-icon name="lock-on" />
<t-icon :name="authStore.isSystemAdmin ? 'edit-1' : 'lock-on'" />
</span>
<div v-if="canManageModel(model)" class="model-card__actions" @click.stop>
<t-dropdown :options="getModelOptions(model._modelType, model)" placement="bottom-right" attach="body"
@@ -75,6 +79,7 @@
</t-button>
</t-dropdown>
<t-popconfirm
v-if="canDeleteModel(model)"
:content="$t('modelSettings.confirmDelete', { name: modelDisplayName(model) })"
:confirm-btn="{ content: $t('common.delete'), theme: 'danger' }"
:cancel-btn="{ content: $t('common.cancel') }"
@@ -310,11 +315,18 @@ const openAddDialog = () => {
showDialog.value = true
}
// 可点击打开编辑抽屉:管理员 + 非内置模型
const isModelCardClickable = (model: any) =>
authStore.hasRole('admin') && !model.isBuiltin
// Tenant Admin+ manages tenant models; only SystemAdmin manages shared
// built-in models. The backend repeats this distinction authoritatively.
const canEditModel = (model: any) =>
model.isBuiltin ? authStore.isSystemAdmin : authStore.hasRole('admin')
const canManageModel = (model: any) =>
const isModelCardClickable = (model: any) => canEditModel(model)
const canManageModel = (model: any) => canEditModel(model)
// Built-in lifecycle remains deployment-managed (YAML / SQL). The UI only
// exposes configuration and credential editing to SystemAdmin.
const canDeleteModel = (model: any) =>
authStore.hasRole('admin') && !model.isBuiltin
const onModelCardClick = (event: Event, type: ModelType, model: any) => {
@@ -331,11 +343,11 @@ const onModelCardClick = (event: Event, type: ModelType, model: any) => {
// 编辑模型
const editModel = (type: ModelType, model: any) => {
if (model.isBuiltin) {
if (model.isBuiltin && !authStore.isSystemAdmin) {
MessagePlugin.warning(t('modelSettings.toasts.builtinCannotEdit'))
return
}
if (!authStore.hasRole('admin')) {
if (!model.isBuiltin && !authStore.hasRole('admin')) {
return
}
currentModelType.value = type
@@ -492,6 +504,12 @@ const getModelOptions = (type: ModelType, model: any) => {
const options: any[] = []
if (model.isBuiltin) {
if (authStore.isSystemAdmin) {
options.push({
content: t('common.edit'),
value: `edit-${type}-${model.id}`
})
}
return options
}