From 880a6a3db5d9bcbc1d1781f9168c2a932786007c Mon Sep 17 00:00:00 2001 From: Harrison Chase Date: Mon, 27 Mar 2023 15:03:51 -0700 Subject: [PATCH] Harrison/redis id key (#2057) Co-authored-by: Fabrizio Ruocco --- langchain/vectorstores/redis.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/langchain/vectorstores/redis.py b/langchain/vectorstores/redis.py index 1729ebff..69660c3a 100644 --- a/langchain/vectorstores/redis.py +++ b/langchain/vectorstores/redis.py @@ -62,11 +62,13 @@ class Redis(VectorStore): ) -> List[str]: # `prefix`: Maybe in the future we can let the user choose the index_name. prefix = "doc" # prefix for the document keys + keys = kwargs.get("keys") ids = [] # Check if index exists for i, text in enumerate(texts): - key = f"{prefix}:{uuid.uuid4().hex}" + _key = keys[i] if keys else uuid.uuid4().hex + key = f"{prefix}:{_key}" metadata = metadatas[i] if metadatas else {} self.client.hset( key,