Merge branch 'main' into feat_oss
This commit is contained in:
@@ -18,6 +18,46 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- WeKnoraCloud 厂商配置 -->
|
||||
<div class="weknoracloud-config-section" style="margin-bottom: 24px;">
|
||||
<div class="category-header" style="margin-bottom: 12px;">
|
||||
<h3 style="margin: 0; font-size: 16px; font-weight: 600;">WeKnoraCloud 厂商配置</h3>
|
||||
</div>
|
||||
<!-- 凭证失效警告 -->
|
||||
<div v-if="weKnoraCloudNeedsReinit" style="margin-bottom: 12px; background: #fff7ed; border: 1px solid #fed7aa; border-left: 3px solid #f97316; border-radius: 6px; padding: 12px 16px; display: flex; align-items: flex-start; gap: 10px;">
|
||||
<t-icon name="error-circle" style="font-size: 16px; color: #f97316; flex-shrink: 0; margin-top: 1px;" />
|
||||
<div style="font-size: 13px; color: #9a3412; line-height: 1.5;">
|
||||
<strong>WeKnoraCloud 凭证已失效</strong><br />
|
||||
{{ weKnoraCloudReinitReason || '服务重启后加密密钥已变更,已保存的凭证无法解密。' }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="weknoracloud-config-card" style="background: var(--td-bg-color-container); border: 1px solid var(--td-component-stroke); border-radius: 8px; padding: 20px;">
|
||||
<div style="display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;">
|
||||
<t-form-item label="APPID" style="margin-bottom: 0;">
|
||||
<t-input v-model="weKnoraCloudForm.appId" placeholder="请输入 APPID" style="width: 240px;" />
|
||||
</t-form-item>
|
||||
<t-form-item label="APPSECRET" style="margin-bottom: 0;">
|
||||
<t-input
|
||||
v-model="weKnoraCloudForm.appSecret"
|
||||
type="password"
|
||||
placeholder="请输入 APPSECRET"
|
||||
style="width: 240px;"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-button
|
||||
theme="primary"
|
||||
:loading="weKnoraCloudLoading"
|
||||
@click="handleWeKnoraCloudInit"
|
||||
>
|
||||
保存并初始化
|
||||
</t-button>
|
||||
</div>
|
||||
<p style="color: var(--td-text-color-secondary); font-size: 12px; margin-top: 12px; margin-bottom: 0;">
|
||||
提交后将自动创建或更新三个模型(Chat / Embedding / Rerank)并设为各类型默认
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 对话模型 -->
|
||||
<div class="settings-group model-type-group" data-model-type="chat">
|
||||
<div class="section-subheader">
|
||||
@@ -295,7 +335,7 @@ import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { AddIcon } from 'tdesign-icons-vue-next'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import ModelEditorDialog from '@/components/ModelEditorDialog.vue'
|
||||
import { listModels, createModel, updateModel as updateModelAPI, deleteModel as deleteModelAPI, type ModelConfig } from '@/api/model'
|
||||
import { listModels, createModel, updateModel as updateModelAPI, deleteModel as deleteModelAPI, initializeWeKnoraCloud, getWeKnoraCloudStatus, type ModelConfig } from '@/api/model'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
@@ -304,6 +344,38 @@ const currentModelType = ref<'chat' | 'embedding' | 'rerank' | 'vllm' | 'asr'>('
|
||||
const editingModel = ref<any>(null)
|
||||
const loading = ref(true)
|
||||
|
||||
// WeKnoraCloud 配置
|
||||
const weKnoraCloudForm = ref({ appId: '', appSecret: '' })
|
||||
const weKnoraCloudLoading = ref(false)
|
||||
const weKnoraCloudNeedsReinit = ref(false)
|
||||
const weKnoraCloudReinitReason = ref('')
|
||||
|
||||
const handleWeKnoraCloudInit = async () => {
|
||||
if (!weKnoraCloudForm.value.appId || !weKnoraCloudForm.value.appSecret) {
|
||||
MessagePlugin.warning('请填写 APPID 和 APPSECRET')
|
||||
return
|
||||
}
|
||||
weKnoraCloudLoading.value = true
|
||||
try {
|
||||
const result = await initializeWeKnoraCloud({
|
||||
app_id: weKnoraCloudForm.value.appId,
|
||||
app_secret: weKnoraCloudForm.value.appSecret,
|
||||
})
|
||||
const updatedCount = result.models.filter((m: any) => m.action === 'updated').length
|
||||
const createdCount = result.models.filter((m: any) => m.action === 'created').length
|
||||
MessagePlugin.success(`初始化成功:新建 ${createdCount} 个,更新 ${updatedCount} 个模型`)
|
||||
weKnoraCloudForm.value.appId = ''
|
||||
weKnoraCloudForm.value.appSecret = ''
|
||||
weKnoraCloudNeedsReinit.value = false
|
||||
weKnoraCloudReinitReason.value = ''
|
||||
await loadModels()
|
||||
} catch (err: any) {
|
||||
MessagePlugin.error(err?.message || 'WeKnoraCloud 初始化失败')
|
||||
} finally {
|
||||
weKnoraCloudLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 模型列表数据
|
||||
const allModels = ref<ModelConfig[]>([])
|
||||
|
||||
@@ -361,6 +433,10 @@ const loadModels = async () => {
|
||||
// 直接获取所有模型,不分类型
|
||||
const models = await listModels()
|
||||
allModels.value = models
|
||||
// 检查 WeKnoraCloud 凭证状态
|
||||
const status = await getWeKnoraCloudStatus()
|
||||
weKnoraCloudNeedsReinit.value = status.needs_reinit
|
||||
weKnoraCloudReinitReason.value = status.reason || ''
|
||||
} catch (error: any) {
|
||||
console.error('加载模型列表失败:', error)
|
||||
MessagePlugin.error(error.message)
|
||||
|
||||
Reference in New Issue
Block a user