feat: Enhance wiki extraction and configuration options
- Introduced extraction granularity settings in the wiki configuration, allowing users to control the level of detail in entity and concept extraction (focused, standard, exhaustive). - Updated the UI to reflect these new options, including tooltips for better user guidance. - Refactored the knowledge base editor to support the new extraction granularity feature, ensuring a seamless user experience. - Improved the backend logic for wiki ingest tasks to utilize the new granularity settings, enhancing the accuracy of extracted content. - Added tests to validate the new extraction granularity functionality and ensure robust performance across different configurations.
This commit is contained in:
@@ -29,11 +29,9 @@ export function createKnowledgeBase(data: {
|
||||
extract_config?: any;
|
||||
faq_config?: { index_mode: string; question_index_mode?: string };
|
||||
wiki_config?: {
|
||||
enabled: boolean;
|
||||
auto_ingest?: boolean;
|
||||
synthesis_model_id?: string;
|
||||
wiki_language?: string;
|
||||
max_pages_per_ingest?: number;
|
||||
extraction_granularity?: 'focused' | 'standard' | 'exhaustive';
|
||||
};
|
||||
indexing_strategy?: {
|
||||
vector_enabled: boolean;
|
||||
@@ -60,11 +58,9 @@ export function updateKnowledgeBase(id: string, data: {
|
||||
image_processing_config?: any;
|
||||
faq_config?: any;
|
||||
wiki_config?: {
|
||||
enabled: boolean;
|
||||
auto_ingest?: boolean;
|
||||
synthesis_model_id?: string;
|
||||
wiki_language?: string;
|
||||
max_pages_per_ingest?: number;
|
||||
extraction_granularity?: 'focused' | 'standard' | 'exhaustive';
|
||||
};
|
||||
indexing_strategy?: {
|
||||
vector_enabled: boolean;
|
||||
|
||||
@@ -1598,16 +1598,20 @@ export default {
|
||||
wiki: {
|
||||
title: 'Wiki Settings',
|
||||
description: 'Configure Wiki auto-generation preferences',
|
||||
enableLabel: 'Enable Wiki',
|
||||
enableTip: 'When enabled, uploading documents will auto-generate interlinked wiki knowledge pages',
|
||||
autoIngestLabel: 'Auto Ingest',
|
||||
autoIngestTip: 'When enabled, uploading new documents automatically triggers Wiki page generation/update',
|
||||
synthesisModelLabel: 'Wiki Synthesis Model',
|
||||
synthesisModelPlaceholder: 'Select the LLM model for Wiki generation',
|
||||
synthesisModelTip: 'Falls back to the summary model if not set',
|
||||
languageLabel: 'Wiki Language',
|
||||
maxPagesLabel: 'Max Pages Per Ingest',
|
||||
maxPagesTip: 'Maximum number of pages to create/update per ingest (0 = no limit)',
|
||||
extractionGranularityLabel: 'Extraction Granularity',
|
||||
extractionGranularityTip: 'Controls how many Wiki entities/concepts are extracted per document. Finer = tighter index, coarser = more comprehensive',
|
||||
granularityFocused: 'Focused',
|
||||
granularityStandard: 'Standard',
|
||||
granularityExhaustive: 'Exhaustive',
|
||||
granularityFocusedHint: 'Extract only the document\u2019s main subjects (e.g. a resume yields the person and their projects). Cleanest, may miss secondary entities.',
|
||||
granularityStandardHint: 'Main subjects plus secondary entities/concepts that receive substantial discussion. Skips name-dropped terms. Recommended default.',
|
||||
granularityExhaustiveHint: 'Extract every named entity and concept, including passing mentions of stacks/tools. Use when the KB serves as a glossary.',
|
||||
},
|
||||
indexing: {
|
||||
title: 'Indexing Strategy',
|
||||
|
||||
@@ -2119,16 +2119,20 @@ export default {
|
||||
wiki: {
|
||||
title: "Wiki 설정",
|
||||
description: "Wiki 자동 생성 환경설정을 구성합니다",
|
||||
enableLabel: "Wiki 활성화",
|
||||
enableTip: "활성화하면 문서 업로드 시 자동으로 상호 연결된 Wiki 지식 페이지가 생성됩니다",
|
||||
autoIngestLabel: "자동 Ingest",
|
||||
autoIngestTip: "활성화하면 새 문서 업로드 시 자동으로 Wiki 페이지가 생성/업데이트됩니다",
|
||||
synthesisModelLabel: "합성 모델",
|
||||
synthesisModelPlaceholder: "Wiki 생성에 사용할 LLM 모델을 선택하세요",
|
||||
synthesisModelTip: "설정하지 않으면 요약 모델로 대체됩니다",
|
||||
languageLabel: "Wiki 언어",
|
||||
maxPagesLabel: "Ingest당 최대 페이지 수",
|
||||
maxPagesTip: "Ingest당 생성/업데이트할 최대 페이지 수 (0 = 제한 없음)",
|
||||
extractionGranularityLabel: "추출 세분화 수준",
|
||||
extractionGranularityTip: "문서당 추출되는 Wiki 엔티티/개념 수를 제어합니다. 세밀할수록 인덱스가 간결하고, 거칠수록 포괄적입니다",
|
||||
granularityFocused: "집중",
|
||||
granularityStandard: "표준",
|
||||
granularityExhaustive: "상세",
|
||||
granularityFocusedHint: "문서의 주요 주체만 추출합니다 (예: 이력서 → 인물과 프로젝트). 가장 깔끔하지만 부수 엔티티는 누락될 수 있습니다.",
|
||||
granularityStandardHint: "주요 주체 + 상세히 논의된 부수 엔티티/개념. 지나가듯 언급된 용어는 생략합니다. 권장 기본값입니다.",
|
||||
granularityExhaustiveHint: "스쳐 지나가는 기술 스택 언급을 포함해 명명된 모든 엔티티와 개념을 추출합니다. KB를 용어집으로 사용할 때 적합합니다.",
|
||||
},
|
||||
wikiBrowser: {
|
||||
tabDocuments: "문서",
|
||||
|
||||
@@ -1798,16 +1798,20 @@ export default {
|
||||
wiki: {
|
||||
title: 'Wiki настройки',
|
||||
description: 'Настройте автоматическую генерацию Wiki',
|
||||
enableLabel: 'Включить Wiki',
|
||||
enableTip: 'При включении загрузка документов автоматически создаст связанные Wiki-страницы',
|
||||
autoIngestLabel: 'Автоматический Ingest',
|
||||
autoIngestTip: 'При загрузке новых документов автоматически создаются/обновляются Wiki-страницы',
|
||||
synthesisModelLabel: 'Модель синтеза',
|
||||
synthesisModelPlaceholder: 'Выберите LLM модель для генерации Wiki',
|
||||
synthesisModelTip: 'Если не указано, используется модель суммаризации',
|
||||
languageLabel: 'Язык Wiki',
|
||||
maxPagesLabel: 'Макс. страниц за Ingest',
|
||||
maxPagesTip: 'Максимальное количество страниц для создания/обновления за одну операцию (0 = без ограничения)',
|
||||
extractionGranularityLabel: 'Детализация извлечения',
|
||||
extractionGranularityTip: 'Управляет количеством извлекаемых сущностей/концепций на документ. Точнее — компактный индекс, грубее — более полный',
|
||||
granularityFocused: 'Фокус',
|
||||
granularityStandard: 'Стандарт',
|
||||
granularityExhaustive: 'Полный',
|
||||
granularityFocusedHint: 'Извлекает только главные темы документа (например, резюме → человек и его проекты). Самый чистый результат, возможны пропуски.',
|
||||
granularityStandardHint: 'Главные темы плюс подробно обсуждаемые сущности/концепции. Пропускает упомянутые вскользь. Рекомендуемое значение.',
|
||||
granularityExhaustiveHint: 'Извлекает все именованные сущности и концепции, включая мимоходом упомянутые технологии. Подходит для глоссария.',
|
||||
},
|
||||
wikiBrowser: {
|
||||
tabDocuments: 'Документы',
|
||||
|
||||
@@ -2123,16 +2123,20 @@ export default {
|
||||
wiki: {
|
||||
title: "Wiki 设置",
|
||||
description: "配置 Wiki 知识库的自动生成偏好",
|
||||
enableLabel: "启用 Wiki",
|
||||
enableTip: "开启后,上传文档时将自动生成互相关联的 Wiki 知识页面",
|
||||
autoIngestLabel: "自动 Ingest",
|
||||
autoIngestTip: "开启后,新文档上传后自动触发 Wiki 页面生成/更新",
|
||||
synthesisModelLabel: "Wiki 合成模型",
|
||||
synthesisModelPlaceholder: "选择用于 Wiki 生成的 LLM 模型",
|
||||
synthesisModelTip: "不设置时将回退使用摘要模型",
|
||||
languageLabel: "Wiki 语言",
|
||||
maxPagesLabel: "单次最大页面数",
|
||||
maxPagesTip: "每次 Ingest 最多创建/更新的页面数(0 表示不限制)",
|
||||
extractionGranularityLabel: "提取粒度",
|
||||
extractionGranularityTip: "控制每篇文档抽取的 Wiki 实体/概念数量。粒度越细,索引越聚焦;粒度越粗,索引越详尽",
|
||||
granularityFocused: "聚焦",
|
||||
granularityStandard: "标准",
|
||||
granularityExhaustive: "详尽",
|
||||
granularityFocusedHint: "只抽取文档的主角(如简历 → 人物和项目)。最干净,但可能漏掉次要实体。",
|
||||
granularityStandardHint: "抽取主角 + 被详细描述的次要实体/概念。跳过一带而过的通用名词。适合大多数场景。",
|
||||
granularityExhaustiveHint: "抽取所有可识别的命名实体与概念,包括一带而过的技术栈。适合将知识库当作术语表使用。",
|
||||
},
|
||||
indexing: {
|
||||
title: "索引策略",
|
||||
|
||||
@@ -45,7 +45,7 @@ const uploading = ref(false);
|
||||
const kbLoading = ref(false);
|
||||
const docListLoading = ref(true);
|
||||
const isFAQ = computed(() => (kbInfo.value?.type || '') === 'faq');
|
||||
const isWiki = computed(() => !!kbInfo.value?.wiki_config?.enabled);
|
||||
const isWiki = computed(() => !!kbInfo.value?.indexing_strategy?.wiki_enabled);
|
||||
const validTabs = ['documents', 'wiki', 'graph'] as const
|
||||
type KbTab = typeof validTabs[number]
|
||||
const initTab = validTabs.includes(route.query.tab as any) ? (route.query.tab as KbTab) : 'documents'
|
||||
|
||||
@@ -93,6 +93,28 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Wiki 提取粒度 (仅当 Wiki 启用时显示) -->
|
||||
<div v-if="!isFAQ && formData.indexingStrategy.wikiEnabled" class="form-item">
|
||||
<label class="form-label">{{ $t('knowledgeEditor.wiki.extractionGranularityLabel') }}</label>
|
||||
<p class="form-tip">{{ $t('knowledgeEditor.wiki.extractionGranularityTip') }}</p>
|
||||
<t-radio-group
|
||||
:value="resolvedGranularity"
|
||||
class="granularity-radio-group"
|
||||
@change="handleGranularityChange"
|
||||
>
|
||||
<t-radio-button value="focused">
|
||||
{{ $t('knowledgeEditor.wiki.granularityFocused') }}
|
||||
</t-radio-button>
|
||||
<t-radio-button value="standard">
|
||||
{{ $t('knowledgeEditor.wiki.granularityStandard') }}
|
||||
</t-radio-button>
|
||||
<t-radio-button value="exhaustive">
|
||||
{{ $t('knowledgeEditor.wiki.granularityExhaustive') }}
|
||||
</t-radio-button>
|
||||
</t-radio-group>
|
||||
<p class="form-tip granularity-hint">{{ granularityHint }}</p>
|
||||
</div>
|
||||
|
||||
<div class="form-item">
|
||||
<label class="form-label required">{{ $t('knowledgeEditor.basic.nameLabel') }}</label>
|
||||
<t-input
|
||||
@@ -482,10 +504,9 @@ const initFormData = (type: 'document' | 'faq' = 'document') => {
|
||||
questionCount: 3
|
||||
},
|
||||
wikiConfig: {
|
||||
enabled: false,
|
||||
autoIngest: true,
|
||||
synthesisModelId: '',
|
||||
maxPagesPerIngest: 0,
|
||||
extractionGranularity: 'standard' as 'focused' | 'standard' | 'exhaustive',
|
||||
},
|
||||
indexingStrategy: {
|
||||
vectorEnabled: true,
|
||||
@@ -576,10 +597,14 @@ const loadKBData = async () => {
|
||||
questionCount: kb.question_generation_config?.question_count || 3
|
||||
},
|
||||
wikiConfig: {
|
||||
enabled: kb.wiki_config?.enabled ?? false,
|
||||
autoIngest: kb.wiki_config?.auto_ingest ?? true,
|
||||
synthesisModelId: kb.wiki_config?.synthesis_model_id || '',
|
||||
maxPagesPerIngest: kb.wiki_config?.max_pages_per_ingest || 0,
|
||||
extractionGranularity: (
|
||||
kb.wiki_config?.extraction_granularity === 'focused' ||
|
||||
kb.wiki_config?.extraction_granularity === 'exhaustive'
|
||||
? kb.wiki_config.extraction_granularity
|
||||
: 'standard'
|
||||
) as 'focused' | 'standard' | 'exhaustive',
|
||||
},
|
||||
indexingStrategy: {
|
||||
vectorEnabled: kb.indexing_strategy?.vector_enabled ?? true,
|
||||
@@ -606,6 +631,39 @@ const handleModelConfigUpdate = (config: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
// 粒度选择器:从 formData.wikiConfig 读出并规范化,未知值回退到 'standard',
|
||||
// 与后端 WikiExtractionGranularity.Normalize() 的契约保持一致。
|
||||
const resolvedGranularity = computed<'focused' | 'standard' | 'exhaustive'>(() => {
|
||||
const g = formData.value?.wikiConfig?.extractionGranularity
|
||||
if (g === 'focused' || g === 'standard' || g === 'exhaustive') {
|
||||
return g
|
||||
}
|
||||
return 'standard'
|
||||
})
|
||||
|
||||
const granularityHint = computed<string>(() => {
|
||||
switch (resolvedGranularity.value) {
|
||||
case 'focused':
|
||||
return t('knowledgeEditor.wiki.granularityFocusedHint')
|
||||
case 'exhaustive':
|
||||
return t('knowledgeEditor.wiki.granularityExhaustiveHint')
|
||||
default:
|
||||
return t('knowledgeEditor.wiki.granularityStandardHint')
|
||||
}
|
||||
})
|
||||
|
||||
const handleGranularityChange = (value: string | number | boolean) => {
|
||||
if (!formData.value) return
|
||||
const next: 'focused' | 'standard' | 'exhaustive' =
|
||||
value === 'focused' || value === 'exhaustive'
|
||||
? (value as 'focused' | 'exhaustive')
|
||||
: 'standard'
|
||||
formData.value.wikiConfig = {
|
||||
...formData.value.wikiConfig,
|
||||
extractionGranularity: next,
|
||||
}
|
||||
}
|
||||
|
||||
const isIndexingLocked = computed(() => props.mode === 'edit' && hasFiles.value)
|
||||
|
||||
const toggleVectorIndexing = () => {
|
||||
@@ -795,14 +853,13 @@ const buildSubmitData = () => {
|
||||
}
|
||||
}
|
||||
|
||||
// Always send wiki_config so enabled/disabled state is persisted
|
||||
// Sync wiki_config.enabled from indexingStrategy.wikiEnabled
|
||||
// Wiki enablement is carried solely by indexing_strategy.wiki_enabled.
|
||||
// wiki_config only holds wiki-specific tunables.
|
||||
if (formData.value.type !== 'faq') {
|
||||
data.wiki_config = {
|
||||
enabled: formData.value.indexingStrategy?.wikiEnabled ?? false,
|
||||
auto_ingest: formData.value.wikiConfig?.autoIngest ?? true,
|
||||
synthesis_model_id: formData.value.modelConfig?.wikiSynthesisModelId || '',
|
||||
max_pages_per_ingest: formData.value.wikiConfig?.maxPagesPerIngest || 0,
|
||||
extraction_granularity: formData.value.wikiConfig?.extractionGranularity || 'standard',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -895,10 +952,9 @@ const doSubmit = async () => {
|
||||
}
|
||||
if (formData.value.wikiConfig && formData.value.type !== 'faq') {
|
||||
updateConfig.wiki_config = {
|
||||
enabled: formData.value.indexingStrategy?.wikiEnabled ?? false,
|
||||
auto_ingest: formData.value.wikiConfig.autoIngest ?? true,
|
||||
synthesis_model_id: formData.value.modelConfig?.wikiSynthesisModelId || '',
|
||||
max_pages_per_ingest: formData.value.wikiConfig.maxPagesPerIngest || 0,
|
||||
extraction_granularity: formData.value.wikiConfig.extractionGranularity || 'standard',
|
||||
}
|
||||
}
|
||||
if (formData.value.type !== 'faq') {
|
||||
@@ -1278,6 +1334,18 @@ watch(
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
|
||||
.granularity-radio-group {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.granularity-hint {
|
||||
margin-top: 8px;
|
||||
line-height: 1.6;
|
||||
color: var(--td-text-color-secondary);
|
||||
white-space: normal;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.indexing-checks {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
||||
|
||||
@@ -103,11 +103,9 @@ const emit = defineEmits<{
|
||||
const uiStore = useUIStore()
|
||||
const { t } = useI18n()
|
||||
|
||||
// 引用各个模型选择器
|
||||
const llmSelectorRef = ref<InstanceType<typeof ModelSelector>>()
|
||||
const embeddingSelectorRef = ref<InstanceType<typeof ModelSelector>>()
|
||||
|
||||
// 处理LLM模型变化
|
||||
const handleLLMChange = (modelId: string) => {
|
||||
emit('update:config', {
|
||||
...props.config,
|
||||
@@ -115,7 +113,6 @@ const handleLLMChange = (modelId: string) => {
|
||||
})
|
||||
}
|
||||
|
||||
// 处理Embedding模型变化
|
||||
const handleEmbeddingChange = (modelId: string) => {
|
||||
emit('update:config', {
|
||||
...props.config,
|
||||
@@ -123,7 +120,6 @@ const handleEmbeddingChange = (modelId: string) => {
|
||||
})
|
||||
}
|
||||
|
||||
// 处理Wiki合成模型变化
|
||||
const handleWikiModelChange = (modelId: string) => {
|
||||
emit('update:config', {
|
||||
...props.config,
|
||||
@@ -131,13 +127,9 @@ const handleWikiModelChange = (modelId: string) => {
|
||||
})
|
||||
}
|
||||
|
||||
// 处理添加模型按钮点击
|
||||
const handleAddModel = (subSection: string) => {
|
||||
// 打开全局设置对话框,并导航到对应的模型子页面
|
||||
uiStore.openSettings('models', subSection)
|
||||
}
|
||||
|
||||
// 由于使用了 allModels prop,不再需要单独刷新各个选择器
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
Reference in New Issue
Block a user