Skip to content

Commit

Permalink
feat(catelog): make topK default 5 (#62)
Browse files Browse the repository at this point in the history
Because

user may not know how to use topk parameter.

This commit

mke topK default 5 when it is not provided.
  • Loading branch information
Yougigun authored Aug 5, 2024
1 parent a549dae commit 02259e1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/milvus/milvus.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type MilvusClientI interface {
DropKnowledgeBaseCollection(ctx context.Context, kbUID string) error
ListEmbeddings(ctx context.Context, collectionName string) ([]Embedding, error)
SearchSimilarEmbeddings(ctx context.Context, collectionName string, vectors [][]float32, topK int) ([][]SimilarEmbedding, error)
// SearchSimilarEmbeddingsInKB search similar embeddings in knowledge base.
// The topK has default value 5
SearchSimilarEmbeddingsInKB(ctx context.Context, kbUID string, vectors [][]float32, topK int) ([][]SimilarEmbedding, error)
DeleteEmbedding(ctx context.Context, collectionName string, embeddingUID []string) error
DeleteEmbeddingsInKb(ctx context.Context, kbUID string, embeddingUID []string) error
Expand Down Expand Up @@ -319,7 +321,12 @@ type SimilarEmbedding struct {
}

// SearchSimilarEmbeddings searches for embeddings similar to the input vector
// topk has default value 5, when topk <= 0, it will be set to 5.
func (m *MilvusClient) SearchSimilarEmbeddings(ctx context.Context, collectionName string, vectors [][]float32, topK int) ([][]SimilarEmbedding, error) {
// set default topK
if topK <= 0 {
topK = 5
}
log, err := logger.GetZapLogger(ctx)
if err != nil {
log.Error("failed to get logger", zap.Error(err))
Expand Down

0 comments on commit 02259e1

Please sign in to comment.