feat(knowledge): implement knowledge item rebuild confirmation dialog and enhance chunk processing options

- Added a confirmation dialog for rebuilding knowledge items in the KnowledgeBase component.
- Introduced new state variables to manage the rebuild process and item selection.
- Enhanced the processChunks function to support question generation options based on configuration.
- Updated the knowledge service to handle question generation settings during document processing.
This commit is contained in:
wizardchen
2026-03-23 19:21:46 +08:00
committed by lyingbug
parent 0e01a8ca64
commit b02e3f1dbb
2 changed files with 59 additions and 9 deletions
+21 -2
View File
@@ -1344,7 +1344,15 @@ func (s *knowledgeService) processDocumentFromPassage(ctx context.Context,
start = end
}
// Process and store chunks
s.processChunks(ctx, kb, knowledge, chunks)
var opts ProcessChunksOptions
if kb.QuestionGenerationConfig != nil && kb.QuestionGenerationConfig.Enabled {
opts.EnableQuestionGeneration = true
opts.QuestionCount = kb.QuestionGenerationConfig.QuestionCount
if opts.QuestionCount <= 0 {
opts.QuestionCount = 3
}
}
s.processChunks(ctx, kb, knowledge, chunks, opts)
}
// ProcessChunksOptions contains options for processing chunks
@@ -6848,6 +6856,13 @@ func (s *knowledgeService) triggerManualProcessing(ctx context.Context,
EnableMultimodel: kb.IsMultimodalEnabled() && len(resolvedImages) > 0,
StoredImages: resolvedImages,
}
if kb.QuestionGenerationConfig != nil && kb.QuestionGenerationConfig.Enabled {
opts.EnableQuestionGeneration = true
opts.QuestionCount = kb.QuestionGenerationConfig.QuestionCount
if opts.QuestionCount <= 0 {
opts.QuestionCount = 3
}
}
if kb.ChunkingConfig.EnableParentChild {
parentCfg, childCfg := buildParentChildConfigs(kb.ChunkingConfig, chunkCfg)
@@ -7473,7 +7488,11 @@ func (s *knowledgeService) ProcessDocument(ctx context.Context, t *asynq.Task) e
})
start = end
}
s.processChunks(ctx, kb, knowledge, passageChunks)
passageOpts := ProcessChunksOptions{
EnableQuestionGeneration: payload.EnableQuestionGeneration,
QuestionCount: payload.QuestionCount,
}
s.processChunks(ctx, kb, knowledge, passageChunks, passageOpts)
return nil
} else {
// File import