feat: enhance multimodal support and image handling

- Updated configuration to improve handling of multimodal queries, including clearer guidelines for when to use [NO_SEARCH] in responses.
- Enhanced the user interface to include dedicated sections for multimodal configuration, allowing users to manage image uploads and related settings more effectively.
- Added localization support for new multimodal features in both English and Chinese, improving accessibility for a broader audience.
- Implemented backend changes to support image analysis and extraction of OCR text, enriching the interaction experience for users.

These enhancements significantly improve the application's capability to process and respond to multimodal queries, fostering a more interactive and user-friendly environment.
This commit is contained in:
wizardchen
2026-03-11 21:16:23 +08:00
parent 3a197f3333
commit bc2cb96d70
20 changed files with 467 additions and 247 deletions
+9 -1
View File
@@ -1409,6 +1409,7 @@ export default {
advanced: 'Advanced Settings',
faq: 'FAQ Settings',
graph: 'Knowledge Graph',
multimodal: 'Multimodal',
share: 'Sharing'
},
basic: {
@@ -1610,9 +1611,13 @@ export default {
childChunkSizeLabel: 'Child Chunk Size',
childChunkSizeDescription: 'Size of child chunks used for embedding matching (64-1024)'
},
multimodal: {
title: 'Multimodal Configuration',
description: 'Configure multimodal content understanding for parsing and retrieving non-text content like images',
},
advanced: {
title: 'Advanced Settings',
description: 'Configure question generation, multimodal features',
description: 'Configure question generation and other advanced features',
questionGeneration: {
label: 'AI Question Generation',
description: 'Generate related questions for each chunk using LLM during document parsing to improve retrieval recall. Enabling this will increase document parsing time.',
@@ -3248,6 +3253,9 @@ export default {
selectPlaceholder: 'Select MCP services',
},
imageUpload: {
navLabel: 'Multimodal',
sectionTitle: 'Multimodal Configuration',
sectionDesc: 'Configure image upload and vision-language model for multimodal conversations',
label: 'Image Upload',
desc: 'Allow users to upload images for multimodal Q&A in conversations',
vlmModel: 'VLM Model',
+9 -1
View File
@@ -1868,6 +1868,7 @@ export default {
advanced: "高级设置",
faq: "FAQ 设置",
graph: "知识图谱",
multimodal: "多模态",
share: "共享管理",
},
basic: {
@@ -2066,9 +2067,13 @@ export default {
childChunkSizeLabel: "子块大小",
childChunkSizeDescription: "用于向量匹配的子块字符数(64-1024)",
},
multimodal: {
title: "多模态配置",
description: "配置多模态内容理解能力,启用后支持图片等非文本内容的解析和检索",
},
advanced: {
title: "高级设置",
description: "配置问题生成、多模态等高级功能",
description: "配置问题生成等高级功能",
questionGeneration: {
label: "AI 问题生成",
description: "解析文档时调用大模型为每个分块生成相关问题,提高检索召回率。启用后会增加文档解析耗时。",
@@ -3246,6 +3251,9 @@ export default {
selectPlaceholder: "选择 MCP 服务",
},
imageUpload: {
navLabel: "多模态",
sectionTitle: "多模态配置",
sectionDesc: "配置图片上传和视觉语言模型,启用后用户可在对话中上传图片",
label: "图片上传",
desc: "启用后用户可在对话中上传图片进行多模态问答",
vlmModel: "VLM 模型",
+14 -1
View File
@@ -319,6 +319,17 @@
</div>
</div>
</div>
</div>
<!-- 多模态配置 -->
<div v-show="currentSection === 'multimodal'" class="section">
<div class="section-header">
<h2>{{ $t('agentEditor.imageUpload.sectionTitle') }}</h2>
<p class="section-description">{{ $t('agentEditor.imageUpload.sectionDesc') }}</p>
</div>
<div class="settings-group">
<!-- 图片上传(多模态) -->
<div class="setting-row">
<div class="setting-info">
@@ -1357,6 +1368,8 @@ const navItems = computed(() => {
}
// 网络搜索(独立菜单)
items.push({ key: 'websearch', icon: 'internet', label: t('agent.editor.webSearchConfig') });
// 多模态配置(图片上传)
items.push({ key: 'multimodal', icon: 'image', label: t('agentEditor.imageUpload.navLabel') });
// 多轮对话(仅普通模式显示,Agent模式内部自动控制)
if (!isAgentMode.value) {
items.push({ key: 'conversation', icon: 'chat', label: t('agent.editor.conversationSettings') });
@@ -2727,7 +2740,7 @@ const handleSave = async () => {
// 校验 VLM 模型(当图片上传启用时必填)
if (formData.value.config.image_upload_enabled && !formData.value.config.vlm_model_id) {
MessagePlugin.error(t('agentEditor.imageUpload.vlmModelRequired'));
currentSection.value = 'model';
currentSection.value = 'multimodal';
return;
}
@@ -155,15 +155,58 @@
/>
</div>
<!-- 多模态配置 -->
<div v-if="!isFAQ" v-show="currentSection === 'multimodal'" class="section">
<div v-if="formData" class="kb-multimodal-settings">
<div class="section-header">
<h2>{{ $t('knowledgeEditor.multimodal.title') }}</h2>
<p class="section-description">{{ $t('knowledgeEditor.multimodal.description') }}</p>
</div>
<div class="settings-group">
<!-- 多模态开关 -->
<div class="setting-row">
<div class="setting-info">
<label>{{ $t('knowledgeEditor.advanced.multimodal.label') }}</label>
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.description') }}</p>
</div>
<div class="setting-control">
<t-switch
v-model="formData.multimodalConfig.enabled"
@change="handleMultimodalToggle"
size="medium"
/>
</div>
</div>
<!-- VLLM 模型选择(多模态启用时) -->
<div v-if="formData.multimodalConfig.enabled" class="setting-row">
<div class="setting-info">
<label>{{ $t('knowledgeEditor.advanced.multimodal.vllmLabel') }} <span class="required">*</span></label>
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.vllmDescription') }}</p>
</div>
<div class="setting-control">
<ModelSelector
model-type="VLLM"
:selected-model-id="formData.multimodalConfig.vllmModelId"
:all-models="allModels"
@update:selected-model-id="handleMultimodalVLLMChange"
@add-model="handleAddVLLMModel"
:placeholder="$t('knowledgeEditor.advanced.multimodal.vllmPlaceholder')"
/>
</div>
</div>
</div>
</div>
</div>
<!-- 高级设置 -->
<div v-if="!isFAQ" v-show="currentSection === 'advanced'" class="section">
<KBAdvancedSettings
ref="advancedSettingsRef"
v-if="formData"
:multimodal="formData.multimodalConfig"
:question-generation="formData.questionGenerationConfig"
:all-models="allModels"
@update:multimodal="handleMultimodalUpdate"
@update:question-generation="handleQuestionGenerationUpdate"
/>
</div>
@@ -203,6 +246,7 @@ import KBParserSettings from './settings/KBParserSettings.vue'
import KBStorageSettings from './settings/KBStorageSettings.vue'
import KBChunkingSettings from './settings/KBChunkingSettings.vue'
import KBAdvancedSettings from './settings/KBAdvancedSettings.vue'
import ModelSelector from '@/components/ModelSelector.vue'
import GraphSettings from './settings/GraphSettings.vue'
import KBShareSettings from './settings/KBShareSettings.vue'
import { useI18n } from 'vue-i18n'
@@ -244,6 +288,7 @@ const navItems = computed(() => {
{ key: 'storage', icon: 'cloud', label: t('knowledgeEditor.sidebar.storage') },
{ key: 'chunking', icon: 'file-copy', label: t('knowledgeEditor.sidebar.chunking') },
{ key: 'graph', icon: 'chart-bubble', label: t('knowledgeEditor.sidebar.graph') },
{ key: 'multimodal', icon: 'image', label: t('knowledgeEditor.sidebar.multimodal') },
{ key: 'advanced', icon: 'setting', label: t('knowledgeEditor.sidebar.advanced') }
)
}
@@ -431,12 +476,22 @@ const handleParserEngineRulesUpdate = (rules: any[]) => {
}
}
const handleMultimodalUpdate = (config: any) => {
if (formData.value) {
formData.value.multimodalConfig = { ...config }
const handleMultimodalToggle = () => {
if (formData.value && !formData.value.multimodalConfig.enabled) {
formData.value.multimodalConfig.vllmModelId = ''
}
}
const handleMultimodalVLLMChange = (modelId: string) => {
if (formData.value) {
formData.value.multimodalConfig.vllmModelId = modelId
}
}
const handleAddVLLMModel = () => {
uiStore.openSettings('models', 'vllm')
}
const handleStorageProviderUpdate = (value: string) => {
if (formData.value) {
formData.value.storageProvider = value || 'local'
@@ -480,13 +535,10 @@ const validateForm = (): boolean => {
}
// 验证多模态配置(如果启用)
if (formData.value.multimodalConfig.enabled) {
const validation = (advancedSettingsRef.value as any)?.validateMultimodal?.()
if (validation && !validation.valid) {
MessagePlugin.warning(validation.message || t('knowledgeEditor.messages.multimodalInvalid'))
currentSection.value = 'advanced'
return false
}
if (formData.value.multimodalConfig.enabled && !formData.value.multimodalConfig.vllmModelId) {
MessagePlugin.warning(t('knowledgeEditor.messages.multimodalInvalid'))
currentSection.value = 'multimodal'
return false
}
if (formData.value.type === 'faq' && !formData.value.faqConfig?.indexMode) {
@@ -1014,5 +1066,80 @@ watch(
}
}
}
// 多模态配置内联样式(与子组件 KBStorageSettings/KBAdvancedSettings 一致)
.kb-multimodal-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;
}
.setting-row {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 20px 0;
border-bottom: 1px solid var(--td-component-stroke);
&: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;
}
.required {
color: var(--td-error-color);
margin-left: 2px;
font-weight: 500;
}
}
</style>
@@ -42,57 +42,12 @@
</div>
</div>
<!-- Multimodal feature:仅选择多模态模型,存储引擎在「存储引擎」页配置 -->
<div class="setting-row">
<div class="setting-info">
<label>{{ $t('knowledgeEditor.advanced.multimodal.label') }}</label>
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.description') }}</p>
</div>
<div class="setting-control">
<t-switch
v-model="localMultimodal.enabled"
@change="handleMultimodalToggle"
size="medium"
/>
</div>
</div>
<!-- 多模态开启时仅配置 VLLM 模型 -->
<div v-if="localMultimodal.enabled" class="subsection">
<div class="setting-row">
<div class="setting-info">
<label>{{ $t('knowledgeEditor.advanced.multimodal.vllmLabel') }} <span class="required">*</span></label>
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.vllmDescription') }}</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="$t('knowledgeEditor.advanced.multimodal.vllmPlaceholder')"
/>
</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
vllmModelId?: string
}
interface QuestionGenerationConfig {
enabled: boolean
@@ -100,7 +55,6 @@ interface QuestionGenerationConfig {
}
interface Props {
multimodal: MultimodalConfig
questionGeneration?: QuestionGenerationConfig
allModels?: any[]
}
@@ -108,21 +62,13 @@ interface Props {
const props = defineProps<Props>()
const emit = defineEmits<{
'update:multimodal': [value: MultimodalConfig]
'update:questionGeneration': [value: QuestionGenerationConfig]
}>()
const localMultimodal = ref<MultimodalConfig>({ ...props.multimodal })
const localQuestionGeneration = ref<QuestionGenerationConfig>(
props.questionGeneration || { enabled: false, questionCount: 3 }
)
const vllmSelectorRef = ref()
watch(() => props.multimodal, (newVal) => {
localMultimodal.value = { ...newVal }
}, { deep: true })
watch(() => props.questionGeneration, (newVal) => {
if (newVal) {
localQuestionGeneration.value = { ...newVal }
@@ -139,22 +85,6 @@ const handleQuestionGenerationToggle = () => {
const handleQuestionGenerationChange = () => {
emit('update:questionGeneration', localQuestionGeneration.value)
}
const handleMultimodalToggle = () => {
if (!localMultimodal.value.enabled) {
localMultimodal.value.vllmModelId = ''
}
emit('update:multimodal', localMultimodal.value)
}
const handleVLLMChange = (modelId: string) => {
localMultimodal.value.vllmModelId = modelId
emit('update:multimodal', localMultimodal.value)
}
const handleAddModel = (subSection: string) => {
uiStore.openSettings('models', subSection)
}
</script>
<style lang="less" scoped>
@@ -250,4 +180,3 @@ const handleAddModel = (subSection: string) => {
}
</style>