Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding async support for tools #735

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tg1482
Copy link

@tg1482 tg1482 commented Jun 5, 2024

Following our discussion here, creating another PR with minimal changes to the codebase for supporting async tooling.

Previous PR here - #550

Added a test which passes for executing a pipeline with an async tool.

Screenshot 2024-06-05 at 10 35 27 AM

Comment on lines +130 to +136
if is_async_tool:
if tool.func:
# async tool defined using BaseTool class from crewai_tools
async_tool_run = tool._run
elif tool.coroutine:
# async tool defined using @tool decorator from langchain
async_tool_run = tool._arun
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently when we define an async function using @tool decorator or BaseTools, they get created differently.

For @tool decorator - if the function is a coroutine, func=None and the function gets added to the coroutine attribute.

However, for BaseTools, thats not the case, it remains part of the func attribute. To absorb this complexity from the user's perspective, we do it this way so that users can still define their async tools using _run when using BaseTools. There is no change from the user's perspective other than just adding a async while defining the tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant