Bug fixes and error handling in Redis - Vectorstore (#4932)

# Bug fixes in Redis - Vectorstore (Added the version of redis to the
error message and removed the cls argument from a classmethod)


Co-authored-by: Tyler Hutcherson <tyler.hutcherson@redis.com>
This commit is contained in:
Adheeban Manoharan 2023-05-20 01:32:03 +05:30 committed by GitHub
parent a87a2524c7
commit 616e9a93e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,8 +56,9 @@ def _check_redis_module_exist(client: RedisType, required_modules: List[dict]) -
return return
# otherwise raise error # otherwise raise error
error_message = ( error_message = (
"You must add the RediSearch (>= 2.4) module from Redis Stack. " "Redis cannot be used as a vector database without RediSearch >=2.4"
"Please refer to Redis Stack docs: https://redis.io/docs/stack/" "Please head to https://redis.io/docs/stack/search/quick_start/"
"to know more about installing the RediSearch module within Redis Stack."
) )
logging.error(error_message) logging.error(error_message)
raise ValueError(error_message) raise ValueError(error_message)
@ -126,7 +127,7 @@ class Redis(VectorStore):
except ImportError: except ImportError:
raise ValueError( raise ValueError(
"Could not import redis python package. " "Could not import redis python package. "
"Please install it with `pip install redis`." "Please install it with `pip install redis>=4.1.0`."
) )
self.embedding_function = embedding_function self.embedding_function = embedding_function
@ -358,7 +359,7 @@ class Redis(VectorStore):
@classmethod @classmethod
def from_texts_return_keys( def from_texts_return_keys(
cls: Type[Redis], cls,
texts: List[str], texts: List[str],
embedding: Embeddings, embedding: Embeddings,
metadatas: Optional[List[dict]] = None, metadatas: Optional[List[dict]] = None,