langchain-ai / langchain

πŸ¦œπŸ”— Build context-aware reasoning applications
https://python.langchain.com
MIT License
93.09k stars 14.97k forks source link

RedisVectorStoreRetriever similarity search similarity_distance_threshold is not implemented asyncronously #16099

Closed HugoMichard closed 5 months ago

HugoMichard commented 8 months ago

Checked other resources

Example Code

from langchain_community.vectorstores.redis import Redis

embedding = ...
redis_url = ...
schema_path = ...

vectorstore = Redis.from_existing_index(
    embedding,
    index_name='index',
    redis_url=redis_url,
    schema=schema_path,
)
retriever = vectorstore.as_retriever(search_type="similarity_distance_threshold", search_kwargs={"distance_threshold": 0.9, "k": 5})
retriever.aget_relevant_documents('query')

Description

The asynchronous method _aget_relevant_documents is not defined for RedisVectorStoreRetriever. As such, the method of the parent of RedisVectorStoreRetriever (VectorStoreRetriever) is called. In VectorStoreRetriever however, similarity_distance_threshold is not available. This makes the chain crash when RedisVectorStoreRetriever is called asynchronously in a chain.

I will make a PR to solve this

System Info

langchain                         0.1.0
langchain-community               0.0.12
langchain-core                    0.1.10

Related Components

dosubot[bot] commented 8 months ago

πŸ€–

That's great to hear that you're willing to make a PR to solve this issue! Your contribution will definitely help improve LangChain for everyone. Thank you for taking the initiative to address this and for your willingness to contribute to the project. If you have any questions or need any assistance while working on the PR, feel free to ask for help. Good luck with your contribution!


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a πŸ‘ if this is helpful and πŸ‘Ž if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.