From 9745b5894dca1b4d09670d2b3f46b4de77f64106 Mon Sep 17 00:00:00 2001 From: axiangcoding Date: Fri, 8 Mar 2024 00:48:25 +0800 Subject: [PATCH] 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 --- libs/community/langchain_community/vectorstores/chroma.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/chroma.py b/libs/community/langchain_community/vectorstores/chroma.py index abd64f56275..3bcb389cff5 100644 --- a/libs/community/langchain_community/vectorstores/chroma.py +++ b/libs/community/langchain_community/vectorstores/chroma.py @@ -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