Skip to content

Commit

Permalink
Merge pull request #35 from philippgille/fix-metadatas-validation
Browse files Browse the repository at this point in the history
Fix metadatas validation in AddConcurrently()
  • Loading branch information
philippgille authored Mar 4, 2024
2 parents ed5dca6 + 5f1568b commit 7ec2813
Showing 1 changed file with 7 additions and 2 deletions.
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

0 comments on commit 7ec2813

Please sign in to comment.