mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-10 15:06:18 +00:00
FIX: 'from_texts' method in Weaviate with non-existent kwargs param (#11604)
Due to the possibility of external inputs including UUIDs, there may be additional values in **kwargs, while Weaviate's `__init__` method does not support passing extra **kwarg parameters. --------- Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
parent
971d2b2e34
commit
f22f273f93
@ -467,6 +467,13 @@ class Weaviate(VectorStore):
|
||||
embeddings = embedding.embed_documents(texts) if embedding else None
|
||||
attributes = list(metadatas[0].keys()) if metadatas else None
|
||||
|
||||
# If the UUID of one of the objects already exists
|
||||
# then the existing object will be replaced by the new object.
|
||||
if "uuids" in kwargs:
|
||||
uuids = kwargs.pop("uuids")
|
||||
else:
|
||||
uuids = [get_valid_uuid(uuid4()) for _ in range(len(texts))]
|
||||
|
||||
with client.batch as batch:
|
||||
for i, text in enumerate(texts):
|
||||
data_properties = {
|
||||
@ -476,12 +483,7 @@ class Weaviate(VectorStore):
|
||||
for key in metadatas[i].keys():
|
||||
data_properties[key] = metadatas[i][key]
|
||||
|
||||
# If the UUID of one of the objects already exists
|
||||
# then the existing objectwill be replaced by the new object.
|
||||
if "uuids" in kwargs:
|
||||
_id = kwargs["uuids"][i]
|
||||
else:
|
||||
_id = get_valid_uuid(uuid4())
|
||||
_id = uuids[i]
|
||||
|
||||
# if an embedding strategy is not provided, we let
|
||||
# weaviate create the embedding. Note that this will only
|
||||
|
Loading…
Reference in New Issue
Block a user