feat(frontend): expose chunking strategy in KB editor
Surfaces the adaptive 3-tier chunking controls in the existing "Chunking" section of the KB editor modal. Users can now pick a strategy from a dropdown without crafting JSON for the API: - Automatic (recommended) → backend profiler picks the tier - Markdown-optimized → forces heading-aware splitting - Smart structure detection → forces heuristic boundary detection - Classic → original recursive splitter (legacy) The fifth backend value `recursive` is intentionally hidden from the UI — it's functionally near `legacy` and would dilute the choice. Advanced options (collapsible, disabled when strategy=legacy): - TokenLimit (0–8192 approx tokens; 0 = char-based budget) - Languages multi-select (DE/EN/ZH; empty = auto-detect) Behaviour: - New KBs default to strategy="auto" - Existing KBs without the field render with empty strategy and keep classic behavior on save unless the user actively picks one - Overlap warning when overlap >= chunkSize/2 Wired through: - KBChunkingSettings.vue: strategy select + advanced collapsible + ChunkingConfig interface extended - KnowledgeBaseEditorModal.vue: form-state defaults, kb-load mapping, buildSubmitData (chunking_config) + updateKBConfig (documentSplitting) pass strategy/token_limit/languages - api/initialization/index.ts: types extended - i18n: en-US / zh-CN / ko-KR / ru-RU all carry strategy + advanced keys (6 keys each) https://claude.ai/code/session_01XADhx6mtu2ZYW3DE9Lun6k
This commit is contained in:
@@ -490,7 +490,11 @@ const initFormData = (type: 'document' | 'faq' = 'document') => {
|
||||
parserEngineRules: undefined as any,
|
||||
enableParentChild: true,
|
||||
parentChunkSize: 4096,
|
||||
childChunkSize: 384
|
||||
childChunkSize: 384,
|
||||
// New KBs default to the adaptive auto-strategy. User can change in the UI.
|
||||
strategy: 'auto' as string,
|
||||
tokenLimit: 0,
|
||||
languages: [] as string[]
|
||||
},
|
||||
storageProvider: '' as string,
|
||||
multimodalConfig: {
|
||||
@@ -587,7 +591,12 @@ const loadKBData = async () => {
|
||||
parserEngineRules: kb.chunking_config?.parser_engine_rules || undefined,
|
||||
enableParentChild: kb.chunking_config?.enable_parent_child || false,
|
||||
parentChunkSize: kb.chunking_config?.parent_chunk_size || 4096,
|
||||
childChunkSize: kb.chunking_config?.child_chunk_size || 384
|
||||
childChunkSize: kb.chunking_config?.child_chunk_size || 384,
|
||||
// Existing KBs without strategy field render as empty (= legacy behavior).
|
||||
// The user has to actively pick a value to opt in to the new tiers.
|
||||
strategy: kb.chunking_config?.strategy || '',
|
||||
tokenLimit: kb.chunking_config?.token_limit || 0,
|
||||
languages: kb.chunking_config?.languages || []
|
||||
},
|
||||
storageProvider: (kb.storage_provider_config?.provider || kb.storage_config?.provider || 'local') as string,
|
||||
multimodalConfig: {
|
||||
@@ -840,6 +849,17 @@ const buildSubmitData = () => {
|
||||
enable_parent_child: formData.value.chunkingConfig.enableParentChild,
|
||||
parent_chunk_size: formData.value.chunkingConfig.parentChunkSize,
|
||||
child_chunk_size: formData.value.chunkingConfig.childChunkSize,
|
||||
// Adaptive chunking fields. Empty/zero values are omitted on the
|
||||
// backend side via omitempty; we send them through unconditionally.
|
||||
...(formData.value.chunkingConfig.strategy
|
||||
? { strategy: formData.value.chunkingConfig.strategy }
|
||||
: {}),
|
||||
...(formData.value.chunkingConfig.tokenLimit
|
||||
? { token_limit: formData.value.chunkingConfig.tokenLimit }
|
||||
: {}),
|
||||
...(formData.value.chunkingConfig.languages?.length
|
||||
? { languages: formData.value.chunkingConfig.languages }
|
||||
: {}),
|
||||
...(formData.value.chunkingConfig.parserEngineRules?.length
|
||||
? { parser_engine_rules: formData.value.chunkingConfig.parserEngineRules }
|
||||
: {})
|
||||
@@ -1023,7 +1043,11 @@ const doSubmit = async () => {
|
||||
parserEngineRules: data.chunking_config.parser_engine_rules || undefined,
|
||||
enableParentChild: data.chunking_config.enable_parent_child || false,
|
||||
parentChunkSize: data.chunking_config.parent_chunk_size || 4096,
|
||||
childChunkSize: data.chunking_config.child_chunk_size || 384
|
||||
childChunkSize: data.chunking_config.child_chunk_size || 384,
|
||||
// Adaptive chunking — empty / 0 / [] means "leave server default".
|
||||
strategy: data.chunking_config.strategy || undefined,
|
||||
tokenLimit: data.chunking_config.token_limit || undefined,
|
||||
languages: data.chunking_config.languages?.length ? data.chunking_config.languages : undefined
|
||||
},
|
||||
multimodal: {
|
||||
enabled: !!data.vlm_config?.enabled
|
||||
|
||||
Reference in New Issue
Block a user