collection.add
def add(
ids: OneOrMany[ID],
embeddings: OneOrMany[Embedding] | OneOrMany[PyEmbedding] | None = None,
metadatas: OneOrMany[Metadata] | None = None,
documents: OneOrMany[Document] | None = None,
images: OneOrMany[Image] | None = None,
uris: OneOrMany[URI] | None = None
) -> None
collection.add(
ids=["1", "2", "3"],
documents=["doc1", "doc2", "doc3"],
embeddings=[[0.1,0.2,0.3], [0.4,0.5,0.6], [0.7,0.8,0.9]],
metadatas=[{"tag": "a"}, {"tag": "b"}, {"tag": "c"}]
)
Add embeddings to the data store.
Args
ids
The ids of the embeddings you wish to add
embeddings
The embeddings to add. If None, embeddings will be computed based on the documents or images using the embedding_function set for the Collection. Optional.
metadatas
The metadata to associate with the embeddings. When querying, you can filter on this metadata. Optional.
documents
The documents to associate with the embeddings. Optional.
images
The images to associate with the embeddings. Optional.
uris
The uris of the images to associate with the embeddings. Optional.
Returns
output
None
Raises
ValueError
If you don't provide either embeddings or documents
ValueError
If the length of ids, embeddings, metadatas, or documents don't match
ValueError
If you don't provide an embedding function and don't provide embeddings
ValueError
If you provide both embeddings and documents
ValueError
If you provide an id that already exists