feat: Enhance chunk management and FAQ import functionality
- Updated chunk repository methods to support deletion of unindexed chunks and listing all FAQ chunks by knowledge ID. - Introduced batch update functionality for chunks in the chunk service. - Enhanced FAQ import logic to handle append and replace operations, improving efficiency and data integrity. - Added content hash calculation for FAQ entries to facilitate quick matching and deduplication. - Refactored related methods to streamline the import process and improve logging for better tracking of import tasks.
This commit is contained in:
@@ -186,6 +186,26 @@ func (s *chunkService) UpdateChunk(ctx context.Context, chunk *types.Chunk) erro
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateChunks updates chunks in batch
|
||||
func (s *chunkService) UpdateChunks(ctx context.Context, chunks []*types.Chunk) error {
|
||||
if len(chunks) == 0 {
|
||||
return nil
|
||||
}
|
||||
logger.Infof(ctx, "Updating %d chunks in batch", len(chunks))
|
||||
|
||||
// Update the chunks in the repository
|
||||
err := s.chunkRepository.UpdateChunks(ctx, chunks)
|
||||
if err != nil {
|
||||
logger.ErrorWithFields(ctx, err, map[string]interface{}{
|
||||
"chunk_count": len(chunks),
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Infof(ctx, "Successfully updated %d chunks", len(chunks))
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteChunk deletes a chunk by ID
|
||||
// This method removes a specific chunk from the repository
|
||||
// Parameters:
|
||||
|
||||
Reference in New Issue
Block a user