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:
@@ -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