Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix metadatas validation in AddConcurrently()
  • Loading branch information
philippgille committed Mar 4, 2024
commit 5f1568b617eefa77963e648514842c6e38c9a779
9 changes: 7 additions & 2 deletions collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,13 @@ func (c *Collection) AddConcurrently(ctx context.Context, ids []string, embeddin
// Assign empty slice so we can simply access via index later
embeddings = make([][]float32, len(ids))
}
if len(metadatas) != 0 && len(ids) != len(metadatas) {
return errors.New("ids, metadatas and contents must have the same length")
if len(metadatas) != 0 {
if len(ids) != len(metadatas) {
return errors.New("when metadatas is not empty it must have the same length as ids")
}
} else {
// Assign empty slice so we can simply access via index later
metadatas = make([]map[string]string, len(ids))
}
if len(contents) != 0 {
if len(contents) != len(ids) {
Expand Down