community[patch]: Chroma use uuid4 instead of uuid1 to generate random ids (#18723)

- **Description:** Chroma use uuid4 instead of uuid1 as random ids. Use
uuid1 may leak mac address, changing to uuid4 will not cause other
effects.
  - **Issue:** None
  - **Dependencies:** None
  - **Twitter handle:** None
This commit is contained in:
axiangcoding 2024-03-08 00:48:25 +08:00 committed by GitHub
parent 1af2130ff7
commit 9745b5894d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -187,7 +187,7 @@ class Chroma(VectorStore):
b64_texts = [self.encode_image(uri=uri) for uri in uris]
# Populate IDs
if ids is None:
ids = [str(uuid.uuid1()) for _ in uris]
ids = [str(uuid.uuid4()) for _ in uris]
embeddings = None
# Set embeddings
if self._embedding_function is not None and hasattr(
@ -268,7 +268,7 @@ class Chroma(VectorStore):
"""
# TODO: Handle the case where the user doesn't provide ids on the Collection
if ids is None:
ids = [str(uuid.uuid1()) for _ in texts]
ids = [str(uuid.uuid4()) for _ in texts]
embeddings = None
texts = list(texts)
if self._embedding_function is not None:
@ -721,7 +721,7 @@ class Chroma(VectorStore):
**kwargs,
)
if ids is None:
ids = [str(uuid.uuid1()) for _ in texts]
ids = [str(uuid.uuid4()) for _ in texts]
if hasattr(
chroma_collection._client, "max_batch_size"
): # for Chroma 0.4.10 and above