refactor: improve knowledge base index removal and streamline vector handling logic

This commit is contained in:
mlogclub
2026-06-02 11:47:35 +08:00
parent c2d05863ba
commit 99d5a951be
4 changed files with 35 additions and 37 deletions
-12
View File
@@ -12,8 +12,6 @@ import (
"agent-desk/internal/pkg/enums"
"agent-desk/internal/ai"
"github.com/mlogclub/simple/common/strs"
)
func (s *index) buildDocumentChunkRequest(document models.KnowledgeDocument, knowledgeBase models.KnowledgeBase) *ragchunk.ChunkRequest {
@@ -45,16 +43,6 @@ func (s *index) buildDocumentChunks(ctx context.Context, document models.Knowled
return chunks, nil
}
func (s *index) collectExistingVectorIDs(chunks []models.KnowledgeChunk) []string {
ret := make([]string, 0, len(chunks))
for _, chunk := range chunks {
if strs.IsNotBlank(chunk.VectorID) {
ret = append(ret, chunk.VectorID)
}
}
return ret
}
func (s *index) prepareDocumentVectors(ctx context.Context, knowledgeBase models.KnowledgeBase, document models.KnowledgeDocument, chunks []ragchunk.ChunkResult) ([]vectordb.Vector, []models.KnowledgeChunk, int, error) {
vectors := make([]vectordb.Vector, 0, len(chunks))
chunkModels := make([]models.KnowledgeChunk, 0, len(chunks))