Async RAG Chain for Agent #17591
Replies: 5 comments 1 reply
-
🤖 Hey @bwhartlove, great to see you diving into async adventures with LangChain! Hope you're doing well. Based on the code you've provided and the context given, it seems like you're on the right track with your implementation of the However, it's important to note that the asynchronous behavior of your tool is dependent on the components of your chain being able to operate asynchronously as well. If any component of your chain is blocking, it will cause your entire tool to block, even if you're calling it with In your case, you're using a RAG chain, which should be able to operate asynchronously. However, you'll need to ensure that your As for your question about whether RAG chains can work in an async context, the answer is yes. The LangChain framework does support asynchronous operations in its core functionality. This is evident from the use of Python's asyncio library in the provided code. For instance, the Furthermore, the I hope this helps! If you have any more questions or need further clarification, feel free to ask. Sources
|
Beta Was this translation helpful? Give feedback.
-
@dosu-bot Thanks for the information! I am using the HuggingFaceTextGenInference class for my LLM and the OpenSearchVectorSearch class is the basis for my retriever. Do those support async calls in a chain? |
Beta Was this translation helpful? Give feedback.
-
🤖 Based on the information available in the LangChain repository, the As for the If your If you're still facing issues, could you please provide more details about your Sources
|
Beta Was this translation helpful? Give feedback.
-
@dosu-bot Below is my _arun function for my tool:
The tool class I made has a
The chain passes the input through my retriever, into a PromptTemplate, through the llm, and finally a output parser. The LLM is built using the HuggingFace TGI server:
The backend vector store I am using for the retriever is OpenSearch:
I'm still trying to sort out where the blocking call is happening that causes the application to pause until the tool is done executing. |
Beta Was this translation helpful? Give feedback.
-
Hello everyone, |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
I have an Opensearch vector store index and built a retriever object off of that. Using the retriever and an LLM served up with HuggingFace's TGI engine, I built a chain using LCEL. That chain is used as the primary component of a custom class called
CustomRAGTool
that invokes the chain. What I've noticed is that despite creating anarun
function for my tool and verifying it's being called, the tool still blocks the primary thread of my application. That being said, I wanted to ask (a) is this the right path to follow for async tools and (b) can RAG chains work in an async context? I figure I am missing something along the way. Thanks!System Info
System Information
Package Information
Packages not installed (Not Necessarily a Problem)
The following packages were not found:
Beta Was this translation helpful? Give feedback.
All reactions