From 3b75b004fc5db592a9763bb3f408ebd93fe947ac Mon Sep 17 00:00:00 2001 From: DvirDukhan Date: Mon, 3 Apr 2023 00:47:08 +0300 Subject: [PATCH] fixed index name error found at redis new vector test (#2311) This PR fixes a logic error in the Redis VectorStore class Creating a redis vector store `from_texts` creates 1:1 mapping between the object and its respected index, created in the function. The index will index only documents adhering to the `doc:{index_name}` prefix. Calling `add_texts` should use the same prefix, unless stated otherwise in `keys` dictionary, and not create a new random uuid. --- langchain/vectorstores/redis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langchain/vectorstores/redis.py b/langchain/vectorstores/redis.py index c4364801..153d8e63 100644 --- a/langchain/vectorstores/redis.py +++ b/langchain/vectorstores/redis.py @@ -69,7 +69,7 @@ class Redis(VectorStore): ids = [] # Check if index exists for i, text in enumerate(texts): - _key = keys[i] if keys else uuid.uuid4().hex + _key = keys[i] if keys else self.index_name key = f"{prefix}:{_key}" metadata = metadatas[i] if metadatas else {} self.client.hset(