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:
wizardchen
2025-11-24 15:47:42 +08:00
parent 385108ce22
commit e56233ef11
9 changed files with 353 additions and 118 deletions
+20
View File
@@ -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: