feat: Implement theme management and UI enhancements across the application
- Added theme initialization and management in the UI store. - Enhanced dark mode styles for various components, including tables, dialogs, and inputs. - Updated multiple components to use CSS variables for consistent theming. - Introduced a new simplified API for updating knowledge base configurations. - Improved overall UI consistency and responsiveness with new styles.
This commit is contained in:
@@ -67,17 +67,27 @@
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
</t-dialog>
|
||||
|
||||
<!-- 知识库设置模态框 -->
|
||||
<KnowledgeBaseSettingsModal />
|
||||
|
||||
<!-- 全局设置模态框 -->
|
||||
<Settings />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref, computed } from 'vue'
|
||||
import { onMounted, reactive, ref, computed, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { listKnowledgeBases, createKnowledgeBase, deleteKnowledgeBase } from '@/api/knowledge-base'
|
||||
import { formatStringDate } from '@/utils/index'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
import KnowledgeBaseSettingsModal from './KnowledgeBaseSettingsModal.vue'
|
||||
import Settings from '@/views/settings/Settings.vue'
|
||||
|
||||
const router = useRouter()
|
||||
const uiStore = useUIStore()
|
||||
|
||||
interface KB {
|
||||
id: string;
|
||||
@@ -167,14 +177,23 @@ const goDetail = (id: string) => {
|
||||
router.push(`/platform/knowledge-bases/${id}`)
|
||||
}
|
||||
const goSettings = (id: string) => {
|
||||
router.push(`/platform/knowledge-bases/${id}/settings`)
|
||||
// 使用模态框打开设置,而不是路由导航
|
||||
uiStore.openKBSettings(id)
|
||||
}
|
||||
|
||||
// 监听知识库设置模态框关闭,刷新列表
|
||||
watch(() => uiStore.showKBSettingsModal, (newVal, oldVal) => {
|
||||
// 当模态框从打开变为关闭时,刷新列表
|
||||
if (oldVal && !newVal) {
|
||||
fetchList()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.kb-list-container {
|
||||
padding: 20px;
|
||||
background: #fff;
|
||||
background: var(--td-bg-color-container);
|
||||
margin: 0 20px 0 20px;
|
||||
height: calc(100vh);
|
||||
overflow-y: auto;
|
||||
@@ -186,7 +205,7 @@ const goSettings = (id: string) => {
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16px;
|
||||
h2 { margin: 0; font-size: 20px; font-weight: 600; }
|
||||
h2 { margin: 0; font-size: 20px; font-weight: 600; color: var(--td-text-color-primary); }
|
||||
}
|
||||
|
||||
.warning-banner {
|
||||
@@ -195,14 +214,14 @@ const goSettings = (id: string) => {
|
||||
gap: 8px;
|
||||
padding: 12px 16px;
|
||||
margin-bottom: 16px;
|
||||
background: #fff7e6;
|
||||
border: 1px solid #ffd591;
|
||||
background: var(--td-warning-color-light);
|
||||
border: 1px solid var(--td-warning-color-3);
|
||||
border-radius: 6px;
|
||||
color: #d46b08;
|
||||
color: var(--td-warning-color);
|
||||
font-size: 14px;
|
||||
|
||||
.t-icon {
|
||||
color: #d46b08;
|
||||
color: var(--td-warning-color);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
@@ -213,21 +232,21 @@ const goSettings = (id: string) => {
|
||||
gap: 8px;
|
||||
|
||||
.warning-icon {
|
||||
color: #ff8800;
|
||||
color: var(--td-warning-color);
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
transition: color 0.2s;
|
||||
|
||||
&:hover {
|
||||
color: #d46b08;
|
||||
color: var(--td-warning-color-hover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.description-cell {
|
||||
.description-text {
|
||||
color: #000000e6;
|
||||
color: var(--td-text-color-primary);
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,668 @@
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Transition name="modal">
|
||||
<div v-if="visible" class="settings-overlay" @click.self="handleClose">
|
||||
<div class="settings-modal">
|
||||
<!-- 关闭按钮 -->
|
||||
<button class="close-btn" @click="handleClose" aria-label="关闭设置">
|
||||
<svg width="20" height="20" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path d="M15 5L5 15M5 5L15 15" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<div class="settings-container">
|
||||
<!-- 左侧导航 -->
|
||||
<div class="settings-sidebar">
|
||||
<div class="sidebar-header">
|
||||
<h2 class="sidebar-title">知识库设置</h2>
|
||||
</div>
|
||||
<div class="settings-nav">
|
||||
<div
|
||||
v-for="(item, index) in navItems"
|
||||
:key="index"
|
||||
:class="['nav-item', { 'active': currentSection === item.key }]"
|
||||
@click="currentSection = item.key"
|
||||
>
|
||||
<span class="nav-icon">{{ item.icon }}</span>
|
||||
<span class="nav-label">{{ item.label }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧内容区域 -->
|
||||
<div class="settings-content">
|
||||
<div class="content-wrapper">
|
||||
<!-- 基本信息 -->
|
||||
<div v-show="currentSection === 'basic'" class="section">
|
||||
<KBBasicInfo
|
||||
v-if="kbData"
|
||||
:kb-id="kbId"
|
||||
:name="kbData.name"
|
||||
:description="kbData.description"
|
||||
@update:name="kbData.name = $event"
|
||||
@update:description="kbData.description = $event"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 模型配置 -->
|
||||
<div v-show="currentSection === 'models'" class="section">
|
||||
<KBModelConfig
|
||||
ref="modelConfigRef"
|
||||
v-if="configData"
|
||||
:config="modelConfig"
|
||||
:has-files="configData.hasFiles"
|
||||
:all-models="allModels"
|
||||
@update:config="handleModelConfigUpdate"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 分块设置 -->
|
||||
<div v-show="currentSection === 'chunking'" class="section">
|
||||
<KBChunkingSettings
|
||||
v-if="configData"
|
||||
:config="chunkingConfig"
|
||||
@update:config="handleChunkingConfigUpdate"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 高级设置 -->
|
||||
<div v-show="currentSection === 'advanced'" class="section">
|
||||
<KBAdvancedSettings
|
||||
ref="advancedSettingsRef"
|
||||
v-if="configData"
|
||||
:multimodal="multimodalConfig"
|
||||
:node-extract="nodeExtractConfig"
|
||||
:all-models="allModels"
|
||||
@update:multimodal="handleMultimodalUpdate"
|
||||
@update:nodeExtract="handleNodeExtractUpdate"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 保存按钮 -->
|
||||
<div class="settings-footer">
|
||||
<t-button theme="default" variant="outline" @click="handleClose">
|
||||
取消
|
||||
</t-button>
|
||||
<t-button theme="primary" @click="handleSave" :loading="saving">
|
||||
保存配置
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch, onMounted } from 'vue'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { getKnowledgeBaseById, listKnowledgeFiles } from '@/api/knowledge-base'
|
||||
import { updateKBConfig, type KBModelConfigRequest } from '@/api/initialization'
|
||||
import { listModels } from '@/api/model'
|
||||
import KBBasicInfo from './settings/KBBasicInfo.vue'
|
||||
import KBModelConfig from './settings/KBModelConfig.vue'
|
||||
import KBChunkingSettings from './settings/KBChunkingSettings.vue'
|
||||
import KBAdvancedSettings from './settings/KBAdvancedSettings.vue'
|
||||
|
||||
const uiStore = useUIStore()
|
||||
|
||||
const visible = computed(() => uiStore.showKBSettingsModal)
|
||||
const kbId = computed(() => uiStore.currentKBId || '')
|
||||
|
||||
const currentSection = ref<string>('basic')
|
||||
const saving = ref(false)
|
||||
const loading = ref(false)
|
||||
const allModels = ref<any[]>([])
|
||||
|
||||
const navItems = [
|
||||
{ key: 'basic', icon: 'ℹ️', label: '基本信息' },
|
||||
{ key: 'models', icon: '🤖', label: '模型配置' },
|
||||
{ key: 'chunking', icon: '📄', label: '分块设置' },
|
||||
{ key: 'advanced', icon: '⚙️', label: '高级设置' }
|
||||
]
|
||||
|
||||
// 知识库基本数据
|
||||
const kbData = ref<{
|
||||
name: string
|
||||
description?: string
|
||||
} | null>(null)
|
||||
|
||||
// 配置数据(简化为只需要 hasFiles 标记)
|
||||
const configData = ref<{ hasFiles: boolean } | null>(null)
|
||||
|
||||
// 模型配置引用
|
||||
const modelConfigRef = ref<InstanceType<typeof KBModelConfig>>()
|
||||
const advancedSettingsRef = ref<InstanceType<typeof KBAdvancedSettings>>()
|
||||
|
||||
// 模型配置
|
||||
const modelConfig = ref({
|
||||
llmModelId: '',
|
||||
embeddingModelId: '',
|
||||
rerankModelId: ''
|
||||
})
|
||||
|
||||
// 分块配置
|
||||
const chunkingConfig = ref({
|
||||
chunkSize: 512,
|
||||
chunkOverlap: 100,
|
||||
separators: ['\n\n', '\n', '。', '!', '?', ';', ';']
|
||||
})
|
||||
|
||||
// 多模态配置
|
||||
const multimodalConfig = ref({
|
||||
enabled: false,
|
||||
storageType: 'minio' as 'minio' | 'cos',
|
||||
vllmModelId: '',
|
||||
minio: {
|
||||
bucketName: '',
|
||||
useSSL: false,
|
||||
pathPrefix: ''
|
||||
},
|
||||
cos: {
|
||||
secretId: '',
|
||||
secretKey: '',
|
||||
region: '',
|
||||
bucketName: '',
|
||||
appId: '',
|
||||
pathPrefix: ''
|
||||
}
|
||||
})
|
||||
|
||||
// 知识图谱配置
|
||||
const nodeExtractConfig = ref({
|
||||
enabled: false,
|
||||
text: '',
|
||||
tags: [] as string[]
|
||||
})
|
||||
|
||||
// 加载所有模型(统一加载,避免重复调用)
|
||||
const loadAllModels = async () => {
|
||||
try {
|
||||
const models = await listModels()
|
||||
allModels.value = models || []
|
||||
return models || []
|
||||
} catch (error) {
|
||||
console.error('加载模型列表失败:', error)
|
||||
MessagePlugin.error('加载模型列表失败')
|
||||
allModels.value = []
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
// 加载知识库数据
|
||||
const loadKBData = async () => {
|
||||
if (!kbId.value) return
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
// 并行加载知识库信息和所有模型(只需要一个接口!)
|
||||
const [kbInfo, models] = await Promise.all([
|
||||
getKnowledgeBaseById(kbId.value),
|
||||
loadAllModels()
|
||||
])
|
||||
|
||||
if (!kbInfo || !kbInfo.data) {
|
||||
throw new Error('知识库不存在')
|
||||
}
|
||||
|
||||
const kb = kbInfo.data
|
||||
|
||||
// 设置基本信息
|
||||
kbData.value = {
|
||||
name: kb.name || '',
|
||||
description: kb.description || ''
|
||||
}
|
||||
|
||||
// 设置模型ID(直接从知识库数据中获取)
|
||||
modelConfig.value = {
|
||||
llmModelId: kb.summary_model_id || '',
|
||||
embeddingModelId: kb.embedding_model_id || '',
|
||||
rerankModelId: kb.rerank_model_id || ''
|
||||
}
|
||||
|
||||
// 设置分块配置
|
||||
chunkingConfig.value = {
|
||||
chunkSize: kb.chunking_config?.chunk_size || 512,
|
||||
chunkOverlap: kb.chunking_config?.chunk_overlap || 100,
|
||||
separators: kb.chunking_config?.separators || ['\n\n', '\n', '。', '!', '?', ';', ';']
|
||||
}
|
||||
|
||||
// 设置多模态配置
|
||||
// 判断是否真的有存储配置:provider 不为空且有实际的存储信息
|
||||
const hasStorage = kb.cos_config?.provider && (
|
||||
(kb.cos_config.provider === 'minio' && kb.cos_config.bucket_name) ||
|
||||
(kb.cos_config.provider === 'cos' && kb.cos_config.bucket_name)
|
||||
)
|
||||
const hasVLM = !!kb.vlm_model_id
|
||||
|
||||
multimodalConfig.value = {
|
||||
enabled: !!(hasStorage || hasVLM),
|
||||
storageType: (kb.cos_config?.provider || 'minio') as 'minio' | 'cos',
|
||||
vllmModelId: kb.vlm_model_id || '',
|
||||
minio: {
|
||||
bucketName: kb.cos_config?.bucket_name || '',
|
||||
useSSL: false,
|
||||
pathPrefix: kb.cos_config?.path_prefix || ''
|
||||
},
|
||||
cos: {
|
||||
secretId: kb.cos_config?.secret_id || '',
|
||||
secretKey: kb.cos_config?.secret_key || '',
|
||||
region: kb.cos_config?.region || '',
|
||||
bucketName: kb.cos_config?.bucket_name || '',
|
||||
appId: kb.cos_config?.app_id || '',
|
||||
pathPrefix: kb.cos_config?.path_prefix || ''
|
||||
}
|
||||
}
|
||||
|
||||
// 设置知识图谱配置
|
||||
if (kb.extract_config) {
|
||||
nodeExtractConfig.value = {
|
||||
enabled: true,
|
||||
text: kb.extract_config.text || '',
|
||||
tags: kb.extract_config.tags || []
|
||||
}
|
||||
} else {
|
||||
nodeExtractConfig.value = {
|
||||
enabled: false,
|
||||
text: '',
|
||||
tags: []
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否有文件(用于判断是否可以修改Embedding模型)
|
||||
const knowledgeList = await listKnowledgeFiles(kbId.value, { page: 1, page_size: 1 })
|
||||
const hasFiles = knowledgeList && knowledgeList.data && knowledgeList.data.items && knowledgeList.data.items.length > 0
|
||||
|
||||
// 设置 configData(用于传递 hasFiles 状态)
|
||||
configData.value = { hasFiles } as any
|
||||
|
||||
} catch (error) {
|
||||
console.error('加载知识库数据失败:', error)
|
||||
MessagePlugin.error('加载知识库数据失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 不再需要 mapModelIds,直接使用知识库返回的模型ID
|
||||
|
||||
// 处理模型配置更新
|
||||
const handleModelConfigUpdate = (newConfig: typeof modelConfig.value) => {
|
||||
modelConfig.value = newConfig
|
||||
}
|
||||
|
||||
// 处理分块配置更新
|
||||
const handleChunkingConfigUpdate = (newConfig: typeof chunkingConfig.value) => {
|
||||
chunkingConfig.value = newConfig
|
||||
}
|
||||
|
||||
// 处理多模态配置更新
|
||||
const handleMultimodalUpdate = (newConfig: typeof multimodalConfig.value) => {
|
||||
multimodalConfig.value = newConfig
|
||||
}
|
||||
|
||||
// 处理知识图谱配置更新
|
||||
const handleNodeExtractUpdate = (newConfig: typeof nodeExtractConfig.value) => {
|
||||
nodeExtractConfig.value = newConfig
|
||||
}
|
||||
|
||||
// 保存配置
|
||||
const handleSave = async () => {
|
||||
if (saving.value || !kbId.value) return
|
||||
|
||||
// 验证必填项 - 模型配置
|
||||
if (!modelConfig.value.llmModelId) {
|
||||
MessagePlugin.warning('请选择LLM模型')
|
||||
currentSection.value = 'models'
|
||||
return
|
||||
}
|
||||
|
||||
if (!modelConfig.value.embeddingModelId) {
|
||||
MessagePlugin.warning('请选择Embedding模型')
|
||||
currentSection.value = 'models'
|
||||
return
|
||||
}
|
||||
|
||||
// 验证多模态配置
|
||||
if (multimodalConfig.value.enabled) {
|
||||
// 验证VLLM模型(必选)
|
||||
if (!multimodalConfig.value.vllmModelId) {
|
||||
MessagePlugin.warning('多模态功能已启用,请选择VLLM视觉模型')
|
||||
currentSection.value = 'advanced'
|
||||
return
|
||||
}
|
||||
|
||||
// 验证存储配置
|
||||
if (multimodalConfig.value.storageType === 'minio') {
|
||||
if (!multimodalConfig.value.minio.bucketName) {
|
||||
MessagePlugin.warning('使用MinIO存储时,Bucket名称为必填项')
|
||||
currentSection.value = 'advanced'
|
||||
return
|
||||
}
|
||||
} else if (multimodalConfig.value.storageType === 'cos') {
|
||||
const cos = multimodalConfig.value.cos
|
||||
if (!cos.secretId) {
|
||||
MessagePlugin.warning('使用腾讯云COS时,SecretId为必填项')
|
||||
currentSection.value = 'advanced'
|
||||
return
|
||||
}
|
||||
if (!cos.secretKey) {
|
||||
MessagePlugin.warning('使用腾讯云COS时,SecretKey为必填项')
|
||||
currentSection.value = 'advanced'
|
||||
return
|
||||
}
|
||||
if (!cos.region) {
|
||||
MessagePlugin.warning('使用腾讯云COS时,地域为必填项')
|
||||
currentSection.value = 'advanced'
|
||||
return
|
||||
}
|
||||
if (!cos.bucketName) {
|
||||
MessagePlugin.warning('使用腾讯云COS时,Bucket名称为必填项')
|
||||
currentSection.value = 'advanced'
|
||||
return
|
||||
}
|
||||
if (!cos.appId) {
|
||||
MessagePlugin.warning('使用腾讯云COS时,AppId为必填项')
|
||||
currentSection.value = 'advanced'
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
saving.value = true
|
||||
try {
|
||||
// 构建配置对象(简化版,只传模型ID)
|
||||
const config: KBModelConfigRequest = {
|
||||
llmModelId: modelConfig.value.llmModelId,
|
||||
embeddingModelId: modelConfig.value.embeddingModelId,
|
||||
rerankModelId: modelConfig.value.rerankModelId || '',
|
||||
vllmModelId: multimodalConfig.value.vllmModelId || '',
|
||||
documentSplitting: {
|
||||
chunkSize: chunkingConfig.value.chunkSize,
|
||||
chunkOverlap: chunkingConfig.value.chunkOverlap,
|
||||
separators: chunkingConfig.value.separators
|
||||
},
|
||||
multimodal: {
|
||||
enabled: multimodalConfig.value.enabled,
|
||||
storageType: multimodalConfig.value.enabled ? multimodalConfig.value.storageType : 'minio',
|
||||
cos: multimodalConfig.value.enabled && multimodalConfig.value.storageType === 'cos' ? multimodalConfig.value.cos : undefined,
|
||||
minio: multimodalConfig.value.enabled && multimodalConfig.value.storageType === 'minio' ? multimodalConfig.value.minio : undefined
|
||||
},
|
||||
nodeExtract: {
|
||||
enabled: nodeExtractConfig.value.enabled,
|
||||
text: nodeExtractConfig.value.text,
|
||||
tags: nodeExtractConfig.value.tags,
|
||||
nodes: [],
|
||||
relations: []
|
||||
}
|
||||
}
|
||||
|
||||
// 保存配置
|
||||
await updateKBConfig(kbId.value, config)
|
||||
MessagePlugin.success('配置保存成功')
|
||||
handleClose()
|
||||
} catch (error) {
|
||||
console.error('保存配置失败:', error)
|
||||
MessagePlugin.error('保存配置失败')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 处理关闭
|
||||
const handleClose = () => {
|
||||
uiStore.closeKBSettings()
|
||||
// 重置当前选中的section
|
||||
setTimeout(() => {
|
||||
currentSection.value = 'basic'
|
||||
}, 300)
|
||||
}
|
||||
|
||||
// 监听visible变化,当打开时加载数据
|
||||
watch(visible, (newVal) => {
|
||||
if (newVal && kbId.value) {
|
||||
loadKBData()
|
||||
}
|
||||
})
|
||||
|
||||
// 监听全局设置关闭事件,刷新模型列表
|
||||
watch(() => uiStore.showSettingsModal, (newVal, oldVal) => {
|
||||
// 当全局设置从打开变为关闭,且知识库设置仍然打开时,刷新模型列表
|
||||
if (oldVal && !newVal && visible.value) {
|
||||
// 统一刷新所有模型列表(只调用一次API)
|
||||
loadAllModels()
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
if (visible.value && kbId.value) {
|
||||
loadKBData()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
/* 遮罩层 */
|
||||
.settings-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 999;
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
/* 弹窗容器 */
|
||||
.settings-modal {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
max-width: 900px;
|
||||
height: 700px;
|
||||
background: var(--td-bg-color-container);
|
||||
border-radius: 12px;
|
||||
box-shadow: var(--td-shadow-3);
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* 关闭按钮 */
|
||||
.close-btn {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
right: 16px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--td-text-color-secondary);
|
||||
cursor: pointer;
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.2s ease;
|
||||
z-index: 10;
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-container-hover);
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.settings-container {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 左侧导航栏 */
|
||||
.settings-sidebar {
|
||||
width: 220px;
|
||||
background-color: var(--td-bg-color-secondarycontainer);
|
||||
border-right: 1px solid var(--td-component-border);
|
||||
flex-shrink: 0;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.sidebar-header {
|
||||
padding: 24px 16px 16px;
|
||||
border-bottom: 1px solid var(--td-component-border);
|
||||
}
|
||||
|
||||
.sidebar-title {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-primary);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.settings-nav {
|
||||
padding: 16px 8px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 10px 16px;
|
||||
margin-bottom: 4px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
color: var(--td-text-color-secondary);
|
||||
font-size: 14px;
|
||||
transition: all 0.2s ease;
|
||||
user-select: none;
|
||||
|
||||
&:hover {
|
||||
background-color: var(--td-bg-color-container-hover);
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
&.active {
|
||||
background-color: var(--td-brand-color-light);
|
||||
color: var(--td-brand-color);
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.nav-icon {
|
||||
margin-right: 12px;
|
||||
font-size: 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.nav-label {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* 右侧内容区域 */
|
||||
.settings-content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
background-color: var(--td-bg-color-container);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.content-wrapper {
|
||||
flex: 1;
|
||||
max-width: 600px;
|
||||
padding: 40px 48px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.section {
|
||||
animation: fadeIn 0.3s ease;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* 底部保存按钮 */
|
||||
.settings-footer {
|
||||
padding: 16px 48px;
|
||||
border-top: 1px solid var(--td-component-border);
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
background: var(--td-bg-color-container);
|
||||
}
|
||||
|
||||
/* 弹窗动画 */
|
||||
.modal-enter-active,
|
||||
.modal-leave-active {
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.modal-enter-active .settings-modal,
|
||||
.modal-leave-active .settings-modal {
|
||||
transition: transform 0.2s ease, opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.modal-enter-from,
|
||||
.modal-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.modal-enter-from .settings-modal,
|
||||
.modal-leave-to .settings-modal {
|
||||
transform: scale(0.95);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
/* 滚动条样式 */
|
||||
.settings-sidebar::-webkit-scrollbar,
|
||||
.settings-content::-webkit-scrollbar,
|
||||
.content-wrapper::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.settings-sidebar::-webkit-scrollbar-track {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
}
|
||||
|
||||
.settings-sidebar::-webkit-scrollbar-thumb {
|
||||
background: var(--td-bg-color-component);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.settings-sidebar::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--td-bg-color-component-hover);
|
||||
}
|
||||
|
||||
.content-wrapper::-webkit-scrollbar-track {
|
||||
background: var(--td-bg-color-container);
|
||||
}
|
||||
|
||||
.content-wrapper::-webkit-scrollbar-thumb {
|
||||
background: var(--td-bg-color-component);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.content-wrapper::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--td-bg-color-component-hover);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,482 @@
|
||||
<template>
|
||||
<div class="kb-advanced-settings">
|
||||
<div class="section-header">
|
||||
<h2>高级设置</h2>
|
||||
<p class="section-description">配置多模态、知识图谱等高级功能</p>
|
||||
</div>
|
||||
|
||||
<div class="settings-group">
|
||||
<!-- 多模态功能 -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>多模态功能</label>
|
||||
<p class="desc">启用图片、视频等多模态内容的理解能力</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-switch
|
||||
v-model="localMultimodal.enabled"
|
||||
@change="handleMultimodalToggle"
|
||||
size="large"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 多模态存储配置 -->
|
||||
<div v-if="localMultimodal.enabled" class="subsection">
|
||||
<!-- VLLM 视觉模型 -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>VLLM 视觉模型 <span class="required">*</span></label>
|
||||
<p class="desc">用于多模态理解的视觉语言模型(必选)</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<ModelSelector
|
||||
ref="vllmSelectorRef"
|
||||
model-type="VLLM"
|
||||
:selected-model-id="localMultimodal.vllmModelId"
|
||||
:all-models="allModels"
|
||||
@update:selected-model-id="handleVLLMChange"
|
||||
@add-model="handleAddModel('vllm')"
|
||||
placeholder="请选择VLLM模型(必选)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="subsection-header">
|
||||
<h4>存储配置 <span class="required">*</span></h4>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>存储类型 <span class="required">*</span></label>
|
||||
<p class="desc">选择多模态文件的存储方式(MinIO或腾讯云COS二选一)</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-radio-group v-model="localMultimodal.storageType" @change="handleStorageTypeChange">
|
||||
<t-radio value="minio">MinIO</t-radio>
|
||||
<t-radio value="cos">腾讯云COS</t-radio>
|
||||
</t-radio-group>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MinIO配置 -->
|
||||
<div v-if="localMultimodal.storageType === 'minio'" class="storage-config">
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>Bucket名称 <span class="required">*</span></label>
|
||||
<p class="desc">MinIO存储桶名称(必填)</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-input
|
||||
v-model="localMultimodal.minio.bucketName"
|
||||
placeholder="请输入Bucket名称(必填)"
|
||||
@change="handleConfigChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>使用SSL</label>
|
||||
<p class="desc">是否使用SSL连接</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-switch
|
||||
v-model="localMultimodal.minio.useSSL"
|
||||
@change="handleConfigChange"
|
||||
size="large"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>路径前缀</label>
|
||||
<p class="desc">文件存储路径前缀(可选)</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-input
|
||||
v-model="localMultimodal.minio.pathPrefix"
|
||||
placeholder="请输入路径前缀"
|
||||
@change="handleConfigChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- COS配置 -->
|
||||
<div v-if="localMultimodal.storageType === 'cos'" class="storage-config">
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>SecretId <span class="required">*</span></label>
|
||||
<p class="desc">腾讯云API密钥ID(必填)</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-input
|
||||
v-model="localMultimodal.cos.secretId"
|
||||
placeholder="请输入SecretId(必填)"
|
||||
@change="handleConfigChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>SecretKey <span class="required">*</span></label>
|
||||
<p class="desc">腾讯云API密钥Key(必填)</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-input
|
||||
v-model="localMultimodal.cos.secretKey"
|
||||
type="password"
|
||||
placeholder="请输入SecretKey(必填)"
|
||||
@change="handleConfigChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>地域 <span class="required">*</span></label>
|
||||
<p class="desc">COS存储桶所在地域(必填)</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-input
|
||||
v-model="localMultimodal.cos.region"
|
||||
placeholder="如:ap-guangzhou(必填)"
|
||||
@change="handleConfigChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>Bucket名称 <span class="required">*</span></label>
|
||||
<p class="desc">COS存储桶名称(必填)</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-input
|
||||
v-model="localMultimodal.cos.bucketName"
|
||||
placeholder="请输入Bucket名称(必填)"
|
||||
@change="handleConfigChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>AppId <span class="required">*</span></label>
|
||||
<p class="desc">腾讯云应用ID(必填)</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-input
|
||||
v-model="localMultimodal.cos.appId"
|
||||
placeholder="请输入AppId(必填)"
|
||||
@change="handleConfigChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>路径前缀</label>
|
||||
<p class="desc">文件存储路径前缀(可选)</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-input
|
||||
v-model="localMultimodal.cos.pathPrefix"
|
||||
placeholder="请输入路径前缀"
|
||||
@change="handleConfigChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 知识图谱提取 -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>知识图谱提取</label>
|
||||
<p class="desc">从文档中自动提取实体和关系构建知识图谱</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-switch
|
||||
v-model="localNodeExtract.enabled"
|
||||
@change="handleNodeExtractToggle"
|
||||
size="large"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 知识图谱配置 -->
|
||||
<div v-if="localNodeExtract.enabled" class="subsection">
|
||||
<div class="subsection-header">
|
||||
<h4>图谱配置</h4>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>提示文本</label>
|
||||
<p class="desc">用于引导模型提取实体和关系的提示文本</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-textarea
|
||||
v-model="localNodeExtract.text"
|
||||
placeholder="请输入提示文本"
|
||||
:autosize="{ minRows: 3, maxRows: 6 }"
|
||||
@change="handleConfigChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>标签</label>
|
||||
<p class="desc">预定义的实体标签(多个标签用逗号分隔)</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-tag-input
|
||||
v-model="localNodeExtract.tags"
|
||||
placeholder="输入标签后按回车"
|
||||
@change="handleConfigChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import ModelSelector from '@/components/ModelSelector.vue'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
|
||||
const uiStore = useUIStore()
|
||||
|
||||
interface MultimodalConfig {
|
||||
enabled: boolean
|
||||
storageType: 'minio' | 'cos'
|
||||
vllmModelId?: string
|
||||
minio: {
|
||||
bucketName: string
|
||||
useSSL: boolean
|
||||
pathPrefix: string
|
||||
}
|
||||
cos: {
|
||||
secretId: string
|
||||
secretKey: string
|
||||
region: string
|
||||
bucketName: string
|
||||
appId: string
|
||||
pathPrefix: string
|
||||
}
|
||||
}
|
||||
|
||||
interface NodeExtractConfig {
|
||||
enabled: boolean
|
||||
text: string
|
||||
tags: string[]
|
||||
}
|
||||
|
||||
interface Props {
|
||||
multimodal: MultimodalConfig
|
||||
nodeExtract: NodeExtractConfig
|
||||
allModels?: any[]
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:multimodal': [value: MultimodalConfig]
|
||||
'update:nodeExtract': [value: NodeExtractConfig]
|
||||
}>()
|
||||
|
||||
const localMultimodal = ref<MultimodalConfig>({ ...props.multimodal })
|
||||
const localNodeExtract = ref<NodeExtractConfig>({ ...props.nodeExtract })
|
||||
|
||||
const vllmSelectorRef = ref()
|
||||
|
||||
// 监听props变化
|
||||
watch(() => props.multimodal, (newVal) => {
|
||||
localMultimodal.value = { ...newVal }
|
||||
}, { deep: true })
|
||||
|
||||
watch(() => props.nodeExtract, (newVal) => {
|
||||
localNodeExtract.value = { ...newVal }
|
||||
}, { deep: true })
|
||||
|
||||
// 处理多模态开关
|
||||
const handleMultimodalToggle = () => {
|
||||
// 如果关闭多模态,清空相关配置
|
||||
if (!localMultimodal.value.enabled) {
|
||||
localMultimodal.value.vllmModelId = ''
|
||||
localMultimodal.value.minio = {
|
||||
bucketName: '',
|
||||
useSSL: false,
|
||||
pathPrefix: ''
|
||||
}
|
||||
localMultimodal.value.cos = {
|
||||
secretId: '',
|
||||
secretKey: '',
|
||||
region: '',
|
||||
bucketName: '',
|
||||
appId: '',
|
||||
pathPrefix: ''
|
||||
}
|
||||
}
|
||||
emit('update:multimodal', localMultimodal.value)
|
||||
}
|
||||
|
||||
// 处理存储类型变化
|
||||
const handleStorageTypeChange = () => {
|
||||
emit('update:multimodal', localMultimodal.value)
|
||||
}
|
||||
|
||||
// 处理VLLM模型变化
|
||||
const handleVLLMChange = (modelId: string) => {
|
||||
localMultimodal.value.vllmModelId = modelId
|
||||
emit('update:multimodal', localMultimodal.value)
|
||||
}
|
||||
|
||||
// 处理添加模型
|
||||
const handleAddModel = (subSection: string) => {
|
||||
uiStore.openSettings('models', subSection)
|
||||
}
|
||||
|
||||
// 处理知识图谱开关
|
||||
const handleNodeExtractToggle = () => {
|
||||
emit('update:nodeExtract', localNodeExtract.value)
|
||||
}
|
||||
|
||||
// 处理配置变化
|
||||
const handleConfigChange = () => {
|
||||
emit('update:multimodal', localMultimodal.value)
|
||||
emit('update:nodeExtract', localNodeExtract.value)
|
||||
}
|
||||
|
||||
// 由于使用了 allModels prop,不再需要单独刷新
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.kb-advanced-settings {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 32px;
|
||||
|
||||
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.5;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.setting-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
padding: 20px 0;
|
||||
border-bottom: 1px solid var(--td-component-border);
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-info {
|
||||
flex: 1;
|
||||
max-width: 65%;
|
||||
padding-right: 24px;
|
||||
|
||||
label {
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.desc {
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-control {
|
||||
flex-shrink: 0;
|
||||
min-width: 280px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.subsection {
|
||||
padding: 16px 20px;
|
||||
margin: 12px 0 0 0;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-radius: 8px;
|
||||
border-left: 3px solid var(--td-brand-color);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.subsection-header {
|
||||
margin: 16px 0 8px 0;
|
||||
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-primary);
|
||||
margin: 0;
|
||||
padding-left: 8px;
|
||||
border-left: 2px solid var(--td-brand-color);
|
||||
|
||||
.required {
|
||||
color: var(--td-error-color);
|
||||
margin-left: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.required {
|
||||
color: var(--td-error-color);
|
||||
margin-left: 2px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.storage-config {
|
||||
margin-top: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
<template>
|
||||
<div class="kb-basic-info">
|
||||
<div class="section-header">
|
||||
<h2>基本信息</h2>
|
||||
<p class="section-description">配置知识库的基本信息</p>
|
||||
</div>
|
||||
|
||||
<div class="settings-group">
|
||||
<!-- 知识库名称 -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>知识库名称 <span class="required">*</span></label>
|
||||
<p class="desc">知识库的显示名称(最多50个字符)</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-input
|
||||
v-model="localName"
|
||||
placeholder="请输入知识库名称"
|
||||
maxlength="50"
|
||||
show-word-limit
|
||||
@blur="handleNameChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 知识库描述 -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>知识库描述</label>
|
||||
<p class="desc">知识库的详细描述信息(最多200个字符)</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-textarea
|
||||
v-model="localDescription"
|
||||
placeholder="请输入知识库描述"
|
||||
maxlength="200"
|
||||
show-word-limit
|
||||
:autosize="{ minRows: 3, maxRows: 6 }"
|
||||
@blur="handleDescriptionChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { updateKnowledgeBase } from '@/api/knowledge-base'
|
||||
|
||||
interface Props {
|
||||
kbId: string
|
||||
name: string
|
||||
description?: string
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:name': [value: string]
|
||||
'update:description': [value: string]
|
||||
}>()
|
||||
|
||||
const localName = ref(props.name)
|
||||
const localDescription = ref(props.description || '')
|
||||
const saving = ref(false)
|
||||
|
||||
// 监听props变化
|
||||
watch(() => props.name, (newVal) => {
|
||||
localName.value = newVal
|
||||
})
|
||||
|
||||
watch(() => props.description, (newVal) => {
|
||||
localDescription.value = newVal || ''
|
||||
})
|
||||
|
||||
// 保存基本信息
|
||||
const saveBasicInfo = async () => {
|
||||
if (saving.value) return
|
||||
|
||||
if (!localName.value.trim()) {
|
||||
MessagePlugin.warning('知识库名称不能为空')
|
||||
return
|
||||
}
|
||||
|
||||
saving.value = true
|
||||
try {
|
||||
await updateKnowledgeBase(props.kbId, {
|
||||
name: localName.value,
|
||||
description: localDescription.value,
|
||||
config: {} // 这里只更新基本信息,不更新配置
|
||||
})
|
||||
|
||||
emit('update:name', localName.value)
|
||||
emit('update:description', localDescription.value)
|
||||
MessagePlugin.success('保存成功')
|
||||
} catch (error) {
|
||||
console.error('保存知识库基本信息失败:', error)
|
||||
MessagePlugin.error('保存失败')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 处理名称变化
|
||||
const handleNameChange = () => {
|
||||
if (localName.value !== props.name) {
|
||||
saveBasicInfo()
|
||||
}
|
||||
}
|
||||
|
||||
// 处理描述变化
|
||||
const handleDescriptionChange = () => {
|
||||
if (localDescription.value !== props.description) {
|
||||
saveBasicInfo()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.kb-basic-info {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 32px;
|
||||
|
||||
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.5;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.setting-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
padding: 20px 0;
|
||||
border-bottom: 1px solid var(--td-component-border);
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-info {
|
||||
flex: 1;
|
||||
max-width: 65%;
|
||||
padding-right: 24px;
|
||||
|
||||
label {
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
|
||||
.required {
|
||||
color: var(--td-error-color);
|
||||
margin-left: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.desc {
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-control {
|
||||
flex-shrink: 0;
|
||||
min-width: 280px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
<template>
|
||||
<div class="kb-chunking-settings">
|
||||
<div class="section-header">
|
||||
<h2>分块设置</h2>
|
||||
<p class="section-description">配置文档分块参数,优化检索效果</p>
|
||||
</div>
|
||||
|
||||
<div class="settings-group">
|
||||
<!-- Chunk Size -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>分块大小</label>
|
||||
<p class="desc">控制每个文档分块的字符数(100-4000)</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<div class="slider-container">
|
||||
<t-slider
|
||||
v-model="localChunkSize"
|
||||
:min="100"
|
||||
:max="4000"
|
||||
:step="50"
|
||||
:marks="{ 100: '100', 1000: '1000', 2000: '2000', 4000: '4000' }"
|
||||
@change="handleChunkSizeChange"
|
||||
style="width: 200px;"
|
||||
/>
|
||||
<span class="value-display">{{ localChunkSize }} 字符</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Chunk Overlap -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>分块重叠</label>
|
||||
<p class="desc">相邻文档块之间的重叠字符数(0-500)</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<div class="slider-container">
|
||||
<t-slider
|
||||
v-model="localChunkOverlap"
|
||||
:min="0"
|
||||
:max="500"
|
||||
:step="20"
|
||||
:marks="{ 0: '0', 250: '250', 500: '500' }"
|
||||
@change="handleChunkOverlapChange"
|
||||
style="width: 200px;"
|
||||
/>
|
||||
<span class="value-display">{{ localChunkOverlap }} 字符</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 分隔符 -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>分隔符</label>
|
||||
<p class="desc">文档分块时使用的分隔符</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-select
|
||||
v-model="localSeparators"
|
||||
:options="separatorOptions"
|
||||
multiple
|
||||
placeholder="选择分隔符"
|
||||
@change="handleSeparatorsChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
interface ChunkingConfig {
|
||||
chunkSize: number
|
||||
chunkOverlap: number
|
||||
separators: string[]
|
||||
}
|
||||
|
||||
interface Props {
|
||||
config: ChunkingConfig
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:config': [value: ChunkingConfig]
|
||||
}>()
|
||||
|
||||
const localChunkSize = ref(props.config.chunkSize)
|
||||
const localChunkOverlap = ref(props.config.chunkOverlap)
|
||||
const localSeparators = ref([...props.config.separators])
|
||||
|
||||
// 分隔符选项
|
||||
const separatorOptions = [
|
||||
{ label: '双换行 (\\n\\n)', value: '\n\n' },
|
||||
{ label: '单换行 (\\n)', value: '\n' },
|
||||
{ label: '中文句号 (。)', value: '。' },
|
||||
{ label: '感叹号 (!)', value: '!' },
|
||||
{ label: '问号 (?)', value: '?' },
|
||||
{ label: '中文分号 (;)', value: ';' },
|
||||
{ label: '英文分号 (;)', value: ';' },
|
||||
{ label: '空格 ( )', value: ' ' }
|
||||
]
|
||||
|
||||
// 监听props变化
|
||||
watch(() => props.config, (newConfig) => {
|
||||
localChunkSize.value = newConfig.chunkSize
|
||||
localChunkOverlap.value = newConfig.chunkOverlap
|
||||
localSeparators.value = [...newConfig.separators]
|
||||
}, { deep: true })
|
||||
|
||||
// 处理分块大小变化
|
||||
const handleChunkSizeChange = () => {
|
||||
emitUpdate()
|
||||
}
|
||||
|
||||
// 处理分块重叠变化
|
||||
const handleChunkOverlapChange = () => {
|
||||
emitUpdate()
|
||||
}
|
||||
|
||||
// 处理分隔符变化
|
||||
const handleSeparatorsChange = () => {
|
||||
emitUpdate()
|
||||
}
|
||||
|
||||
// 发出更新事件
|
||||
const emitUpdate = () => {
|
||||
emit('update:config', {
|
||||
chunkSize: localChunkSize.value,
|
||||
chunkOverlap: localChunkOverlap.value,
|
||||
separators: localSeparators.value
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.kb-chunking-settings {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 32px;
|
||||
|
||||
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.5;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.setting-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
padding: 20px 0;
|
||||
border-bottom: 1px solid var(--td-component-border);
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-info {
|
||||
flex: 1;
|
||||
max-width: 65%;
|
||||
padding-right: 24px;
|
||||
|
||||
label {
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.desc {
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-control {
|
||||
flex-shrink: 0;
|
||||
min-width: 280px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.slider-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
width: 100%;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.value-display {
|
||||
font-size: 14px;
|
||||
color: var(--td-text-color-primary);
|
||||
font-weight: 500;
|
||||
min-width: 80px;
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,217 @@
|
||||
<template>
|
||||
<div class="kb-model-config">
|
||||
<div class="section-header">
|
||||
<h2>模型配置</h2>
|
||||
<p class="section-description">为知识库选择合适的AI模型</p>
|
||||
</div>
|
||||
|
||||
<div class="settings-group">
|
||||
<!-- LLM 大语言模型 -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>LLM 大语言模型 <span class="required">*</span></label>
|
||||
<p class="desc">用于对话和问答的大语言模型</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<ModelSelector
|
||||
ref="llmSelectorRef"
|
||||
model-type="KnowledgeQA"
|
||||
:selected-model-id="config.llmModelId"
|
||||
:all-models="allModels"
|
||||
@update:selected-model-id="handleLLMChange"
|
||||
@add-model="handleAddModel('chat')"
|
||||
placeholder="请选择LLM模型"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Embedding 嵌入模型 -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>Embedding 嵌入模型 <span class="required">*</span></label>
|
||||
<p class="desc">用于文本向量化的嵌入模型</p>
|
||||
<t-alert
|
||||
v-if="hasFiles"
|
||||
theme="warning"
|
||||
message="知识库中已有文件,无法修改Embedding模型"
|
||||
style="margin-top: 8px;"
|
||||
/>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<ModelSelector
|
||||
ref="embeddingSelectorRef"
|
||||
model-type="Embedding"
|
||||
:selected-model-id="config.embeddingModelId"
|
||||
:all-models="allModels"
|
||||
:disabled="hasFiles"
|
||||
@update:selected-model-id="handleEmbeddingChange"
|
||||
@add-model="handleAddModel('embedding')"
|
||||
placeholder="请选择Embedding模型"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ReRank 重排序模型 -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>ReRank 重排序模型</label>
|
||||
<p class="desc">用于搜索结果重排序的模型(可选)</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<ModelSelector
|
||||
ref="rerankSelectorRef"
|
||||
model-type="Rerank"
|
||||
:selected-model-id="config.rerankModelId"
|
||||
:all-models="allModels"
|
||||
@update:selected-model-id="handleRerankChange"
|
||||
@add-model="handleAddModel('rerank')"
|
||||
placeholder="请选择ReRank模型(可选)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
import ModelSelector from '@/components/ModelSelector.vue'
|
||||
|
||||
interface ModelConfig {
|
||||
llmModelId?: string
|
||||
embeddingModelId?: string
|
||||
rerankModelId?: string
|
||||
vllmModelId?: string
|
||||
}
|
||||
|
||||
interface Props {
|
||||
config: ModelConfig
|
||||
hasFiles: boolean
|
||||
allModels?: any[]
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:config': [value: ModelConfig]
|
||||
}>()
|
||||
|
||||
const uiStore = useUIStore()
|
||||
|
||||
// 引用各个模型选择器
|
||||
const llmSelectorRef = ref<InstanceType<typeof ModelSelector>>()
|
||||
const embeddingSelectorRef = ref<InstanceType<typeof ModelSelector>>()
|
||||
const rerankSelectorRef = ref<InstanceType<typeof ModelSelector>>()
|
||||
|
||||
// 处理LLM模型变化
|
||||
const handleLLMChange = (modelId: string) => {
|
||||
emit('update:config', {
|
||||
...props.config,
|
||||
llmModelId: modelId
|
||||
})
|
||||
}
|
||||
|
||||
// 处理Embedding模型变化
|
||||
const handleEmbeddingChange = (modelId: string) => {
|
||||
emit('update:config', {
|
||||
...props.config,
|
||||
embeddingModelId: modelId
|
||||
})
|
||||
}
|
||||
|
||||
// 处理ReRank模型变化
|
||||
const handleRerankChange = (modelId: string) => {
|
||||
emit('update:config', {
|
||||
...props.config,
|
||||
rerankModelId: modelId
|
||||
})
|
||||
}
|
||||
|
||||
// 处理添加模型按钮点击
|
||||
const handleAddModel = (subSection: string) => {
|
||||
// 打开全局设置对话框,并导航到对应的模型子页面
|
||||
uiStore.openSettings('models', subSection)
|
||||
}
|
||||
|
||||
// 由于使用了 allModels prop,不再需要单独刷新各个选择器
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.kb-model-config {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 32px;
|
||||
|
||||
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.5;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.setting-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
padding: 20px 0;
|
||||
border-bottom: 1px solid var(--td-component-border);
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-info {
|
||||
flex: 1;
|
||||
max-width: 65%;
|
||||
padding-right: 24px;
|
||||
|
||||
label {
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
|
||||
.required {
|
||||
color: var(--td-error-color);
|
||||
margin-left: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.desc {
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-control {
|
||||
flex-shrink: 0;
|
||||
min-width: 280px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: flex-start;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user