feat: Implement comprehensive wiki feature for knowledge bases
This commit introduces the complete wiki feature for WeKnora, enabling AI-powered wiki page generation and management. The implementation includes: **Backend Changes:** - Wiki data model: WikiPage type with support for multiple page types (Summary, Entity, Concept, Index, Log) - Database schema: wiki_pages table with full migration support - WikiPageService: CRUD operations and page management - WikiPageRepository: GORM-based persistence layer - Wiki ingest pipeline: Automated generation of wiki pages from knowledge documents * Summary page generation using LLM * Entity and concept extraction in a single LLM call * Synthesis opportunity detection * Index page rebuilding * Log page maintenance - Wiki boost feature: Enhance chat retrieval with wiki context - Wiki linting: Maintenance and validation utilities - Agent wiki tools: Enable agents to query and interact with wiki pages - Wiki prompts: Comprehensive LLM prompt templates for all wiki generation tasks - Language support: Reuse existing middleware language infrastructure for LLM prompts **Frontend Changes:** - Wiki browser UI: View all wiki pages with filtering and search - Wiki API client: Knowledge base wiki management endpoints - Knowledge base editor: Configure wiki settings (language, auto-ingest, synthesis model) - i18n updates: Support for English, Korean, Russian, and Chinese interfaces **Configuration:** - Container DI: Wire up all wiki services - Router: Register wiki API endpoints - Task handling: Support async wiki ingest tasks **Testing:** - Unit tests for wiki page types - Service layer tests - Endpoint tests for wiki operations - Integration tests with LLM mocking **Documentation:** - Language refactoring analysis and guides - Implementation completion reports - Quick reference guides for developers **Key Features:** ✅ LLM-powered wiki page generation from documents ✅ Multi-language support (9+ languages) ✅ Automatic extraction of entities and concepts ✅ Synthesis opportunity detection ✅ Index and log page maintenance ✅ Progressive wiki building across multiple documents ✅ Agent-based wiki interaction ✅ Chat retrieval enhancement with wiki context ✅ Full frontend UI for wiki browsing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -49,6 +49,7 @@
|
||||
>
|
||||
<t-radio-button value="document">{{ $t('knowledgeEditor.basic.typeDocument') }}</t-radio-button>
|
||||
<t-radio-button value="faq">{{ $t('knowledgeEditor.basic.typeFAQ') }}</t-radio-button>
|
||||
<t-radio-button value="wiki">{{ $t('knowledgeEditor.basic.typeWiki') }}</t-radio-button>
|
||||
</t-radio-group>
|
||||
<p class="form-tip">{{ $t('knowledgeEditor.basic.typeDescription') }}</p>
|
||||
</div>
|
||||
@@ -120,8 +121,49 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Wiki 配置 -->
|
||||
<div v-if="isWiki && formData" v-show="currentSection === 'wiki'" class="section">
|
||||
<div class="section-content">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">{{ $t('knowledgeEditor.wiki.title') }}</h3>
|
||||
<p class="section-desc">{{ $t('knowledgeEditor.wiki.description') }}</p>
|
||||
</div>
|
||||
<div class="section-body">
|
||||
<div class="form-item">
|
||||
<label class="form-label">{{ $t('knowledgeEditor.wiki.autoIngestLabel') }}</label>
|
||||
<t-switch v-model="formData.wikiConfig.autoIngest" size="medium" />
|
||||
<p class="form-tip">{{ $t('knowledgeEditor.wiki.autoIngestTip') }}</p>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label class="form-label">{{ $t('knowledgeEditor.wiki.synthesisModelLabel') }}</label>
|
||||
<ModelSelector
|
||||
model-type="LLM"
|
||||
:selected-model-id="formData.wikiConfig.synthesisModelId"
|
||||
:all-models="allModels"
|
||||
@update:selected-model-id="(val: string) => { if (formData) formData.wikiConfig.synthesisModelId = val }"
|
||||
:placeholder="$t('knowledgeEditor.wiki.synthesisModelPlaceholder')"
|
||||
/>
|
||||
<p class="form-tip">{{ $t('knowledgeEditor.wiki.synthesisModelTip') }}</p>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label class="form-label">{{ $t('knowledgeEditor.wiki.languageLabel') }}</label>
|
||||
<t-radio-group v-model="formData.wikiConfig.wikiLanguage">
|
||||
<t-radio-button value="auto">Auto</t-radio-button>
|
||||
<t-radio-button value="zh">中文</t-radio-button>
|
||||
<t-radio-button value="en">English</t-radio-button>
|
||||
</t-radio-group>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label class="form-label">{{ $t('knowledgeEditor.wiki.maxPagesLabel') }}</label>
|
||||
<t-input-number v-model="formData.wikiConfig.maxPagesPerIngest" :min="0" :max="50" />
|
||||
<p class="form-tip">{{ $t('knowledgeEditor.wiki.maxPagesTip') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 解析引擎 -->
|
||||
<div v-if="!isFAQ && formData" v-show="currentSection === 'parser'" class="section">
|
||||
<div v-if="!isFAQ && !isWiki && formData" v-show="currentSection === 'parser'" class="section">
|
||||
<KBParserSettings
|
||||
:parser-engine-rules="formData.chunkingConfig.parserEngineRules"
|
||||
@update:parser-engine-rules="handleParserEngineRulesUpdate"
|
||||
@@ -129,7 +171,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 存储引擎 -->
|
||||
<div v-if="!isFAQ && formData" v-show="currentSection === 'storage'" class="section">
|
||||
<div v-if="!isFAQ && !isWiki && formData" v-show="currentSection === 'storage'" class="section">
|
||||
<KBStorageSettings
|
||||
:storage-provider="formData.storageProvider"
|
||||
:has-files="mode === 'edit' && hasFiles"
|
||||
@@ -138,7 +180,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 分块设置 -->
|
||||
<div v-if="!isFAQ" v-show="currentSection === 'chunking'" class="section">
|
||||
<div v-if="!isFAQ && !isWiki" v-show="currentSection === 'chunking'" class="section">
|
||||
<KBChunkingSettings
|
||||
v-if="formData"
|
||||
:config="formData.chunkingConfig"
|
||||
@@ -147,7 +189,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 图谱设置 -->
|
||||
<div v-if="!isFAQ" v-show="currentSection === 'graph'" class="section">
|
||||
<div v-if="!isFAQ && !isWiki" v-show="currentSection === 'graph'" class="section">
|
||||
<GraphSettings
|
||||
v-if="formData"
|
||||
:graph-extract="formData.nodeExtractConfig"
|
||||
@@ -158,7 +200,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 多模态配置 -->
|
||||
<div v-if="!isFAQ" v-show="currentSection === 'multimodal'" class="section">
|
||||
<div v-if="!isFAQ && !isWiki" v-show="currentSection === 'multimodal'" class="section">
|
||||
<div v-if="formData" class="kb-multimodal-settings">
|
||||
<div class="section-header">
|
||||
<h2>{{ $t('knowledgeEditor.multimodal.title') }}</h2>
|
||||
@@ -202,8 +244,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 音视频语音识别(ASR)设置 -->
|
||||
<div v-if="!isFAQ" v-show="currentSection === 'asr'" class="section">
|
||||
<!-- 音频处理(ASR)设置 -->
|
||||
<div v-if="!isFAQ && !isWiki" v-show="currentSection === 'asr'" class="section">
|
||||
<div v-if="formData" class="kb-multimodal-settings">
|
||||
<div class="section-header">
|
||||
<h2>{{ $t('knowledgeEditor.asr.title') }}</h2>
|
||||
@@ -247,7 +289,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 高级设置 -->
|
||||
<div v-if="!isFAQ" v-show="currentSection === 'advanced'" class="section">
|
||||
<div v-if="!isFAQ && !isWiki" v-show="currentSection === 'advanced'" class="section">
|
||||
<KBAdvancedSettings
|
||||
ref="advancedSettingsRef"
|
||||
v-if="formData"
|
||||
@@ -313,7 +355,7 @@ const props = defineProps<{
|
||||
visible: boolean
|
||||
mode: 'create' | 'edit'
|
||||
kbId?: string
|
||||
initialType?: 'document' | 'faq'
|
||||
initialType?: 'document' | 'faq' | 'wiki'
|
||||
}>()
|
||||
|
||||
// Emits
|
||||
@@ -337,6 +379,8 @@ const navItems = computed(() => {
|
||||
]
|
||||
if (formData.value?.type === 'faq') {
|
||||
items.push({ key: 'faq', icon: 'help-circle', label: t('knowledgeEditor.sidebar.faq') })
|
||||
} else if (formData.value?.type === 'wiki') {
|
||||
items.push({ key: 'wiki', icon: 'catalog', label: t('knowledgeEditor.sidebar.wiki') })
|
||||
} else {
|
||||
items.push(
|
||||
{ key: 'parser', icon: 'file-search', label: t('settings.parserEngine') },
|
||||
@@ -364,6 +408,7 @@ const advancedSettingsRef = ref<InstanceType<typeof KBAdvancedSettings>>()
|
||||
// 表单数据
|
||||
const formData = ref<any>(null)
|
||||
const isFAQ = computed(() => formData.value?.type === 'faq')
|
||||
const isWiki = computed(() => formData.value?.type === 'wiki')
|
||||
|
||||
watch(
|
||||
() => formData.value?.type,
|
||||
@@ -376,14 +421,21 @@ watch(
|
||||
if (!['basic', 'models', 'faq'].includes(currentSection.value)) {
|
||||
currentSection.value = 'faq'
|
||||
}
|
||||
} else if (oldType === 'faq' && currentSection.value === 'faq') {
|
||||
} else if (newType === 'wiki') {
|
||||
if (!formData.value.wikiConfig) {
|
||||
formData.value.wikiConfig = { autoIngest: true, synthesisModelId: '', wikiLanguage: 'auto', maxPagesPerIngest: 0 }
|
||||
}
|
||||
if (!['basic', 'models', 'wiki'].includes(currentSection.value)) {
|
||||
currentSection.value = 'wiki'
|
||||
}
|
||||
} else if ((oldType === 'faq' && currentSection.value === 'faq') || (oldType === 'wiki' && currentSection.value === 'wiki')) {
|
||||
currentSection.value = 'basic'
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// 初始化表单数据
|
||||
const initFormData = (type: 'document' | 'faq' = 'document') => {
|
||||
const initFormData = (type: 'document' | 'faq' | 'wiki' = 'document') => {
|
||||
return {
|
||||
type,
|
||||
name: '',
|
||||
@@ -433,6 +485,12 @@ const initFormData = (type: 'document' | 'faq' = 'document') => {
|
||||
enabled: true,
|
||||
questionCount: 3
|
||||
},
|
||||
wikiConfig: {
|
||||
autoIngest: true,
|
||||
synthesisModelId: '',
|
||||
wikiLanguage: 'auto',
|
||||
maxPagesPerIngest: 0,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,7 +526,7 @@ const loadKBData = async () => {
|
||||
hasFiles.value = (filesResult as any)?.total > 0
|
||||
|
||||
// 设置表单数据
|
||||
const kbType = (kb.type as 'document' | 'faq') || 'document'
|
||||
const kbType = (kb.type as 'document' | 'faq' | 'wiki') || 'document'
|
||||
formData.value = {
|
||||
type: kbType,
|
||||
name: kb.name || '',
|
||||
@@ -514,6 +572,12 @@ const loadKBData = async () => {
|
||||
enabled: kb.question_generation_config?.enabled || false,
|
||||
questionCount: kb.question_generation_config?.question_count || 3
|
||||
},
|
||||
wikiConfig: {
|
||||
autoIngest: kb.wiki_config?.auto_ingest ?? true,
|
||||
synthesisModelId: kb.wiki_config?.synthesis_model_id || '',
|
||||
wikiLanguage: kb.wiki_config?.wiki_language || 'auto',
|
||||
maxPagesPerIngest: kb.wiki_config?.max_pages_per_ingest || 0,
|
||||
},
|
||||
}
|
||||
initialStorageProvider.value = formData.value.storageProvider
|
||||
} catch (error) {
|
||||
@@ -698,6 +762,15 @@ const buildSubmitData = () => {
|
||||
}
|
||||
}
|
||||
|
||||
if (formData.value.type === 'wiki') {
|
||||
data.wiki_config = {
|
||||
auto_ingest: formData.value.wikiConfig?.autoIngest ?? true,
|
||||
synthesis_model_id: formData.value.wikiConfig?.synthesisModelId || '',
|
||||
wiki_language: formData.value.wikiConfig?.wikiLanguage || 'auto',
|
||||
max_pages_per_ingest: formData.value.wikiConfig?.maxPagesPerIngest || 0,
|
||||
}
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
@@ -756,7 +829,7 @@ const doSubmit = async () => {
|
||||
throw new Error(t('knowledgeEditor.messages.missingId'))
|
||||
}
|
||||
|
||||
// 1. 更新基本信息(名称、描述)和 FAQ 配置
|
||||
// 1. 更新基本信息(名称、描述)和 FAQ/Wiki 配置
|
||||
const updateConfig: any = {}
|
||||
if (formData.value.type === 'faq' && formData.value.faqConfig) {
|
||||
updateConfig.faq_config = {
|
||||
@@ -764,6 +837,14 @@ const doSubmit = async () => {
|
||||
question_index_mode: formData.value.faqConfig.questionIndexMode || 'separate'
|
||||
}
|
||||
}
|
||||
if (formData.value.type === 'wiki' && formData.value.wikiConfig) {
|
||||
updateConfig.wiki_config = {
|
||||
auto_ingest: formData.value.wikiConfig.autoIngest ?? true,
|
||||
synthesis_model_id: formData.value.wikiConfig.synthesisModelId || '',
|
||||
wiki_language: formData.value.wikiConfig.wikiLanguage || 'auto',
|
||||
max_pages_per_ingest: formData.value.wikiConfig.maxPagesPerIngest || 0,
|
||||
}
|
||||
}
|
||||
await updateKnowledgeBase(props.kbId, {
|
||||
name: data.name,
|
||||
description: data.description,
|
||||
|
||||
Reference in New Issue
Block a user