langchain icon indicating copy to clipboard operation
langchain copied to clipboard

AttributeError: 'Redis' object has no attribute 'module_list'

Open Ahmedniz1 opened this issue 1 year ago • 10 comments

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.

Ahmedniz1 avatar May 01 '23 17:05 Ahmedniz1

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.

tylerhutcherson avatar May 03 '23 13:05 tylerhutcherson

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

Ahmedniz1 avatar May 03 '23 18:05 Ahmedniz1

Can you try with the latest redis client version (>=4.5.2)

tylerhutcherson avatar May 03 '23 21:05 tylerhutcherson

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

Ahmedniz1 avatar May 15 '23 19:05 Ahmedniz1

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

tylerhutcherson avatar May 15 '23 19:05 tylerhutcherson

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.

iamadhee avatar May 17 '23 02:05 iamadhee

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)

apburton84 avatar May 17 '23 13:05 apburton84

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

tylerhutcherson avatar May 17 '23 13:05 tylerhutcherson

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)

tylerhutcherson avatar May 18 '23 15:05 tylerhutcherson

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

iamadhee avatar May 18 '23 15:05 iamadhee

Still not working

nickstreletskij avatar Jul 14 '23 10:07 nickstreletskij

still not working

bhanu-Bigdata avatar Jul 18 '23 18:07 bhanu-Bigdata

Can anybody suggest a solution for this issue ..

shubh207 avatar Aug 21 '23 18:08 shubh207

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.

anmolagrwl avatar Sep 29 '23 22:09 anmolagrwl

still not working..

shanshanRT avatar Oct 04 '23 15:10 shanshanRT

these versions resolved my problem:

pip install redis==4.5.4 redisearch==2.0.0

let me know, thanks

GhaithDek avatar Jan 23 '24 21:01 GhaithDek

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.

tylerhutcherson avatar Jan 24 '24 00:01 tylerhutcherson

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

koorukuroo avatar Feb 12 '24 05:02 koorukuroo