feat(repository): add TagID and IsRecommended fields to vector embeddings

- Introduced `TagID` and `IsRecommended` fields across various repository implementations (Elasticsearch, Milvus, Postgres, Qdrant, SQLite) to enhance document categorization and recommendation capabilities.
- Updated the logic for handling `IsEnabled` to ensure it reflects the actual state from the source data.
- Adjusted the knowledge service to incorporate the new `IsRecommended` field, improving the indexing process for knowledge chunks.

These changes enhance the flexibility and functionality of document retrieval and indexing across the application.
This commit is contained in:
wizardchen
2026-03-02 21:40:28 +08:00
committed by lyingbug
parent 7b8a78aa2a
commit 931bd38138
6 changed files with 25 additions and 6 deletions
@@ -797,6 +797,10 @@ func (q *qdrantRepository) CopyIndices(ctx context.Context,
targetSourceID = uuid.New().String()
}
isEnabled := true
if v, ok := payload[fieldIsEnabled]; ok {
isEnabled = v.GetBoolValue()
}
newPayload := qdrant.NewValueMap(map[string]any{
fieldContent: payload[fieldContent].GetStringValue(),
fieldSourceID: targetSourceID,
@@ -804,7 +808,8 @@ func (q *qdrantRepository) CopyIndices(ctx context.Context,
fieldChunkID: targetChunkID,
fieldKnowledgeID: targetKnowledgeID,
fieldKnowledgeBaseID: targetKnowledgeBaseID,
fieldIsEnabled: true,
fieldTagID: payload[fieldTagID].GetStringValue(),
fieldIsEnabled: isEnabled,
})
var vectors *qdrant.Vectors
@@ -923,7 +928,7 @@ func toQdrantVectorEmbedding(embedding *types.IndexInfo, additionalParams map[st
KnowledgeID: embedding.KnowledgeID,
KnowledgeBaseID: embedding.KnowledgeBaseID,
TagID: embedding.TagID,
IsEnabled: true, // Default to enabled
IsEnabled: embedding.IsEnabled,
}
if additionalParams != nil && slices.Contains(slices.Collect(maps.Keys(additionalParams)), fieldEmbedding) {
if embeddingMap, ok := additionalParams[fieldEmbedding].(map[string][]float32); ok {