feat: introduce WeKnora Lite edition with lightweight configuration and deployment
- Added a new `.env.lite.example` file for the Lite version, providing a minimal configuration template. - Updated `.env.example` to remove deprecated variables and include new Docreader settings. - Enhanced Docker configurations to support the Lite version, including a new Dockerfile for the Docreader service. - Introduced a Makefile target for building and running the Lite version, along with packaging capabilities. - Created GitHub workflows for building and releasing Lite binaries, including Homebrew formula support. - Implemented a new service file for managing the Lite version as a system service. This update enables a streamlined, single-binary deployment of WeKnora, reducing external dependencies and simplifying setup.
This commit is contained in:
@@ -31,6 +31,7 @@ import {
|
||||
import FAQEntryManager from './components/FAQEntryManager.vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { formatStringDate, kbFileTypeVerification } from '@/utils';
|
||||
import { getParserEngines, type ParserEngineInfo } from '@/api/system';
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
const kbId = computed(() => (route.params as any).kbId as string || '');
|
||||
@@ -40,6 +41,62 @@ const folderUploadInputRef = ref<HTMLInputElement | null>(null);
|
||||
const uploading = ref(false);
|
||||
const kbLoading = ref(false);
|
||||
const isFAQ = computed(() => (kbInfo.value?.type || '') === 'faq');
|
||||
const parserEngines = ref<ParserEngineInfo[]>([]);
|
||||
|
||||
const supportedFileTypes = computed<Set<string>>(() => {
|
||||
const engines = parserEngines.value
|
||||
if (!engines.length) return new Set<string>()
|
||||
|
||||
const rules: { file_types: string[]; engine: string }[] =
|
||||
kbInfo.value?.chunking_config?.parser_engine_rules || []
|
||||
|
||||
const ruleMap = new Map<string, string>()
|
||||
for (const r of rules) {
|
||||
for (const ft of r.file_types) ruleMap.set(ft, r.engine)
|
||||
}
|
||||
|
||||
const available = new Set<string>()
|
||||
const availableEngineNames = new Set(
|
||||
engines.filter(e => e.Available !== false).map(e => e.Name)
|
||||
)
|
||||
|
||||
for (const engine of engines) {
|
||||
for (const ft of engine.FileTypes || []) {
|
||||
if (available.has(ft)) continue
|
||||
|
||||
const explicitEngine = ruleMap.get(ft)
|
||||
if (explicitEngine) {
|
||||
if (availableEngineNames.has(explicitEngine)) available.add(ft)
|
||||
} else {
|
||||
if (engine.Available !== false) available.add(ft)
|
||||
}
|
||||
}
|
||||
}
|
||||
return available
|
||||
})
|
||||
|
||||
const acceptFileTypes = computed(() =>
|
||||
[...supportedFileTypes.value].map(t => '.' + t).join(',')
|
||||
)
|
||||
|
||||
const unsupportedFileTypes = computed<string[]>(() => {
|
||||
const engines = parserEngines.value
|
||||
if (!engines.length) return []
|
||||
|
||||
const allTypes = new Set<string>()
|
||||
for (const engine of engines) {
|
||||
for (const ft of engine.FileTypes || []) allTypes.add(ft)
|
||||
}
|
||||
|
||||
const supported = supportedFileTypes.value
|
||||
return [...allTypes].filter(ft => !supported.has(ft)).sort()
|
||||
})
|
||||
|
||||
const goToParserSettings = () => {
|
||||
if (kbId.value) {
|
||||
uiStore.openKBSettings(kbId.value, 'parser')
|
||||
}
|
||||
}
|
||||
|
||||
// Permission control: check if current user owns this KB or has edit/manage permission
|
||||
const isOwner = computed(() => {
|
||||
@@ -121,6 +178,8 @@ const fileTypeOptions = computed(() => [
|
||||
{ content: 'PDF', value: 'pdf' },
|
||||
{ content: 'DOCX', value: 'docx' },
|
||||
{ content: 'DOC', value: 'doc' },
|
||||
{ content: 'PPTX', value: 'pptx' },
|
||||
{ content: 'PPT', value: 'ppt' },
|
||||
{ content: 'TXT', value: 'txt' },
|
||||
{ content: 'MD', value: 'md' },
|
||||
{ content: 'URL', value: 'url' },
|
||||
@@ -564,15 +623,35 @@ const handleOpenURLImportDialog = (event: CustomEvent) => {
|
||||
}
|
||||
};
|
||||
|
||||
// Auto-open document detail when navigated with ?knowledge_id=xxx
|
||||
const pendingKnowledgeId = ref<string | null>(
|
||||
(route.query.knowledge_id as string) || null
|
||||
);
|
||||
|
||||
const tryAutoOpenDocument = () => {
|
||||
if (!pendingKnowledgeId.value || !cardList.value?.length) return;
|
||||
const targetId = pendingKnowledgeId.value;
|
||||
pendingKnowledgeId.value = null;
|
||||
const card = cardList.value.find((c: KnowledgeCard) => c.id === targetId);
|
||||
if (card) {
|
||||
nextTick(() => openCardDetails(card));
|
||||
} else {
|
||||
nextTick(() => {
|
||||
openCardDetails({ id: targetId } as KnowledgeCard);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
loadKnowledgeBaseInfo(kbId.value);
|
||||
loadKnowledgeList();
|
||||
// Load shared knowledge bases to get permission info
|
||||
orgStore.fetchSharedKnowledgeBases();
|
||||
|
||||
// 监听文件上传事件
|
||||
getParserEngines()
|
||||
.then(res => { parserEngines.value = res?.data || [] })
|
||||
.catch(() => { parserEngines.value = [] })
|
||||
|
||||
window.addEventListener('knowledgeFileUploaded', handleFileUploaded as EventListener);
|
||||
// 监听URL导入对话框打开事件
|
||||
window.addEventListener('openURLImportDialog', handleOpenURLImportDialog as EventListener);
|
||||
});
|
||||
|
||||
@@ -582,6 +661,12 @@ onUnmounted(() => {
|
||||
});
|
||||
watch(() => cardList.value, (newValue) => {
|
||||
if (isFAQ.value) return;
|
||||
|
||||
// Auto-open document if navigated with ?knowledge_id=xxx
|
||||
if (pendingKnowledgeId.value && newValue?.length) {
|
||||
tryAutoOpenDocument();
|
||||
}
|
||||
|
||||
let analyzeList = [];
|
||||
// Filter items that need polling: parsing in progress OR summary generation in progress
|
||||
analyzeList = newValue.filter(item => {
|
||||
@@ -780,21 +865,29 @@ const handleDocumentUpload = async (event: Event) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// 过滤有效文件
|
||||
const dynamicTypes = supportedFileTypes.value.size > 0 ? supportedFileTypes.value : undefined
|
||||
const validFiles: File[] = [];
|
||||
let skippedCount = 0;
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i];
|
||||
if (!kbFileTypeVerification(file, files.length > 1)) {
|
||||
if (!kbFileTypeVerification(file, files.length > 1, dynamicTypes)) {
|
||||
validFiles.push(file);
|
||||
} else {
|
||||
skippedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (validFiles.length === 0) {
|
||||
if (skippedCount > 0) {
|
||||
MessagePlugin.warning(`所选文件类型暂无可用解析引擎,已全部跳过`);
|
||||
}
|
||||
resetUploadInput();
|
||||
return;
|
||||
}
|
||||
if (skippedCount > 0) {
|
||||
MessagePlugin.warning(`${skippedCount} 个文件因无可用解析引擎被跳过`);
|
||||
}
|
||||
|
||||
// 批量上传
|
||||
let successCount = 0;
|
||||
let failCount = 0;
|
||||
const totalCount = validFiles.length;
|
||||
@@ -871,10 +964,9 @@ const handleFolderUpload = async (event: Event) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否启用了VLM
|
||||
const vlmEnabled = kbInfo.value?.vlm_config?.enabled || false;
|
||||
const dynamicTypes = supportedFileTypes.value.size > 0 ? supportedFileTypes.value : undefined
|
||||
|
||||
// 过滤有效文件
|
||||
const validFiles: File[] = [];
|
||||
let hiddenFileCount = 0;
|
||||
let imageFilteredCount = 0;
|
||||
@@ -883,7 +975,6 @@ const handleFolderUpload = async (event: Event) => {
|
||||
const file = files[i];
|
||||
const relativePath = (file as any).webkitRelativePath || file.name;
|
||||
|
||||
// 1. 过滤隐藏文件和隐藏文件夹
|
||||
const pathParts = relativePath.split('/');
|
||||
const hasHiddenComponent = pathParts.some((part: string) => part.startsWith('.'));
|
||||
if (hasHiddenComponent) {
|
||||
@@ -891,7 +982,6 @@ const handleFolderUpload = async (event: Event) => {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 2. 如果未启用VLM,过滤图片文件
|
||||
if (!vlmEnabled) {
|
||||
const fileExt = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase();
|
||||
const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
|
||||
@@ -901,8 +991,7 @@ const handleFolderUpload = async (event: Event) => {
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 文件类型验证
|
||||
if (!kbFileTypeVerification(file, true)) {
|
||||
if (!kbFileTypeVerification(file, true, dynamicTypes)) {
|
||||
validFiles.push(file);
|
||||
}
|
||||
}
|
||||
@@ -1111,9 +1200,8 @@ const delCardConfirm = () => {
|
||||
|
||||
// 处理知识库编辑成功后的回调
|
||||
const handleKBEditorSuccess = (kbIdValue: string) => {
|
||||
// 如果编辑的是当前知识库,刷新文件列表
|
||||
if (kbIdValue === kbId.value) {
|
||||
loadKnowledgeFiles(kbIdValue);
|
||||
loadKnowledgeBaseInfo(kbIdValue);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1226,6 +1314,11 @@ async function createNewSession(value: string): Promise<void> {
|
||||
</t-tooltip>
|
||||
</div>
|
||||
<p class="document-subtitle">{{ $t('knowledgeEditor.document.subtitle') }}</p>
|
||||
<p v-if="unsupportedFileTypes.length" class="parser-hint" @click="goToParserSettings">
|
||||
<t-icon name="info-circle" class="parser-hint-icon" />
|
||||
<span>{{ $t('knowledgeBase.unsupportedTypesHint', { types: unsupportedFileTypes.map(t => '.' + t).join('、') }) }}</span>
|
||||
<span class="parser-hint-link">{{ $t('knowledgeBase.goToParserSettings') }} →</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1233,7 +1326,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
ref="uploadInputRef"
|
||||
type="file"
|
||||
class="document-upload-input"
|
||||
accept=".pdf,.docx,.doc,.txt,.md,.jpg,.jpeg,.png,.csv,.xlsx,.xls"
|
||||
:accept="acceptFileTypes || '.pdf,.docx,.doc,.txt,.md,.jpg,.jpeg,.png,.csv,.xlsx,.xls,.pptx,.ppt'"
|
||||
multiple
|
||||
@change="handleDocumentUpload"
|
||||
/>
|
||||
@@ -2197,7 +2290,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
background: transparent;
|
||||
border: none;
|
||||
&:hover {
|
||||
color: #4e5969;
|
||||
color: #07C05F;
|
||||
background: #f2f3f5;
|
||||
}
|
||||
}
|
||||
@@ -2212,7 +2305,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
&:hover,
|
||||
&:focus,
|
||||
&.t-is-focused {
|
||||
border-color: #4080ff;
|
||||
border-color: #07C05F;
|
||||
background-color: #fff;
|
||||
}
|
||||
}
|
||||
@@ -2226,7 +2319,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
|
||||
&:hover,
|
||||
&.t-is-focused {
|
||||
border-color: #4080ff;
|
||||
border-color: #07C05F;
|
||||
background-color: #fff;
|
||||
}
|
||||
}
|
||||
@@ -2375,6 +2468,36 @@ async function createNewSession(value: string): Promise<void> {
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.parser-hint {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
margin: 2px 0 0;
|
||||
color: #b08000;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
cursor: pointer;
|
||||
transition: color 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
color: #8a6300;
|
||||
|
||||
.parser-hint-link {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
.parser-hint-icon {
|
||||
font-size: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.parser-hint-link {
|
||||
color: #07C05F;
|
||||
margin-left: 2px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -119,6 +119,22 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 解析引擎 -->
|
||||
<div v-if="!isFAQ && formData" v-show="currentSection === 'parser'" class="section">
|
||||
<KBParserSettings
|
||||
:parser-engine-rules="formData.chunkingConfig.parserEngineRules"
|
||||
@update:parser-engine-rules="handleParserEngineRulesUpdate"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 存储引擎 -->
|
||||
<div v-if="!isFAQ && formData" v-show="currentSection === 'storage'" class="section">
|
||||
<KBStorageSettings
|
||||
:storage-provider="formData.storageProvider"
|
||||
@update:storage-provider="handleStorageProviderUpdate"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 分块设置 -->
|
||||
<div v-if="!isFAQ" v-show="currentSection === 'chunking'" class="section">
|
||||
<KBChunkingSettings
|
||||
@@ -182,6 +198,8 @@ import { updateKBConfig, type KBModelConfigRequest } from '@/api/initialization'
|
||||
import { listModels } from '@/api/model'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
import KBModelConfig from './settings/KBModelConfig.vue'
|
||||
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 GraphSettings from './settings/GraphSettings.vue'
|
||||
@@ -220,6 +238,8 @@ const navItems = computed(() => {
|
||||
items.push({ key: 'faq', icon: 'help-circle', label: t('knowledgeEditor.sidebar.faq') })
|
||||
} else {
|
||||
items.push(
|
||||
{ key: 'parser', icon: 'file-search', label: '解析引擎' },
|
||||
{ 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: 'advanced', icon: 'setting', label: t('knowledgeEditor.sidebar.advanced') }
|
||||
@@ -274,25 +294,13 @@ const initFormData = (type: 'document' | 'faq' = 'document') => {
|
||||
chunkingConfig: {
|
||||
chunkSize: 512,
|
||||
chunkOverlap: 100,
|
||||
separators: ['\n\n', '\n', '。', '!', '?', ';', ';']
|
||||
separators: ['\n\n', '\n', '。', '!', '?', ';', ';'],
|
||||
parserEngineRules: undefined as any
|
||||
},
|
||||
storageProvider: 'local' as string,
|
||||
multimodalConfig: {
|
||||
enabled: false,
|
||||
storageType: 'minio' as 'minio' | 'cos',
|
||||
vllmModelId: '',
|
||||
minio: {
|
||||
bucketName: '',
|
||||
useSSL: false,
|
||||
pathPrefix: ''
|
||||
},
|
||||
cos: {
|
||||
secretId: '',
|
||||
secretKey: '',
|
||||
region: '',
|
||||
bucketName: '',
|
||||
appId: '',
|
||||
pathPrefix: ''
|
||||
}
|
||||
vllmModelId: ''
|
||||
},
|
||||
nodeExtractConfig: {
|
||||
enabled: false,
|
||||
@@ -363,25 +371,13 @@ const loadKBData = async () => {
|
||||
chunkingConfig: {
|
||||
chunkSize: kb.chunking_config?.chunk_size || 512,
|
||||
chunkOverlap: kb.chunking_config?.chunk_overlap || 100,
|
||||
separators: kb.chunking_config?.separators || ['\n\n', '\n', '。', '!', '?', ';', ';']
|
||||
separators: kb.chunking_config?.separators || ['\n\n', '\n', '。', '!', '?', ';', ';'],
|
||||
parserEngineRules: kb.chunking_config?.parser_engine_rules || undefined
|
||||
},
|
||||
storageProvider: (kb.cos_config?.provider || 'local') as string,
|
||||
multimodalConfig: {
|
||||
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_config?.model_id || '',
|
||||
minio: {
|
||||
bucketName: kb.cos_config?.bucket_name || '',
|
||||
useSSL: kb.cos_config?.use_ssl || 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 || ''
|
||||
}
|
||||
enabled: !!kb.vlm_config?.enabled,
|
||||
vllmModelId: kb.vlm_config?.model_id || ''
|
||||
},
|
||||
nodeExtractConfig: {
|
||||
enabled: kb.extract_config?.enabled || false,
|
||||
@@ -420,12 +416,24 @@ const handleChunkingConfigUpdate = (config: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleParserEngineRulesUpdate = (rules: any[]) => {
|
||||
if (formData.value) {
|
||||
formData.value.chunkingConfig.parserEngineRules = rules?.length ? rules : undefined
|
||||
}
|
||||
}
|
||||
|
||||
const handleMultimodalUpdate = (config: any) => {
|
||||
if (formData.value) {
|
||||
formData.value.multimodalConfig = { ...config }
|
||||
}
|
||||
}
|
||||
|
||||
const handleStorageProviderUpdate = (value: string) => {
|
||||
if (formData.value) {
|
||||
formData.value.storageProvider = value || 'local'
|
||||
}
|
||||
}
|
||||
|
||||
const handleQuestionGenerationUpdate = (config: any) => {
|
||||
if (formData.value) {
|
||||
formData.value.questionGenerationConfig = { ...config }
|
||||
@@ -493,7 +501,10 @@ const buildSubmitData = () => {
|
||||
chunk_size: formData.value.chunkingConfig.chunkSize,
|
||||
chunk_overlap: formData.value.chunkingConfig.chunkOverlap,
|
||||
separators: formData.value.chunkingConfig.separators,
|
||||
enable_multimodal: formData.value.multimodalConfig.enabled
|
||||
enable_multimodal: formData.value.multimodalConfig.enabled,
|
||||
...(formData.value.chunkingConfig.parserEngineRules?.length
|
||||
? { parser_engine_rules: formData.value.chunkingConfig.parserEngineRules }
|
||||
: {})
|
||||
},
|
||||
embedding_model_id: formData.value.modelConfig.embeddingModelId,
|
||||
summary_model_id: formData.value.modelConfig.llmModelId
|
||||
@@ -507,26 +518,9 @@ const buildSubmitData = () => {
|
||||
: ''
|
||||
}
|
||||
|
||||
if (formData.value.multimodalConfig.enabled) {
|
||||
const storageType = formData.value.multimodalConfig.storageType
|
||||
if (storageType === 'minio') {
|
||||
data.cos_config = {
|
||||
provider: 'minio',
|
||||
bucket_name: formData.value.multimodalConfig.minio.bucketName,
|
||||
use_ssl: formData.value.multimodalConfig.minio.useSSL,
|
||||
path_prefix: formData.value.multimodalConfig.minio.pathPrefix || undefined
|
||||
}
|
||||
} else {
|
||||
data.cos_config = {
|
||||
provider: 'cos',
|
||||
secret_id: formData.value.multimodalConfig.cos.secretId,
|
||||
secret_key: formData.value.multimodalConfig.cos.secretKey,
|
||||
region: formData.value.multimodalConfig.cos.region,
|
||||
bucket_name: formData.value.multimodalConfig.cos.bucketName,
|
||||
app_id: formData.value.multimodalConfig.cos.appId,
|
||||
path_prefix: formData.value.multimodalConfig.cos.pathPrefix || undefined
|
||||
}
|
||||
}
|
||||
// 存储引擎:仅传 provider,参数从全局设置读取
|
||||
data.cos_config = {
|
||||
provider: formData.value.storageProvider || 'local'
|
||||
}
|
||||
|
||||
// 添加知识图谱配置
|
||||
@@ -599,7 +593,7 @@ const handleSubmit = async () => {
|
||||
config: updateConfig
|
||||
})
|
||||
|
||||
// 2. 更新完整配置(模型、分块、多模态、知识图谱等)
|
||||
// 2. 更新完整配置(模型、分块、多模态、存储引擎、知识图谱等)
|
||||
const config: KBModelConfigRequest = {
|
||||
llmModelId: data.summary_model_id,
|
||||
embeddingModelId: data.embedding_model_id,
|
||||
@@ -607,25 +601,13 @@ const handleSubmit = async () => {
|
||||
documentSplitting: {
|
||||
chunkSize: data.chunking_config.chunk_size,
|
||||
chunkOverlap: data.chunking_config.chunk_overlap,
|
||||
separators: data.chunking_config.separators
|
||||
separators: data.chunking_config.separators,
|
||||
parserEngineRules: data.chunking_config.parser_engine_rules || undefined
|
||||
},
|
||||
multimodal: {
|
||||
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,
|
||||
secretKey: data.cos_config.secret_key,
|
||||
region: data.cos_config.region,
|
||||
bucketName: data.cos_config.bucket_name,
|
||||
appId: data.cos_config.app_id,
|
||||
pathPrefix: data.cos_config.path_prefix || ''
|
||||
} : undefined,
|
||||
minio: data.cos_config?.provider === 'minio' ? {
|
||||
bucketName: data.cos_config.bucket_name,
|
||||
useSSL: data.cos_config.use_ssl || false,
|
||||
pathPrefix: data.cos_config.path_prefix || ''
|
||||
} : undefined
|
||||
enabled: !!data.vlm_config?.enabled
|
||||
},
|
||||
storageProvider: data.cos_config?.provider || 'local',
|
||||
nodeExtract: {
|
||||
enabled: data.extract_config?.enabled || false,
|
||||
text: data.extract_config?.text || '',
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Multimodal feature -->
|
||||
<!-- Multimodal feature:仅选择多模态模型,存储引擎在「存储引擎」页配置 -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('knowledgeEditor.advanced.multimodal.label') }}</label>
|
||||
@@ -57,9 +57,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Multimodal storage configuration -->
|
||||
<!-- 多模态开启时仅配置 VLLM 模型 -->
|
||||
<div v-if="localMultimodal.enabled" class="subsection">
|
||||
<!-- VLLM model -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('knowledgeEditor.advanced.multimodal.vllmLabel') }} <span class="required">*</span></label>
|
||||
@@ -77,206 +76,6 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="subsection-header">
|
||||
<h4>{{ $t('knowledgeEditor.advanced.multimodal.storageTitle') }} <span class="required">*</span></h4>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('knowledgeEditor.advanced.multimodal.storageTypeLabel') }} <span class="required">*</span></label>
|
||||
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.storageTypeDescription') }}</p>
|
||||
<!-- Warning message when MinIO is not enabled -->
|
||||
<t-alert
|
||||
v-if="!isMinioEnabled"
|
||||
theme="warning"
|
||||
:message="$t('knowledgeEditor.advanced.multimodal.minioDisabledWarning')"
|
||||
style="margin-top: 8px;"
|
||||
/>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-radio-group v-model="localMultimodal.storageType" @change="handleStorageTypeChange">
|
||||
<t-radio value="minio" :disabled="!isMinioEnabled">
|
||||
{{ $t('knowledgeEditor.advanced.multimodal.storageTypeOptions.minio') }}
|
||||
</t-radio>
|
||||
<t-radio value="cos">{{ $t('knowledgeEditor.advanced.multimodal.storageTypeOptions.cos') }}</t-radio>
|
||||
</t-radio-group>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MinIO configuration -->
|
||||
<div v-if="localMultimodal.storageType === 'minio'" class="storage-config">
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('knowledgeEditor.advanced.multimodal.minio.bucketLabel') }} <span class="required">*</span></label>
|
||||
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.minio.bucketDescription') }}</p>
|
||||
<p class="hint">{{ $t('knowledgeEditor.advanced.multimodal.minio.bucketHint') }}</p>
|
||||
</div>
|
||||
<div class="setting-control bucket-control">
|
||||
<t-select
|
||||
v-model="localMultimodal.minio.bucketName"
|
||||
:placeholder="$t('knowledgeEditor.advanced.multimodal.minio.bucketPlaceholder')"
|
||||
:loading="loadingBuckets"
|
||||
filterable
|
||||
creatable
|
||||
@change="handleConfigChange"
|
||||
@focus="loadMinioBuckets"
|
||||
style="width: 280px;"
|
||||
>
|
||||
<t-option
|
||||
v-for="bucket in minioBuckets"
|
||||
:key="bucket.name"
|
||||
:value="bucket.name"
|
||||
:label="bucket.name"
|
||||
>
|
||||
<div class="bucket-option">
|
||||
<span class="bucket-name">{{ bucket.name }}</span>
|
||||
<t-tag
|
||||
:theme="bucket.policy === 'public' ? 'success' : bucket.policy === 'private' ? 'default' : 'warning'"
|
||||
size="small"
|
||||
variant="light"
|
||||
>
|
||||
{{ $t(`knowledgeEditor.advanced.multimodal.minio.policyLabels.${bucket.policy}`) }}
|
||||
</t-tag>
|
||||
</div>
|
||||
</t-option>
|
||||
</t-select>
|
||||
<t-button
|
||||
theme="default"
|
||||
variant="outline"
|
||||
size="small"
|
||||
:loading="loadingBuckets"
|
||||
@click="loadMinioBuckets"
|
||||
style="margin-left: 8px;"
|
||||
>
|
||||
<template #icon><refresh-icon /></template>
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('knowledgeEditor.advanced.multimodal.minio.useSslLabel') }}</label>
|
||||
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.minio.useSslDescription') }}</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>{{ $t('knowledgeEditor.advanced.multimodal.minio.pathPrefixLabel') }}</label>
|
||||
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.minio.pathPrefixDescription') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-input
|
||||
v-model="localMultimodal.minio.pathPrefix"
|
||||
:placeholder="$t('knowledgeEditor.advanced.multimodal.minio.pathPrefixPlaceholder')"
|
||||
@change="handleConfigChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- COS configuration -->
|
||||
<div v-if="localMultimodal.storageType === 'cos'" class="storage-config">
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('knowledgeEditor.advanced.multimodal.cos.secretIdLabel') }} <span class="required">*</span></label>
|
||||
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.cos.secretIdDescription') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-input
|
||||
v-model="localMultimodal.cos.secretId"
|
||||
:placeholder="$t('knowledgeEditor.advanced.multimodal.cos.secretIdPlaceholder')"
|
||||
@change="handleConfigChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('knowledgeEditor.advanced.multimodal.cos.secretKeyLabel') }} <span class="required">*</span></label>
|
||||
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.cos.secretKeyDescription') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-input
|
||||
v-model="localMultimodal.cos.secretKey"
|
||||
type="password"
|
||||
:placeholder="$t('knowledgeEditor.advanced.multimodal.cos.secretKeyPlaceholder')"
|
||||
@change="handleConfigChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('knowledgeEditor.advanced.multimodal.cos.regionLabel') }} <span class="required">*</span></label>
|
||||
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.cos.regionDescription') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-input
|
||||
v-model="localMultimodal.cos.region"
|
||||
:placeholder="$t('knowledgeEditor.advanced.multimodal.cos.regionPlaceholder')"
|
||||
@change="handleConfigChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('knowledgeEditor.advanced.multimodal.cos.bucketLabel') }} <span class="required">*</span></label>
|
||||
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.cos.bucketDescription') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-input
|
||||
v-model="localMultimodal.cos.bucketName"
|
||||
:placeholder="$t('knowledgeEditor.advanced.multimodal.cos.bucketPlaceholder')"
|
||||
@change="handleConfigChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('knowledgeEditor.advanced.multimodal.cos.appIdLabel') }} <span class="required">*</span></label>
|
||||
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.cos.appIdDescription') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-input
|
||||
v-model="localMultimodal.cos.appId"
|
||||
:placeholder="$t('knowledgeEditor.advanced.multimodal.cos.appIdPlaceholder')"
|
||||
@change="handleConfigChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('knowledgeEditor.advanced.multimodal.cos.pathPrefixLabel') }}</label>
|
||||
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.cos.pathPrefixDescription') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-input
|
||||
v-model="localMultimodal.cos.pathPrefix"
|
||||
:placeholder="$t('knowledgeEditor.advanced.multimodal.cos.pathPrefixPlaceholder')"
|
||||
@change="handleConfigChange"
|
||||
style="width: 280px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -284,31 +83,15 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, onMounted } from 'vue'
|
||||
import { RefreshIcon } from 'tdesign-icons-vue-next'
|
||||
import { ref, watch } from 'vue'
|
||||
import ModelSelector from '@/components/ModelSelector.vue'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
import { getSystemInfo, listMinioBuckets, type MinioBucketInfo } from '@/api/system'
|
||||
|
||||
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 QuestionGenerationConfig {
|
||||
@@ -335,58 +118,7 @@ const localQuestionGeneration = ref<QuestionGenerationConfig>(
|
||||
)
|
||||
|
||||
const vllmSelectorRef = ref()
|
||||
const isMinioEnabled = ref(false)
|
||||
const minioBuckets = ref<MinioBucketInfo[]>([])
|
||||
const loadingBuckets = ref(false)
|
||||
|
||||
// Load MinIO buckets
|
||||
const loadMinioBuckets = async () => {
|
||||
if (!isMinioEnabled.value || loadingBuckets.value) return
|
||||
|
||||
loadingBuckets.value = true
|
||||
try {
|
||||
const response = await listMinioBuckets()
|
||||
if (response.data?.buckets) {
|
||||
minioBuckets.value = response.data.buckets
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load MinIO buckets:', error)
|
||||
} finally {
|
||||
loadingBuckets.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// Check system status on mount
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const systemInfo = await getSystemInfo()
|
||||
|
||||
// Check MinIO status
|
||||
isMinioEnabled.value = systemInfo.data?.minio_enabled === true
|
||||
|
||||
// If MinIO is not enabled and storage type is minio, switch to cos
|
||||
if (!isMinioEnabled.value && localMultimodal.value.storageType === 'minio') {
|
||||
localMultimodal.value.storageType = 'cos'
|
||||
emit('update:multimodal', localMultimodal.value)
|
||||
}
|
||||
|
||||
// Load MinIO buckets if enabled
|
||||
if (isMinioEnabled.value) {
|
||||
loadMinioBuckets()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch system info:', error)
|
||||
// Default to disabled if we can't fetch the info
|
||||
isMinioEnabled.value = false
|
||||
// If MinIO status unknown and storage type is minio, switch to cos
|
||||
if (localMultimodal.value.storageType === 'minio') {
|
||||
localMultimodal.value.storageType = 'cos'
|
||||
emit('update:multimodal', localMultimodal.value)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Watch for prop changes
|
||||
watch(() => props.multimodal, (newVal) => {
|
||||
localMultimodal.value = { ...newVal }
|
||||
}, { deep: true })
|
||||
@@ -397,7 +129,6 @@ watch(() => props.questionGeneration, (newVal) => {
|
||||
}
|
||||
}, { deep: true })
|
||||
|
||||
// Handle question generation toggle
|
||||
const handleQuestionGenerationToggle = () => {
|
||||
if (!localQuestionGeneration.value.enabled) {
|
||||
localQuestionGeneration.value.questionCount = 3
|
||||
@@ -405,59 +136,25 @@ const handleQuestionGenerationToggle = () => {
|
||||
emit('update:questionGeneration', localQuestionGeneration.value)
|
||||
}
|
||||
|
||||
// Handle question generation config change
|
||||
const handleQuestionGenerationChange = () => {
|
||||
emit('update:questionGeneration', localQuestionGeneration.value)
|
||||
}
|
||||
|
||||
// Handle multimodal toggle
|
||||
const handleMultimodalToggle = () => {
|
||||
// Reset related configuration when multimodal is disabled
|
||||
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)
|
||||
}
|
||||
|
||||
// Handle storage type change
|
||||
const handleStorageTypeChange = () => {
|
||||
// Prevent switching to minio if it's not enabled
|
||||
if (localMultimodal.value.storageType === 'minio' && !isMinioEnabled.value) {
|
||||
localMultimodal.value.storageType = 'cos'
|
||||
}
|
||||
emit('update:multimodal', localMultimodal.value)
|
||||
}
|
||||
|
||||
// Handle VLLM model change
|
||||
const handleVLLMChange = (modelId: string) => {
|
||||
localMultimodal.value.vllmModelId = modelId
|
||||
emit('update:multimodal', localMultimodal.value)
|
||||
}
|
||||
|
||||
// Navigate to model management when adding models
|
||||
const handleAddModel = (subSection: string) => {
|
||||
uiStore.openSettings('models', subSection)
|
||||
}
|
||||
|
||||
// Handle configuration change
|
||||
const handleConfigChange = () => {
|
||||
emit('update:multimodal', localMultimodal.value)
|
||||
}
|
||||
|
||||
// The allModels prop keeps model options in sync
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
@@ -546,104 +243,11 @@ const handleConfigChange = () => {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.subsection-header {
|
||||
margin: 16px 0 8px 0;
|
||||
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #333333;
|
||||
margin: 0;
|
||||
padding-left: 8px;
|
||||
border-left: 2px solid #07C05F;
|
||||
|
||||
.required {
|
||||
color: #e34d59;
|
||||
margin-left: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.required {
|
||||
color: #e34d59;
|
||||
margin-left: 2px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.storage-config {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.bucket-control {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.bucket-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
|
||||
.bucket-name {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.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>
|
||||
|
||||
|
||||
@@ -77,10 +77,16 @@
|
||||
import { ref, watch, computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
interface ParserEngineRule {
|
||||
file_types: string[]
|
||||
engine: string
|
||||
}
|
||||
|
||||
interface ChunkingConfig {
|
||||
chunkSize: number
|
||||
chunkOverlap: number
|
||||
separators: string[]
|
||||
parserEngineRules?: ParserEngineRule[]
|
||||
}
|
||||
|
||||
interface Props {
|
||||
@@ -98,7 +104,6 @@ const localChunkOverlap = ref(props.config.chunkOverlap)
|
||||
const localSeparators = ref([...props.config.separators])
|
||||
const { t } = useI18n()
|
||||
|
||||
// Separator options
|
||||
const separatorOptions = computed(() => [
|
||||
{ label: t('knowledgeEditor.chunking.separators.doubleNewline'), value: '\n\n' },
|
||||
{ label: t('knowledgeEditor.chunking.separators.singleNewline'), value: '\n' },
|
||||
@@ -110,34 +115,22 @@ const separatorOptions = computed(() => [
|
||||
{ label: t('knowledgeEditor.chunking.separators.space'), value: ' ' }
|
||||
])
|
||||
|
||||
// Watch for prop changes
|
||||
watch(() => props.config, (newConfig) => {
|
||||
localChunkSize.value = newConfig.chunkSize
|
||||
localChunkOverlap.value = newConfig.chunkOverlap
|
||||
localSeparators.value = [...newConfig.separators]
|
||||
}, { deep: true })
|
||||
|
||||
// Handle chunk size change
|
||||
const handleChunkSizeChange = () => {
|
||||
emitUpdate()
|
||||
}
|
||||
const handleChunkSizeChange = () => { emitUpdate() }
|
||||
const handleChunkOverlapChange = () => { emitUpdate() }
|
||||
const handleSeparatorsChange = () => { emitUpdate() }
|
||||
|
||||
// Handle chunk overlap change
|
||||
const handleChunkOverlapChange = () => {
|
||||
emitUpdate()
|
||||
}
|
||||
|
||||
// Handle separator change
|
||||
const handleSeparatorsChange = () => {
|
||||
emitUpdate()
|
||||
}
|
||||
|
||||
// Emit update event
|
||||
const emitUpdate = () => {
|
||||
emit('update:config', {
|
||||
chunkSize: localChunkSize.value,
|
||||
chunkOverlap: localChunkOverlap.value,
|
||||
separators: localSeparators.value
|
||||
separators: localSeparators.value,
|
||||
parserEngineRules: props.config.parserEngineRules
|
||||
})
|
||||
}
|
||||
</script>
|
||||
@@ -228,4 +221,3 @@ const emitUpdate = () => {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -0,0 +1,456 @@
|
||||
<template>
|
||||
<div class="kb-parser-settings">
|
||||
<div class="section-header">
|
||||
<h2>解析引擎</h2>
|
||||
<p class="section-description">为不同文件类型选择文档解析引擎。未配置的文件类型将使用内置解析引擎。</p>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="loading-inline">
|
||||
<t-loading size="small" />
|
||||
<span>加载中...</span>
|
||||
</div>
|
||||
|
||||
<div v-else-if="fileTypeGroups.length === 0" class="empty-hint">
|
||||
<p>暂无可用解析引擎,或文档解析服务未配置。</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="settings-group">
|
||||
<div
|
||||
v-for="group in fileTypeGroups"
|
||||
:key="group.key"
|
||||
class="setting-row"
|
||||
>
|
||||
<div class="setting-info">
|
||||
<label class="group-label">
|
||||
<t-icon :name="group.icon" class="group-icon" />
|
||||
{{ group.label }}
|
||||
</label>
|
||||
<div class="ext-tags">
|
||||
<span v-for="ext in group.extensions" :key="ext" class="ext-tag">.{{ ext }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-select
|
||||
:value="getEngineForGroup(group.extensions) || undefined"
|
||||
@change="(val: string) => handleEngineChange(group.extensions, val)"
|
||||
style="width: 280px;"
|
||||
:status="hasAvailableEngine(group.extensions) ? 'default' : 'warning'"
|
||||
placeholder="无可用引擎"
|
||||
>
|
||||
<t-option
|
||||
v-for="opt in getEngineOptions(group.extensions)"
|
||||
:key="opt.value"
|
||||
:value="opt.value"
|
||||
:label="opt.selectLabel"
|
||||
:disabled="opt.disabled"
|
||||
>
|
||||
<t-tooltip
|
||||
:content="`支持格式: ${opt.fileTypes.map(t => '.' + t).join(' ')}`"
|
||||
placement="left"
|
||||
:show-arrow="false"
|
||||
>
|
||||
<div class="engine-option">
|
||||
<div class="engine-option-top">
|
||||
<span class="engine-option-name">{{ opt.value }}</span>
|
||||
<t-tag
|
||||
v-if="opt.isDefault"
|
||||
theme="primary"
|
||||
variant="light"
|
||||
size="small"
|
||||
>默认</t-tag>
|
||||
<t-tag
|
||||
v-if="opt.disabled"
|
||||
theme="danger"
|
||||
variant="light"
|
||||
size="small"
|
||||
>不可用</t-tag>
|
||||
</div>
|
||||
<div class="engine-option-desc">{{ opt.desc }}</div>
|
||||
<div v-if="opt.disabled && opt.reason" class="engine-option-reason">
|
||||
{{ opt.reason }}
|
||||
<a class="go-settings" @click.stop.prevent="goToParserSettings">去设置 →</a>
|
||||
</div>
|
||||
</div>
|
||||
</t-tooltip>
|
||||
</t-option>
|
||||
</t-select>
|
||||
<div v-if="!hasAvailableEngine(group.extensions)" class="no-engine-warning">
|
||||
<a class="go-settings" @click.prevent="goToParserSettings">前往配置 →</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, computed, onMounted, onUnmounted } from 'vue'
|
||||
import { getParserEngines, type ParserEngineInfo } from '@/api/system'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
import { storeToRefs } from 'pinia'
|
||||
|
||||
export interface ParserEngineRule {
|
||||
file_types: string[]
|
||||
engine: string
|
||||
}
|
||||
|
||||
interface EngineOption {
|
||||
value: string
|
||||
selectLabel: string
|
||||
desc: string
|
||||
fileTypes: string[]
|
||||
disabled: boolean
|
||||
isDefault: boolean
|
||||
reason?: string
|
||||
}
|
||||
|
||||
interface Props {
|
||||
parserEngineRules?: ParserEngineRule[]
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
parserEngineRules: () => []
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:parserEngineRules': [value: ParserEngineRule[]]
|
||||
}>()
|
||||
|
||||
const uiStore = useUIStore()
|
||||
const localEngineRules = ref<ParserEngineRule[]>([...props.parserEngineRules])
|
||||
const parserEngines = ref<ParserEngineInfo[]>([])
|
||||
const loading = ref(true)
|
||||
|
||||
const allFileTypes = computed(() => {
|
||||
const s = new Set<string>()
|
||||
for (const engine of parserEngines.value) {
|
||||
for (const ft of engine.FileTypes || []) {
|
||||
s.add(ft)
|
||||
}
|
||||
}
|
||||
return s
|
||||
})
|
||||
|
||||
const fileTypeGroups = computed(() => {
|
||||
const ft = allFileTypes.value
|
||||
const groups: { key: string; label: string; icon: string; extensions: string[] }[] = []
|
||||
|
||||
const pdfExts = ['pdf'].filter(e => ft.has(e))
|
||||
const officeExts = ['docx', 'doc'].filter(e => ft.has(e))
|
||||
const pptExts = ['pptx', 'ppt'].filter(e => ft.has(e))
|
||||
const excelExts = ['xlsx', 'xls'].filter(e => ft.has(e))
|
||||
const csvExts = ['csv'].filter(e => ft.has(e))
|
||||
const mdExts = ['md', 'markdown'].filter(e => ft.has(e))
|
||||
const txtExts = ['txt'].filter(e => ft.has(e))
|
||||
const imageExts = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'tiff', 'webp'].filter(e => ft.has(e))
|
||||
|
||||
if (pdfExts.length) groups.push({ key: 'pdf', label: 'PDF 文档', icon: 'file-pdf', extensions: pdfExts })
|
||||
if (officeExts.length) groups.push({ key: 'office', label: 'Word 文档', icon: 'file-word', extensions: officeExts })
|
||||
if (pptExts.length) groups.push({ key: 'ppt', label: '演示文稿', icon: 'file-powerpoint', extensions: pptExts })
|
||||
if (excelExts.length) groups.push({ key: 'excel', label: 'Excel 表格', icon: 'file-excel', extensions: excelExts })
|
||||
if (csvExts.length) groups.push({ key: 'csv', label: 'CSV 文件', icon: 'file-excel', extensions: csvExts })
|
||||
if (mdExts.length) groups.push({ key: 'markdown', label: 'Markdown', icon: 'file-code', extensions: mdExts })
|
||||
if (txtExts.length) groups.push({ key: 'text', label: '纯文本', icon: 'file', extensions: txtExts })
|
||||
if (imageExts.length) groups.push({ key: 'image', label: '图片', icon: 'image', extensions: imageExts })
|
||||
|
||||
return groups
|
||||
})
|
||||
|
||||
function getEngineOptions(extensions: string[]): EngineOption[] {
|
||||
const raw: { name: string; desc: string; fileTypes: string[]; available: boolean; reason: string }[] = []
|
||||
for (const engine of parserEngines.value) {
|
||||
const supports = extensions.some(ext => (engine.FileTypes || []).includes(ext))
|
||||
if (supports) {
|
||||
raw.push({
|
||||
name: engine.Name,
|
||||
desc: engine.Description || engine.Name,
|
||||
fileTypes: engine.FileTypes || [],
|
||||
available: engine.Available !== false,
|
||||
reason: engine.UnavailableReason || '',
|
||||
})
|
||||
}
|
||||
}
|
||||
const defaultName = raw.find(e => e.available)?.name ?? ''
|
||||
return raw.map(e => ({
|
||||
value: e.name,
|
||||
selectLabel: `${e.name} — ${e.desc}`,
|
||||
desc: e.desc,
|
||||
fileTypes: e.fileTypes,
|
||||
disabled: !e.available,
|
||||
isDefault: defaultName !== '' && e.name === defaultName,
|
||||
reason: e.reason,
|
||||
}))
|
||||
}
|
||||
|
||||
function hasAvailableEngine(extensions: string[]): boolean {
|
||||
return getEngineOptions(extensions).some(opt => !opt.disabled)
|
||||
}
|
||||
|
||||
function getDefaultEngine(extensions: string[]): string {
|
||||
const opts = getEngineOptions(extensions)
|
||||
return opts.find(o => o.isDefault)?.value ?? ''
|
||||
}
|
||||
|
||||
function getEngineForGroup(extensions: string[]): string {
|
||||
for (const rule of localEngineRules.value) {
|
||||
if (rule.file_types.some(ft => extensions.includes(ft))) {
|
||||
return rule.engine
|
||||
}
|
||||
}
|
||||
return getDefaultEngine(extensions)
|
||||
}
|
||||
|
||||
function handleEngineChange(extensions: string[], engine: string) {
|
||||
const otherRules = localEngineRules.value.filter(
|
||||
r => !r.file_types.some(ft => extensions.includes(ft))
|
||||
)
|
||||
if (engine) {
|
||||
otherRules.push({ file_types: [...extensions], engine })
|
||||
}
|
||||
localEngineRules.value = otherRules
|
||||
emit('update:parserEngineRules', buildCompleteRules())
|
||||
}
|
||||
|
||||
function buildCompleteRules(): ParserEngineRule[] {
|
||||
const rules: ParserEngineRule[] = []
|
||||
for (const group of fileTypeGroups.value) {
|
||||
const engine = getEngineForGroup(group.extensions)
|
||||
if (engine) {
|
||||
rules.push({ file_types: [...group.extensions], engine })
|
||||
}
|
||||
}
|
||||
return rules
|
||||
}
|
||||
|
||||
function goToParserSettings() {
|
||||
uiStore.openSettings('parser')
|
||||
}
|
||||
|
||||
async function loadEngines() {
|
||||
loading.value = true
|
||||
try {
|
||||
const resp = await getParserEngines()
|
||||
if (resp?.data && Array.isArray(resp.data)) {
|
||||
parserEngines.value = resp.data
|
||||
}
|
||||
} catch {
|
||||
parserEngines.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
ensureCompleteRules()
|
||||
}
|
||||
}
|
||||
|
||||
function ensureCompleteRules() {
|
||||
if (!parserEngines.value.length) return
|
||||
const complete = buildCompleteRules()
|
||||
if (complete.length && complete.length > localEngineRules.value.length) {
|
||||
localEngineRules.value = complete
|
||||
emit('update:parserEngineRules', complete)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadEngines)
|
||||
|
||||
const { showSettingsModal } = storeToRefs(uiStore)
|
||||
watch(showSettingsModal, (open, wasOpen) => {
|
||||
if (wasOpen && !open) {
|
||||
loadEngines()
|
||||
}
|
||||
})
|
||||
|
||||
watch(() => props.parserEngineRules, (v) => {
|
||||
localEngineRules.value = v?.length ? [...v] : []
|
||||
}, { deep: true })
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.kb-parser-settings {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 32px;
|
||||
|
||||
h2 {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.section-description {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.loading-inline {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 16px 0;
|
||||
}
|
||||
|
||||
.empty-hint {
|
||||
padding: 24px 0;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.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 #e5e7eb;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-info {
|
||||
flex: 1;
|
||||
max-width: 65%;
|
||||
padding-right: 24px;
|
||||
|
||||
.group-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.group-icon {
|
||||
font-size: 18px;
|
||||
color: #555;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
label {
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.ext-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.ext-tag {
|
||||
display: inline-block;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
color: #555;
|
||||
background: #f3f4f6;
|
||||
padding: 3px 8px;
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
}
|
||||
|
||||
.desc {
|
||||
font-size: 13px;
|
||||
color: #666;
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-control {
|
||||
flex-shrink: 0;
|
||||
min-width: 280px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.no-engine-warning {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: #e37318;
|
||||
line-height: 1.4;
|
||||
|
||||
.go-settings {
|
||||
color: #07C05F;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 下拉选项样式 ----
|
||||
.engine-option {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
padding: 3px 0;
|
||||
}
|
||||
|
||||
.engine-option-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.engine-option-name {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
}
|
||||
|
||||
.engine-option-desc {
|
||||
font-size: 12px;
|
||||
color: #888;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.engine-option-reason {
|
||||
font-size: 12px;
|
||||
color: #e34d59;
|
||||
line-height: 1.4;
|
||||
|
||||
.go-settings {
|
||||
color: #07C05F;
|
||||
cursor: pointer;
|
||||
margin-left: 4px;
|
||||
font-size: 12px;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less">
|
||||
.t-select__dropdown .t-select-option {
|
||||
height: auto;
|
||||
align-items: flex-start;
|
||||
padding-top: 6px;
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
.t-select__dropdown .t-select-option__content {
|
||||
white-space: normal;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,244 @@
|
||||
<template>
|
||||
<div class="kb-storage-settings">
|
||||
<div class="section-header">
|
||||
<h2>存储引擎</h2>
|
||||
<p class="section-description">
|
||||
选择文件存储引擎,影响文档上传存储和文档中图片的存储方式。参数在全局设置中配置。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="loading-inline">
|
||||
<t-loading size="small" />
|
||||
<span>加载中...</span>
|
||||
</div>
|
||||
|
||||
<div v-else class="settings-group">
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>存储引擎</label>
|
||||
<p class="desc">选择该知识库使用的存储引擎,需在全局设置中已配置对应引擎。</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-select
|
||||
v-model="localProvider"
|
||||
size="medium"
|
||||
placeholder="请选择存储引擎"
|
||||
style="width: 100%; min-width: 220px;"
|
||||
@change="handleChange"
|
||||
>
|
||||
<t-option
|
||||
v-for="opt in engineOptions"
|
||||
:key="opt.value"
|
||||
:value="opt.value"
|
||||
:label="opt.label"
|
||||
:disabled="opt.disabled"
|
||||
>
|
||||
<span class="select-option">
|
||||
<span>{{ opt.label }}</span>
|
||||
<t-tag v-if="opt.disabled" theme="warning" variant="light" size="small">未配置</t-tag>
|
||||
<t-tag v-else-if="opt.available === false" theme="danger" variant="light" size="small">不可用</t-tag>
|
||||
</span>
|
||||
</t-option>
|
||||
</t-select>
|
||||
<p v-if="selectedOption?.desc" class="option-hint">{{ selectedOption.desc }}</p>
|
||||
<a v-if="showGoSettings" href="javascript:void(0)" class="go-settings" @click.prevent="goToStorageSettings">去全局设置中配置</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch, onMounted } from 'vue'
|
||||
import { getStorageEngineConfig, getStorageEngineStatus, type StorageEngineStatusItem } from '@/api/system'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
|
||||
const props = defineProps<{
|
||||
storageProvider: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:storageProvider': [value: string]
|
||||
}>()
|
||||
|
||||
const uiStore = useUIStore()
|
||||
const localProvider = ref(props.storageProvider || 'local')
|
||||
const loading = ref(true)
|
||||
const engineStatus = ref<StorageEngineStatusItem[]>([])
|
||||
const defaultProvider = ref('local')
|
||||
const hasAnyConfig = ref(false)
|
||||
|
||||
const engineOptions = computed(() => {
|
||||
const statusMap: Record<string, boolean> = {}
|
||||
for (const e of engineStatus.value) {
|
||||
statusMap[e.name] = e.available
|
||||
}
|
||||
return [
|
||||
{
|
||||
value: 'local',
|
||||
label: 'Local(本地存储)',
|
||||
desc: '仅适合单机部署,简单轻量',
|
||||
available: statusMap.local !== false,
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
value: 'minio',
|
||||
label: 'MinIO',
|
||||
desc: 'S3 兼容,适合内网或私有云',
|
||||
available: statusMap.minio,
|
||||
disabled: statusMap.minio === false,
|
||||
},
|
||||
{
|
||||
value: 'cos',
|
||||
label: '腾讯云 COS',
|
||||
desc: '公有云部署,支持 CDN 加速',
|
||||
available: statusMap.cos,
|
||||
disabled: statusMap.cos === false,
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
const showGoSettings = computed(() =>
|
||||
engineOptions.value.some(o => o.disabled)
|
||||
)
|
||||
|
||||
const selectedOption = computed(() =>
|
||||
engineOptions.value.find(o => o.value === localProvider.value)
|
||||
)
|
||||
|
||||
function handleChange() {
|
||||
emit('update:storageProvider', localProvider.value)
|
||||
}
|
||||
|
||||
function goToStorageSettings() {
|
||||
uiStore.closeKBEditor?.()
|
||||
uiStore.openSettings?.('storage')
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
const [configRes, statusRes] = await Promise.all([
|
||||
getStorageEngineConfig(),
|
||||
getStorageEngineStatus(),
|
||||
])
|
||||
const engines = statusRes?.data?.engines ?? []
|
||||
engineStatus.value = engines
|
||||
defaultProvider.value = configRes?.data?.default_provider || 'local'
|
||||
const d = configRes?.data
|
||||
hasAnyConfig.value = !!(d?.local?.path_prefix || d?.minio?.bucket_name || d?.cos?.bucket_name)
|
||||
if (!localProvider.value || localProvider.value === '') {
|
||||
localProvider.value = defaultProvider.value
|
||||
emit('update:storageProvider', localProvider.value)
|
||||
}
|
||||
} catch {
|
||||
engineStatus.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => props.storageProvider, (v) => {
|
||||
localProvider.value = v || defaultProvider.value || 'local'
|
||||
}, { immediate: true })
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.kb-storage-settings {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 32px;
|
||||
|
||||
h2 {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin: 0 0 8px 0;
|
||||
}
|
||||
|
||||
.section-description {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.loading-inline {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 16px 0;
|
||||
}
|
||||
|
||||
.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 #e5e7eb;
|
||||
}
|
||||
|
||||
.setting-info {
|
||||
flex: 1;
|
||||
max-width: 65%;
|
||||
padding-right: 24px;
|
||||
|
||||
label {
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.desc {
|
||||
font-size: 13px;
|
||||
color: #666;
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-control {
|
||||
flex-shrink: 0;
|
||||
min-width: 280px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.select-option {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.option-hint {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin: 0;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.go-settings {
|
||||
font-size: 13px;
|
||||
color: var(--td-brand-color, #0052d9);
|
||||
margin-top: 8px;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user