Replies: 2 comments
-
🤖 Hello @sowsan, I'm Dosu, an AI assistant here to help you with your questions and troubleshoot issues related to LangChain. While we wait for a human maintainer, I'm here to provide as much assistance as I can! In the LangChain framework, to ensure that your tool function is called asynchronously, you need to define it as a coroutine function using from langchain_core.tools import tool
@tool()
async def my_tool(a: int, b: int) -> int:
"""Add two numbers asynchronously"""
return a + b In this example, The result = await my_tool.ainvoke({"a": 1, "b": 2}) In this code, Regarding your second question, the For more details, you can refer to the source code of LangChain in the tools.py and manager.py files. I hope this helps! If you have any more questions, feel free to ask. SourcesThis 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. |
Beta Was this translation helpful? Give feedback.
-
I need help with this too! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello Team -
How can I call the tool created with async ? Like the scenario below , and if I use AgentExecutor, how can I ensure that AgentExecutor will call the _arun behind the scene? I am using
Also how can we make the tool with @tool decorator called asynchronously ? @tool. If I decorate the fucnation with async it says @tool doesnt support async. I am using latest version of langchain - 0.0.0.346
Beta Was this translation helpful? Give feedback.
All reactions