langchain
langchain copied to clipboard
AttributeError: 'Redis' object has no attribute 'module_list'
I'm trying to make a vectorstore using redis and store the embeddings in redis. When I write the code rds = Redis.from_documents(docs, embeddings, redis_url="redis://localhost:6379", index_name='test_link') I get the following error AttributeError: 'Redis' object has no attribute 'module_list'. Note: I'm trying to run redis locally on windows subsystem ubuntu. Please help.
Which version of the redis python client and LC are you using? I'm not able to reproduce this with unit tests (just added a from_documents test method.
Wonder if it's possible module names are colliding in your working env too.
I have redis server in windows subsystem (ubuntu) and its Redis server v=6.0.16 on python side, its redis version 3.5.3
Can you try with the latest redis client version (>=4.5.2)
sorry for the late reply. I updated the redis version to 4.5.4. When I run the piece of code, it says ValueError: Redis failed to connect: You must add the RediSearch (>= 2.4) module from Redis Stack. Please refer to Redis Stack docs: https://redis.io/docs/stack/ When I try to install redisearch==2.4 i get the error no such distribution found for redisearch when I just install redisearch, it updates redis version to 3.5.3 please help
Ok so the redis client version fixed the initial error here.
For this one, you don't need to install a different client. You need to run the version of redis that has the search module installed on the database for vector search. (Redis is modular and has different developer capabilities). Did you checkout the link it provided?
Here is a docker command to run the correct flavor of redis:
docker run -d --name redis-stack-server -p 6379:6379 redis/redis-stack-server:latest
Hi, I'm also getting the same error. I'm using the below versions of the packages
redis==3.5.3
redisearch==2.1.1
The docker command also didn't actually solve the issue.
Seems there is some dependency conflict between redis and redisearch. redisearch>=2.4 is not available. 2.1.1 is the latest.
Hey,
Same issue ...
AttributeError: 'Redis' object has no attribute 'module_list'
The redis client, and redisearch versions are:
redis==3.5.3
redisearch==2.1.1
The docker image
docker run -d --name bot -p 6379:6379 redis/redis-stack-server:latest
With the redis stack server version being redis-stack-server==6.2.12
When executing the command MODULE LIST from the redis cli the list of modules is returned as expected.
This appears to be an API incompatibility with the redis python client version that is pinned to python redisearch i.e. as the error says the redis client does not have the module_list method.
The python redis client documentation for 3.5.3 is sparse on the subject. https://redis-py.readthedocs.io/en/3.5.3/py-modindex.html
It appears that module_list
was introduced in version 4.1.0 of the python redis client.
https://redis-py.readthedocs.io/en/v4.1.0/redis_commands.html?highlight=module_list#redis.commands.core.CoreCommands.module_list
This is a redisearch issues rather than a langchain issues (https://github.com/RediSearch/redisearch-py/blob/master/pyproject.toml)
Thanks for looking into that.
The redisearch client library should not be needed here. All search functionality required has been ported to the standard redis Python client.
We need to make sure that any LangChain pin to redisearch is removed in favor of just redis. Will look into this.
cc @hwchase17
I can't find anywhere in langchain where the redisearch
python client library is invoked or used. Any leads? It's possible that user application code uses redisearch
client library and that's causing issue?
https://github.com/RediSearch/redisearch-py (this is deprecated now)
No, it's just that the error message suggests the user to install redisearch (>=2.4), I'm fixing that in the new PR
https://github.com/hwchase17/langchain/blob/1ed4228822498fd58d33d377572af0821c496b20/langchain/vectorstores/redis.py#LL59C35-L59C35
Still not working
still not working
Can anybody suggest a solution for this issue ..
Still facing the same issue while using redis-stack-server docker container:
Here is the full trace.
rds = Redis.from_texts(
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain/vectorstores/redis/base.py", line 497, in from_texts
instance, _ = cls.from_texts_return_keys(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain/vectorstores/redis/base.py", line 414, in from_texts_return_keys
instance = cls(
^^^^
File "/usr/local/lib/python3.11/site-packages/langchain/vectorstores/redis/base.py", line 280, in __init__
check_redis_module_exist(redis_client, REDIS_REQUIRED_MODULES)
File "/usr/local/lib/python3.11/site-packages/langchain/utilities/redis.py", line 49, in check_redis_module_exist
installed_modules = client.module_list()
^^^^^^^^^^^^^^^^^^
AttributeError: 'Redis' object has no attribute 'module_list'
Was really looking forward to using Redis. Seems this issue has been there for a while. I will have to look into other vector DB options soon.
still not working..
these versions resolved my problem:
pip install redis==4.5.4 redisearch==2.0.0
let me know, thanks
FYI there is no dependency on redisearch
; the client library here. Base redis
is all that's needed from a client standpoint.
You need to make sure search/query featured are enabled on your database... which is built-in if using the free Redis Stack docker image or Redis Enterprise.
You guys all need to switch to Redis Stack, not just Redis.
docker run -d --name redis-stack -p 6379:6379 redis/redis-stack:latest