chroma[patch]: Update logic for assigning ids

This commit is contained in:
Kaiwei Zhang 2024-12-13 16:58:34 -05:00 committed by GitHub
parent 9c55c75eb5
commit b909d54e70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -433,6 +433,8 @@ class Chroma(VectorStore):
# Populate IDs
if ids is None:
ids = [str(uuid.uuid4()) for _ in uris]
else:
ids = [id if id is not None else str(uuid.uuid4()) for id in ids]
embeddings = None
# Set embeddings
if self._embedding_function is not None and hasattr(
@ -519,10 +521,8 @@ class Chroma(VectorStore):
if ids is None:
ids = [str(uuid.uuid4()) for _ in texts]
else:
# Assign strings to any null IDs
for idx, _id in enumerate(ids):
if _id is None:
ids[idx] = str(uuid.uuid4())
ids = [id if id is not None else str(uuid.uuid4()) for id in ids]
embeddings = None
texts = list(texts)
if self._embedding_function is not None:
@ -1169,6 +1169,8 @@ class Chroma(VectorStore):
)
if ids is None:
ids = [str(uuid.uuid4()) for _ in texts]
else:
ids = [id if id is not None else str(uuid.uuid4()) for id in ids]
if hasattr(
chroma_collection._client, "get_max_batch_size"
) or hasattr( # for Chroma 0.5.1 and above