You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Create a new record set with to hold the records to insertrs, err:=types.NewRecordSet(
types.WithEmbeddingFunction(newCollection.EmbeddingFunction), // we pass the embedding function from the collectiontypes.WithIDGenerator(types.NewULIDGenerator()),
)
iferr!=nil {
log.Fatalf("Error creating record set: %s \n", err)
}
// Add a few records to the record setrs.WithRecord(types.WithDocument("My name is John. And I have two dogs."), types.WithMetadata("key1", "value1"))
rs.WithRecord(types.WithDocument("My name is Jane. I am a data scientist."), types.WithMetadata("key2", "value2"))
// Build and validate the record set (this will create embeddings if not already present)_, err=rs.BuildAndValidate(context.TODO())
iferr!=nil {
log.Fatalf("Error validating record set: %s \n", err)
}
// Add the records to the collection_, err=newCollection.AddRecords(context.Background(), rs)
iferr!=nil {
log.Fatalf("Error adding documents: %s \n", err)
}
Can we simplify it?
The text was updated successfully, but these errors were encountered:
This code is way too verbose:
Can we simplify it?
The text was updated successfully, but these errors were encountered: