mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-04 10:42:55 +00:00
community[patch]: Use uuid4 not uuid1 (#20487)
Using UUID1 is incorrect since it's time dependent, which makes it easy to generate the exact same uuid
This commit is contained in:
parent
f7667c614b
commit
c50099161b
@ -157,7 +157,7 @@ class AnalyticDB(VectorStore):
|
|||||||
List of ids from adding the texts into the vectorstore.
|
List of ids from adding the texts into the vectorstore.
|
||||||
"""
|
"""
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = [str(uuid.uuid1()) for _ in texts]
|
ids = [str(uuid.uuid4()) for _ in texts]
|
||||||
|
|
||||||
embeddings = self.embedding_function.embed_documents(list(texts))
|
embeddings = self.embedding_function.embed_documents(list(texts))
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ class AtlasDB(VectorStore):
|
|||||||
|
|
||||||
texts = list(texts)
|
texts = list(texts)
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = [str(uuid.uuid1()) for _ in texts]
|
ids = [str(uuid.uuid4()) for _ in texts]
|
||||||
|
|
||||||
# Embedding upload case
|
# Embedding upload case
|
||||||
if self._embedding_function is not None:
|
if self._embedding_function is not None:
|
||||||
|
@ -146,7 +146,7 @@ class Bagel(VectorStore):
|
|||||||
"""
|
"""
|
||||||
# creating unique ids if None
|
# creating unique ids if None
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = [str(uuid.uuid1()) for _ in texts]
|
ids = [str(uuid.uuid4()) for _ in texts]
|
||||||
|
|
||||||
texts = list(texts)
|
texts = list(texts)
|
||||||
if self._embedding_function and embeddings is None and texts:
|
if self._embedding_function and embeddings is None and texts:
|
||||||
|
@ -107,7 +107,7 @@ class Dingo(VectorStore):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Embed and create the documents
|
# Embed and create the documents
|
||||||
ids = ids or [str(uuid.uuid1().int)[:13] for _ in texts]
|
ids = ids or [str(uuid.uuid4().int)[:13] for _ in texts]
|
||||||
metadatas_list = []
|
metadatas_list = []
|
||||||
texts = list(texts)
|
texts = list(texts)
|
||||||
embeds = self._embedding.embed_documents(texts)
|
embeds = self._embedding.embed_documents(texts)
|
||||||
@ -347,7 +347,7 @@ class Dingo(VectorStore):
|
|||||||
|
|
||||||
# Embed and create the documents
|
# Embed and create the documents
|
||||||
|
|
||||||
ids = ids or [str(uuid.uuid1().int)[:13] for _ in texts]
|
ids = ids or [str(uuid.uuid4().int)[:13] for _ in texts]
|
||||||
metadatas_list = []
|
metadatas_list = []
|
||||||
texts = list(texts)
|
texts = list(texts)
|
||||||
embeds = embedding.embed_documents(texts)
|
embeds = embedding.embed_documents(texts)
|
||||||
|
@ -80,7 +80,7 @@ class Hologres(VectorStore):
|
|||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> Hologres:
|
) -> Hologres:
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = [str(uuid.uuid1()) for _ in texts]
|
ids = [str(uuid.uuid4()) for _ in texts]
|
||||||
|
|
||||||
if not metadatas:
|
if not metadatas:
|
||||||
metadatas = [{} for _ in texts]
|
metadatas = [{} for _ in texts]
|
||||||
@ -141,7 +141,7 @@ class Hologres(VectorStore):
|
|||||||
List of ids from adding the texts into the vectorstore.
|
List of ids from adding the texts into the vectorstore.
|
||||||
"""
|
"""
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = [str(uuid.uuid1()) for _ in texts]
|
ids = [str(uuid.uuid4()) for _ in texts]
|
||||||
|
|
||||||
embeddings = self.embedding_function.embed_documents(list(texts))
|
embeddings = self.embedding_function.embed_documents(list(texts))
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ class Kinetica(VectorStore):
|
|||||||
Kinetica: An instance of Kinetica class
|
Kinetica: An instance of Kinetica class
|
||||||
"""
|
"""
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = [str(uuid.uuid1()) for _ in texts]
|
ids = [str(uuid.uuid4()) for _ in texts]
|
||||||
|
|
||||||
if not metadatas:
|
if not metadatas:
|
||||||
metadatas = [{} for _ in texts]
|
metadatas = [{} for _ in texts]
|
||||||
@ -330,7 +330,7 @@ class Kinetica(VectorStore):
|
|||||||
kwargs: vectorstore specific parameters
|
kwargs: vectorstore specific parameters
|
||||||
"""
|
"""
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = [str(uuid.uuid1()) for _ in texts]
|
ids = [str(uuid.uuid4()) for _ in texts]
|
||||||
|
|
||||||
if not metadatas:
|
if not metadatas:
|
||||||
metadatas = [{} for _ in texts]
|
metadatas = [{} for _ in texts]
|
||||||
|
@ -441,7 +441,7 @@ class Lantern(VectorStore):
|
|||||||
- Useful for testing.
|
- Useful for testing.
|
||||||
"""
|
"""
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = [str(uuid.uuid1()) for _ in texts]
|
ids = [str(uuid.uuid4()) for _ in texts]
|
||||||
|
|
||||||
if not metadatas:
|
if not metadatas:
|
||||||
metadatas = [{} for _ in texts]
|
metadatas = [{} for _ in texts]
|
||||||
|
@ -237,7 +237,7 @@ class PGEmbedding(VectorStore):
|
|||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> PGEmbedding:
|
) -> PGEmbedding:
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = [str(uuid.uuid1()) for _ in texts]
|
ids = [str(uuid.uuid4()) for _ in texts]
|
||||||
|
|
||||||
if not metadatas:
|
if not metadatas:
|
||||||
metadatas = [{} for _ in texts]
|
metadatas = [{} for _ in texts]
|
||||||
@ -288,7 +288,7 @@ class PGEmbedding(VectorStore):
|
|||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> List[str]:
|
) -> List[str]:
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = [str(uuid.uuid1()) for _ in texts]
|
ids = [str(uuid.uuid4()) for _ in texts]
|
||||||
|
|
||||||
embeddings = self.embedding_function.embed_documents(list(texts))
|
embeddings = self.embedding_function.embed_documents(list(texts))
|
||||||
|
|
||||||
|
@ -471,7 +471,7 @@ class PGVector(VectorStore):
|
|||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> PGVector:
|
) -> PGVector:
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = [str(uuid.uuid1()) for _ in texts]
|
ids = [str(uuid.uuid4()) for _ in texts]
|
||||||
|
|
||||||
if not metadatas:
|
if not metadatas:
|
||||||
metadatas = [{} for _ in texts]
|
metadatas = [{} for _ in texts]
|
||||||
@ -511,7 +511,7 @@ class PGVector(VectorStore):
|
|||||||
kwargs: vectorstore specific parameters
|
kwargs: vectorstore specific parameters
|
||||||
"""
|
"""
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = [str(uuid.uuid1()) for _ in texts]
|
ids = [str(uuid.uuid4()) for _ in texts]
|
||||||
|
|
||||||
if not metadatas:
|
if not metadatas:
|
||||||
metadatas = [{} for _ in texts]
|
metadatas = [{} for _ in texts]
|
||||||
|
@ -150,7 +150,7 @@ class TimescaleVector(VectorStore):
|
|||||||
num_dimensions = len(embeddings[0])
|
num_dimensions = len(embeddings[0])
|
||||||
|
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = [str(uuid.uuid1()) for _ in texts]
|
ids = [str(uuid.uuid4()) for _ in texts]
|
||||||
|
|
||||||
if not metadatas:
|
if not metadatas:
|
||||||
metadatas = [{} for _ in texts]
|
metadatas = [{} for _ in texts]
|
||||||
@ -191,7 +191,7 @@ class TimescaleVector(VectorStore):
|
|||||||
num_dimensions = len(embeddings[0])
|
num_dimensions = len(embeddings[0])
|
||||||
|
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = [str(uuid.uuid1()) for _ in texts]
|
ids = [str(uuid.uuid4()) for _ in texts]
|
||||||
|
|
||||||
if not metadatas:
|
if not metadatas:
|
||||||
metadatas = [{} for _ in texts]
|
metadatas = [{} for _ in texts]
|
||||||
@ -232,7 +232,7 @@ class TimescaleVector(VectorStore):
|
|||||||
kwargs: vectorstore specific parameters
|
kwargs: vectorstore specific parameters
|
||||||
"""
|
"""
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = [str(uuid.uuid1()) for _ in texts]
|
ids = [str(uuid.uuid4()) for _ in texts]
|
||||||
|
|
||||||
if not metadatas:
|
if not metadatas:
|
||||||
metadatas = [{} for _ in texts]
|
metadatas = [{} for _ in texts]
|
||||||
@ -259,7 +259,7 @@ class TimescaleVector(VectorStore):
|
|||||||
kwargs: vectorstore specific parameters
|
kwargs: vectorstore specific parameters
|
||||||
"""
|
"""
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = [str(uuid.uuid1()) for _ in texts]
|
ids = [str(uuid.uuid4()) for _ in texts]
|
||||||
|
|
||||||
if not metadatas:
|
if not metadatas:
|
||||||
metadatas = [{} for _ in texts]
|
metadatas = [{} for _ in texts]
|
||||||
|
@ -255,7 +255,7 @@ class VDMS(VectorStore):
|
|||||||
metadatas = metadatas if metadatas is not None else [None for _ in texts]
|
metadatas = metadatas if metadatas is not None else [None for _ in texts]
|
||||||
_len_check_if_sized(texts, metadatas, "texts", "metadatas")
|
_len_check_if_sized(texts, metadatas, "texts", "metadatas")
|
||||||
|
|
||||||
ids = ids if ids is not None else [str(uuid.uuid1()) for _ in texts]
|
ids = ids if ids is not None else [str(uuid.uuid4()) for _ in texts]
|
||||||
_len_check_if_sized(texts, ids, "texts", "ids")
|
_len_check_if_sized(texts, ids, "texts", "ids")
|
||||||
|
|
||||||
all_queries: List[Any] = []
|
all_queries: List[Any] = []
|
||||||
@ -535,7 +535,7 @@ class VDMS(VectorStore):
|
|||||||
metadatas.append({"image_path": uri})
|
metadatas.append({"image_path": uri})
|
||||||
|
|
||||||
# Populate IDs
|
# Populate IDs
|
||||||
ids = ids if ids is not None else [str(uuid.uuid1()) for _ in uris]
|
ids = ids if ids is not None else [str(uuid.uuid4()) for _ in uris]
|
||||||
|
|
||||||
# Set embeddings
|
# Set embeddings
|
||||||
embeddings = self._embed_image(uris=uris)
|
embeddings = self._embed_image(uris=uris)
|
||||||
@ -577,7 +577,7 @@ class VDMS(VectorStore):
|
|||||||
|
|
||||||
texts = list(texts)
|
texts = list(texts)
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = [str(uuid.uuid1()) for _ in texts]
|
ids = [str(uuid.uuid4()) for _ in texts]
|
||||||
|
|
||||||
embeddings = self._embed_documents(texts)
|
embeddings = self._embed_documents(texts)
|
||||||
|
|
||||||
@ -873,7 +873,7 @@ class VDMS(VectorStore):
|
|||||||
# **kwargs,
|
# **kwargs,
|
||||||
)
|
)
|
||||||
if ids is None:
|
if ids is None:
|
||||||
ids = [str(uuid.uuid1()) for _ in texts]
|
ids = [str(uuid.uuid4()) for _ in texts]
|
||||||
vdms_collection.add_texts(
|
vdms_collection.add_texts(
|
||||||
texts=texts,
|
texts=texts,
|
||||||
metadatas=metadatas,
|
metadatas=metadatas,
|
||||||
|
Loading…
Reference in New Issue
Block a user