feat: Update VLM configuration in knowledge base and API documentation
- Replaced `vlm_model_id` with a structured `vlm_config` object in knowledge base configurations, including `enabled` flag and `model_id`. - Updated API documentation to reflect changes in VLM configuration structure. - Enhanced frontend interfaces to accommodate new VLM configuration format. - Improved localization for new features related to knowledge graph and multimodal capabilities.
This commit is contained in:
@@ -275,7 +275,17 @@ const initFormData = (type: 'document' | 'faq' = 'document') => {
|
||||
nodeExtractConfig: {
|
||||
enabled: false,
|
||||
text: '',
|
||||
tags: [] as string[]
|
||||
tags: [] as string[],
|
||||
nodes: [] as Array<{
|
||||
name: string
|
||||
chunks: string[]
|
||||
attributes: string[]
|
||||
}>,
|
||||
relations: [] as Array<{
|
||||
node1: string
|
||||
node2: string
|
||||
type: string
|
||||
}>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,9 +341,9 @@ const loadKBData = async () => {
|
||||
separators: kb.chunking_config?.separators || ['\n\n', '\n', '。', '!', '?', ';', ';']
|
||||
},
|
||||
multimodalConfig: {
|
||||
enabled: !!(kb.vlm_model_id || (kb.cos_config?.provider && kb.cos_config?.bucket_name)),
|
||||
enabled: !!(kb.vlm_config?.enabled || (kb.cos_config?.provider && kb.cos_config?.bucket_name)),
|
||||
storageType: (kb.cos_config?.provider || 'minio') as 'minio' | 'cos',
|
||||
vllmModelId: kb.vlm_model_id || '',
|
||||
vllmModelId: kb.vlm_config?.model_id || '',
|
||||
minio: {
|
||||
bucketName: kb.cos_config?.bucket_name || '',
|
||||
useSSL: kb.cos_config?.use_ssl || false,
|
||||
@@ -351,7 +361,9 @@ const loadKBData = async () => {
|
||||
nodeExtractConfig: {
|
||||
enabled: kb.extract_config?.enabled || false,
|
||||
text: kb.extract_config?.text || '',
|
||||
tags: kb.extract_config?.tags || []
|
||||
tags: kb.extract_config?.tags || [],
|
||||
nodes: kb.extract_config?.nodes || [],
|
||||
relations: kb.extract_config?.relations || []
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -450,11 +462,14 @@ const buildSubmitData = () => {
|
||||
}
|
||||
|
||||
// 添加多模态配置
|
||||
data.vlm_config = {
|
||||
enabled: formData.value.multimodalConfig.enabled,
|
||||
model_id: formData.value.multimodalConfig.enabled
|
||||
? (formData.value.multimodalConfig.vllmModelId || '')
|
||||
: ''
|
||||
}
|
||||
|
||||
if (formData.value.multimodalConfig.enabled) {
|
||||
if (formData.value.multimodalConfig.vllmModelId) {
|
||||
data.vlm_model_id = formData.value.multimodalConfig.vllmModelId
|
||||
}
|
||||
|
||||
const storageType = formData.value.multimodalConfig.storageType
|
||||
if (storageType === 'minio') {
|
||||
data.cos_config = {
|
||||
@@ -481,7 +496,9 @@ const buildSubmitData = () => {
|
||||
data.extract_config = {
|
||||
enabled: true,
|
||||
text: formData.value.nodeExtractConfig.text,
|
||||
tags: formData.value.nodeExtractConfig.tags
|
||||
tags: formData.value.nodeExtractConfig.tags,
|
||||
nodes: formData.value.nodeExtractConfig.nodes,
|
||||
relations: formData.value.nodeExtractConfig.relations
|
||||
}
|
||||
}
|
||||
|
||||
@@ -540,14 +557,14 @@ const handleSubmit = async () => {
|
||||
const config: KBModelConfigRequest = {
|
||||
llmModelId: data.summary_model_id,
|
||||
embeddingModelId: data.embedding_model_id,
|
||||
vllmModelId: data.vlm_model_id || '',
|
||||
vlm_config: data.vlm_config,
|
||||
documentSplitting: {
|
||||
chunkSize: data.chunking_config.chunk_size,
|
||||
chunkOverlap: data.chunking_config.chunk_overlap,
|
||||
separators: data.chunking_config.separators
|
||||
},
|
||||
multimodal: {
|
||||
enabled: !!data.cos_config,
|
||||
enabled: !!data.cos_config || !!data.vlm_config?.enabled,
|
||||
storageType: data.cos_config?.provider || 'minio',
|
||||
cos: data.cos_config?.provider === 'cos' ? {
|
||||
secretId: data.cos_config.secret_id,
|
||||
|
||||
@@ -71,9 +71,23 @@
|
||||
|
||||
<!-- 卡片底部 -->
|
||||
<div class="card-bottom">
|
||||
<div class="type-badge" :class="{ 'document': (kb.type || 'document') === 'document', 'faq': kb.type === 'faq' }">
|
||||
<t-icon :name="kb.type === 'faq' ? 'chat-bubble-help' : 'folder'" size="14px" />
|
||||
<span>{{ kb.type === 'faq' ? $t('knowledgeEditor.basic.typeFAQ') : $t('knowledgeEditor.basic.typeDocument') }}</span>
|
||||
<div class="bottom-left">
|
||||
<div class="type-badge" :class="{ 'document': (kb.type || 'document') === 'document', 'faq': kb.type === 'faq' }">
|
||||
<t-icon :name="kb.type === 'faq' ? 'chat-bubble-help' : 'folder'" size="14px" />
|
||||
<span>{{ kb.type === 'faq' ? $t('knowledgeEditor.basic.typeFAQ') : $t('knowledgeEditor.basic.typeDocument') }}</span>
|
||||
</div>
|
||||
<div class="feature-badges">
|
||||
<t-tooltip v-if="kb.extract_config?.enabled" :content="$t('knowledgeList.features.knowledgeGraph')" placement="top">
|
||||
<div class="feature-badge kg">
|
||||
<t-icon name="relation" size="14px" />
|
||||
</div>
|
||||
</t-tooltip>
|
||||
<t-tooltip v-if="kb.vlm_config?.enabled || (kb.cos_config?.provider && kb.cos_config?.bucket_name)" :content="$t('knowledgeList.features.multimodal')" placement="top">
|
||||
<div class="feature-badge multimodal">
|
||||
<t-icon name="image" size="14px" />
|
||||
</div>
|
||||
</t-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<span class="card-time">{{ kb.updated_at }}</span>
|
||||
</div>
|
||||
@@ -150,6 +164,9 @@ interface KB {
|
||||
summary_model_id?: string;
|
||||
type?: 'document' | 'faq';
|
||||
showMore?: boolean;
|
||||
vlm_config?: { enabled?: boolean; model_id?: string };
|
||||
extract_config?: { enabled?: boolean };
|
||||
cos_config?: { provider?: string; bucket_name?: string };
|
||||
}
|
||||
|
||||
const kbs = ref<KB[]>([])
|
||||
@@ -483,6 +500,12 @@ const handleKBEditorSuccess = (kbId: string) => {
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
.bottom-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.type-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -507,6 +530,42 @@ const handleKBEditorSuccess = (kbId: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
.feature-badges {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.feature-badge {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
|
||||
&.kg {
|
||||
background: rgba(124, 77, 255, 0.1);
|
||||
color: #7c4dff;
|
||||
border: 1px solid rgba(124, 77, 255, 0.2);
|
||||
|
||||
&:hover {
|
||||
background: rgba(124, 77, 255, 0.15);
|
||||
}
|
||||
}
|
||||
|
||||
&.multimodal {
|
||||
background: rgba(255, 152, 0, 0.1);
|
||||
color: #ff9800;
|
||||
border: 1px solid rgba(255, 152, 0, 0.2);
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 152, 0, 0.15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.card-time {
|
||||
color: #00000066;
|
||||
font-family: "PingFang SC";
|
||||
|
||||
@@ -219,11 +219,11 @@
|
||||
<t-alert
|
||||
v-if="!isGraphDatabaseEnabled"
|
||||
theme="warning"
|
||||
:message="$t('knowledgeEditor.advanced.graph.disabledWarning')"
|
||||
style="margin-top: 8px;"
|
||||
>
|
||||
<template #operation>
|
||||
<t-link theme="primary" @click="handleOpenSystemInfo">
|
||||
<template #message>
|
||||
<div>{{ $t('knowledgeEditor.advanced.graph.disabledWarning') }}</div>
|
||||
<t-link class="graph-guide-link" theme="primary" @click="handleOpenGraphGuide">
|
||||
{{ $t('knowledgeEditor.advanced.graph.howToEnable') }}
|
||||
</t-link>
|
||||
</template>
|
||||
@@ -275,6 +275,132 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Nodes Configuration -->
|
||||
<div class="subsection-header">
|
||||
<h4>{{ $t('knowledgeEditor.advanced.graph.nodesLabel') }}</h4>
|
||||
<p class="subsection-desc">{{ $t('knowledgeEditor.advanced.graph.nodesDescription') }}</p>
|
||||
</div>
|
||||
|
||||
<div v-for="(node, index) in localNodeExtract.nodes" :key="index" class="config-item">
|
||||
<div class="config-item-header">
|
||||
<span class="config-item-title">节点 #{{ index + 1 }}</span>
|
||||
<t-button
|
||||
theme="danger"
|
||||
variant="text"
|
||||
size="small"
|
||||
@click="removeNode(index)"
|
||||
>
|
||||
{{ $t('knowledgeEditor.advanced.graph.deleteNode') }}
|
||||
</t-button>
|
||||
</div>
|
||||
|
||||
<div class="config-item-body">
|
||||
<div class="config-field">
|
||||
<label>{{ $t('knowledgeEditor.advanced.graph.nodeNameLabel') }}</label>
|
||||
<t-input
|
||||
v-model="node.name"
|
||||
:placeholder="$t('knowledgeEditor.advanced.graph.nodeNamePlaceholder')"
|
||||
@change="handleConfigChange"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="config-field">
|
||||
<label>{{ $t('knowledgeEditor.advanced.graph.nodeChunksLabel') }}</label>
|
||||
<t-tag-input
|
||||
v-model="node.chunks"
|
||||
:placeholder="$t('knowledgeEditor.advanced.graph.nodeChunksPlaceholder')"
|
||||
@change="handleConfigChange"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="config-field">
|
||||
<label>{{ $t('knowledgeEditor.advanced.graph.nodeAttributesLabel') }}</label>
|
||||
<t-tag-input
|
||||
v-model="node.attributes"
|
||||
:placeholder="$t('knowledgeEditor.advanced.graph.nodeAttributesPlaceholder')"
|
||||
@change="handleConfigChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<t-button
|
||||
theme="primary"
|
||||
variant="outline"
|
||||
@click="addNode"
|
||||
style="margin-top: 12px;"
|
||||
>
|
||||
<template #icon>
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
||||
<path d="M8 2a1 1 0 011 1v4h4a1 1 0 110 2H9v4a1 1 0 11-2 0V9H3a1 1 0 110-2h4V3a1 1 0 011-1z"/>
|
||||
</svg>
|
||||
</template>
|
||||
{{ $t('knowledgeEditor.advanced.graph.addNode') }}
|
||||
</t-button>
|
||||
|
||||
<!-- Relations Configuration -->
|
||||
<div class="subsection-header" style="margin-top: 24px;">
|
||||
<h4>{{ $t('knowledgeEditor.advanced.graph.relationsLabel') }}</h4>
|
||||
<p class="subsection-desc">{{ $t('knowledgeEditor.advanced.graph.relationsDescription') }}</p>
|
||||
</div>
|
||||
|
||||
<div v-for="(relation, index) in localNodeExtract.relations" :key="index" class="config-item">
|
||||
<div class="config-item-header">
|
||||
<span class="config-item-title">关系 #{{ index + 1 }}</span>
|
||||
<t-button
|
||||
theme="danger"
|
||||
variant="text"
|
||||
size="small"
|
||||
@click="removeRelation(index)"
|
||||
>
|
||||
{{ $t('knowledgeEditor.advanced.graph.deleteRelation') }}
|
||||
</t-button>
|
||||
</div>
|
||||
|
||||
<div class="config-item-body">
|
||||
<div class="config-field">
|
||||
<label>{{ $t('knowledgeEditor.advanced.graph.relationNode1Label') }}</label>
|
||||
<t-input
|
||||
v-model="relation.node1"
|
||||
:placeholder="$t('knowledgeEditor.advanced.graph.relationNode1Placeholder')"
|
||||
@change="handleConfigChange"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="config-field">
|
||||
<label>{{ $t('knowledgeEditor.advanced.graph.relationNode2Label') }}</label>
|
||||
<t-input
|
||||
v-model="relation.node2"
|
||||
:placeholder="$t('knowledgeEditor.advanced.graph.relationNode2Placeholder')"
|
||||
@change="handleConfigChange"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="config-field">
|
||||
<label>{{ $t('knowledgeEditor.advanced.graph.relationTypeLabel') }}</label>
|
||||
<t-input
|
||||
v-model="relation.type"
|
||||
:placeholder="$t('knowledgeEditor.advanced.graph.relationTypePlaceholder')"
|
||||
@change="handleConfigChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<t-button
|
||||
theme="primary"
|
||||
variant="outline"
|
||||
@click="addRelation"
|
||||
style="margin-top: 12px;"
|
||||
>
|
||||
<template #icon>
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
||||
<path d="M8 2a1 1 0 011 1v4h4a1 1 0 110 2H9v4a1 1 0 11-2 0V9H3a1 1 0 110-2h4V3a1 1 0 011-1z"/>
|
||||
</svg>
|
||||
</template>
|
||||
{{ $t('knowledgeEditor.advanced.graph.addRelation') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -311,6 +437,16 @@ interface NodeExtractConfig {
|
||||
enabled: boolean
|
||||
text: string
|
||||
tags: string[]
|
||||
nodes: Array<{
|
||||
name: string
|
||||
chunks: string[]
|
||||
attributes: string[]
|
||||
}>
|
||||
relations: Array<{
|
||||
node1: string
|
||||
node2: string
|
||||
type: string
|
||||
}>
|
||||
}
|
||||
|
||||
interface Props {
|
||||
@@ -327,7 +463,11 @@ const emit = defineEmits<{
|
||||
}>()
|
||||
|
||||
const localMultimodal = ref<MultimodalConfig>({ ...props.multimodal })
|
||||
const localNodeExtract = ref<NodeExtractConfig>({ ...props.nodeExtract })
|
||||
const localNodeExtract = ref<NodeExtractConfig>({
|
||||
...props.nodeExtract,
|
||||
nodes: props.nodeExtract.nodes || [],
|
||||
relations: props.nodeExtract.relations || []
|
||||
})
|
||||
|
||||
const vllmSelectorRef = ref()
|
||||
const isGraphDatabaseEnabled = ref(false)
|
||||
@@ -391,7 +531,11 @@ watch(() => props.multimodal, (newVal) => {
|
||||
}, { deep: true })
|
||||
|
||||
watch(() => props.nodeExtract, (newVal) => {
|
||||
localNodeExtract.value = { ...newVal }
|
||||
localNodeExtract.value = {
|
||||
...newVal,
|
||||
nodes: newVal.nodes || [],
|
||||
relations: newVal.relations || []
|
||||
}
|
||||
}, { deep: true })
|
||||
|
||||
// Handle multimodal toggle
|
||||
@@ -436,6 +580,10 @@ const handleAddModel = (subSection: string) => {
|
||||
uiStore.openSettings('models', subSection)
|
||||
}
|
||||
|
||||
const graphGuideUrl =
|
||||
import.meta.env.VITE_KG_GUIDE_URL ||
|
||||
'https://github.com/Tencent/WeKnora/blob/main/docs/%E5%BC%80%E5%90%AF%E7%9F%A5%E8%AF%86%E5%9B%BE%E8%B0%B1%E5%8A%9F%E8%83%BD.md'
|
||||
|
||||
// Handle knowledge graph toggle
|
||||
const handleNodeExtractToggle = () => {
|
||||
// Prevent enabling if graph database is not enabled
|
||||
@@ -446,9 +594,9 @@ const handleNodeExtractToggle = () => {
|
||||
emit('update:nodeExtract', localNodeExtract.value)
|
||||
}
|
||||
|
||||
// Open system info page to show how to enable graph database
|
||||
const handleOpenSystemInfo = () => {
|
||||
uiStore.openSettings('system')
|
||||
// Open guide documentation to show how to enable graph database
|
||||
const handleOpenGraphGuide = () => {
|
||||
window.open(graphGuideUrl, '_blank', 'noopener')
|
||||
}
|
||||
|
||||
// Handle configuration change
|
||||
@@ -457,6 +605,44 @@ const handleConfigChange = () => {
|
||||
emit('update:nodeExtract', localNodeExtract.value)
|
||||
}
|
||||
|
||||
// Add a new node
|
||||
const addNode = () => {
|
||||
if (!localNodeExtract.value.nodes) {
|
||||
localNodeExtract.value.nodes = []
|
||||
}
|
||||
localNodeExtract.value.nodes.push({
|
||||
name: '',
|
||||
chunks: [],
|
||||
attributes: []
|
||||
})
|
||||
handleConfigChange()
|
||||
}
|
||||
|
||||
// Remove a node
|
||||
const removeNode = (index: number) => {
|
||||
localNodeExtract.value.nodes.splice(index, 1)
|
||||
handleConfigChange()
|
||||
}
|
||||
|
||||
// Add a new relation
|
||||
const addRelation = () => {
|
||||
if (!localNodeExtract.value.relations) {
|
||||
localNodeExtract.value.relations = []
|
||||
}
|
||||
localNodeExtract.value.relations.push({
|
||||
node1: '',
|
||||
node2: '',
|
||||
type: ''
|
||||
})
|
||||
handleConfigChange()
|
||||
}
|
||||
|
||||
// Remove a relation
|
||||
const removeRelation = (index: number) => {
|
||||
localNodeExtract.value.relations.splice(index, 1)
|
||||
handleConfigChange()
|
||||
}
|
||||
|
||||
// The allModels prop keeps model options in sync
|
||||
</script>
|
||||
|
||||
@@ -530,6 +716,11 @@ const handleConfigChange = () => {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.graph-guide-link {
|
||||
display: inline-block;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.subsection {
|
||||
padding: 16px 20px;
|
||||
margin: 12px 0 0 0;
|
||||
@@ -570,5 +761,54 @@ const handleConfigChange = () => {
|
||||
.storage-config {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.config-item {
|
||||
background: #ffffff;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 6px;
|
||||
padding: 16px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.config-item-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 16px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.config-item-title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.config-item-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.config-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
|
||||
label {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: #555555;
|
||||
}
|
||||
}
|
||||
|
||||
.subsection-desc {
|
||||
font-size: 13px;
|
||||
color: #666666;
|
||||
margin: 4px 0 8px 8px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user