feat: implement parent-child chunking strategy for enhanced context management
- Added support for parent-child chunking in the knowledge base, allowing for a two-level chunking strategy that improves context retrieval. - Introduced new configuration options for enabling parent-child chunking, including parent and child chunk sizes. - Updated relevant components and services to handle parent chunk data, ensuring proper linking and retrieval of child chunks. - Enhanced user interface elements to reflect the new chunking options and provide better user guidance. These changes significantly improve the knowledge extraction process by providing richer context through hierarchical chunking.
This commit is contained in:
@@ -96,6 +96,9 @@ type KBModelConfigRequest struct {
|
||||
ChunkOverlap int `json:"chunkOverlap"`
|
||||
Separators []string `json:"separators"`
|
||||
ParserEngineRules []types.ParserEngineRule `json:"parserEngineRules,omitempty"`
|
||||
EnableParentChild bool `json:"enableParentChild"`
|
||||
ParentChunkSize int `json:"parentChunkSize,omitempty"`
|
||||
ChildChunkSize int `json:"childChunkSize,omitempty"`
|
||||
} `json:"documentSplitting"`
|
||||
|
||||
// 多模态配置(仅模型相关;存储引擎在 storageProvider 中配置)
|
||||
@@ -289,6 +292,13 @@ func (h *InitializationHandler) UpdateKBConfig(c *gin.Context) {
|
||||
kb.ChunkingConfig.Separators = req.DocumentSplitting.Separators
|
||||
}
|
||||
kb.ChunkingConfig.ParserEngineRules = req.DocumentSplitting.ParserEngineRules
|
||||
kb.ChunkingConfig.EnableParentChild = req.DocumentSplitting.EnableParentChild
|
||||
if req.DocumentSplitting.ParentChunkSize > 0 {
|
||||
kb.ChunkingConfig.ParentChunkSize = req.DocumentSplitting.ParentChunkSize
|
||||
}
|
||||
if req.DocumentSplitting.ChildChunkSize > 0 {
|
||||
kb.ChunkingConfig.ChildChunkSize = req.DocumentSplitting.ChildChunkSize
|
||||
}
|
||||
|
||||
// 更新多模态配置
|
||||
if req.Multimodal.Enabled {
|
||||
|
||||
Reference in New Issue
Block a user