langchain icon indicating copy to clipboard operation
langchain copied to clipboard

Redis Vectorstore: Did not find redis_url, please add an environment variable `REDIS_URL` which contains it, or pass `redis_url` as a named parameter.

Open 0xcaffeinated opened this issue 2 years ago • 4 comments

System Info

Python 3.10.4
langchain==0.0.171
redis==4.5.5
redisearch==2.1.1

Who can help?

@tylerhutcherson

Information

  • [ ] The official example notebooks/scripts
  • [X] My own modified scripts

Related Components

  • [ ] LLMs/Chat Models
  • [ ] Embedding Models
  • [ ] Prompts / Prompt Templates / Prompt Selectors
  • [ ] Output Parsers
  • [ ] Document Loaders
  • [X] Vector Stores / Retrievers
  • [ ] Memory
  • [ ] Agents / Agent Executors
  • [ ] Tools / Toolkits
  • [ ] Chains
  • [ ] Callbacks/Tracing
  • [ ] Async

Reproduction

I was able to override #4896 by getting rid of the extra cls from the mentioned method. Post which, I'm getting this below error. Ideally from_texts_return_keys method should not be expecting redis_url to be passed in as a kwarg since the redis_url is defined during the initialization of the Redis class and is a mandatory argument.

  File "/home/codespace/.python/current/lib/python3.10/site-packages/langchain/vectorstores/redis.py", line 448, in from_texts
    instance, _ = cls.from_texts_return_keys(
  File "/home/codespace/.python/current/lib/python3.10/site-packages/langchain/vectorstores/redis.py", line 389, in from_texts_return_keys
    redis_url = get_from_dict_or_env(kwargs, "redis_url", "REDIS_URL") 
  File "/home/codespace/.python/current/lib/python3.10/site-packages/langchain/utils.py", line 17, in get_from_dict_or_env
    return get_from_env(key, env_key, default=default)
  File "/home/codespace/.python/current/lib/python3.10/site-packages/langchain/utils.py", line 27, in get_from_env
    raise ValueError(
ValueError: Did not find redis_url, please add an environment variable `REDIS_URL` which contains it, or pass  `redis_url` as a named parameter.

Expected behavior

The method from_texts_return_keys should not expect the redis_url to be passed in as a kwarg.

0xcaffeinated avatar May 18 '23 03:05 0xcaffeinated

Thanks for this one too. This is currently broken on latest version of LC

tylerhutcherson avatar May 18 '23 16:05 tylerhutcherson

Hey @iamadhee the issue here is:

https://github.com/hwchase17/langchain/blob/a8ded21b6963b0041e9931f6e397573cb498cbaf/langchain/vectorstores/redis.py#L456

should be **kwargs

I am working with LC team on a fix now.

tylerhutcherson avatar May 18 '23 16:05 tylerhutcherson

Great. Thanks

0xcaffeinated avatar May 18 '23 16:05 0xcaffeinated

I updated the langchain today, version 0.177 and the problem is already solved

jtmigowski avatar May 23 '23 17:05 jtmigowski

Hi, @iamadhee! I'm Dosu, and I'm helping the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, the issue is about a Redis Vectorstore in Python that was expecting the redis_url to be passed as a keyword argument, but it should be defined during the initialization of the Redis class. Tylerhutcherson pointed out the issue and is working on a fix with the LangChain team. Jtmigowski confirmed that the problem has been solved in version 0.177 of langchain.

Before we close this issue, we wanted to check with you if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself or it will be automatically closed in 7 days.

Thank you for your contribution to LangChain!

dosubot[bot] avatar Sep 12 '23 16:09 dosubot[bot]