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

Feature/contrib_crewai #166

Closed
wants to merge 11 commits into from
Closed

Conversation

lgesuellip
Copy link
Contributor

@lgesuellip lgesuellip commented Nov 27, 2024

ArcadeAI Integration with CrewAI

Hi team,

Here are all the details of this pull request that include the integration with CrewAI.

Contributions in /contrib Folder

1. Generic ArcadeManager

  • Developed a generic ArcadeManager to reduce code duplication across different integrations, such as LangChain and CrewAI.
  • This design promotes flexibility and reusability by providing a base manager that can be extended for specific frameworks.

2. CrewAI Integration

  • Developed all necessary components to integrate Arcade tools with CrewAI:
    • StructuredTool Implementation: Since CrewAI does not currently have a StructuredTool implementation, we developed one in this integration and submitted an issue and pull request to the CrewAI repository to include this feature natively in the future. (I am in conversation with the team, so I will give you updates regarding this part).
    • CrewAI Manager: Created a CrewAIManager class that inherits from ArcadeManager. This ensures code reuse and leverages the generic manager while adding logic specific to CrewAI tools.

3. Documentation and Testing

  • Added comprehensive documentation for each component.
  • Provided test coverage for the new ArcadeManager, CrewAIManager, and related integrations.

Examples in /examples Folder

1. How to Use ArcadeAI Tools in CrewAI

  • Added a step-by-step guide demonstrating how to integrate and use ArcadeAI tools in CrewAI. ✅

2. ArcadeAI Authorization for CrewAI Tools

  • A detailed example for handling ArcadeAI authentication within CrewAI workflows.

3. End-to-End Example

  • Built a complete example showcasing multiple ArcadeAI tools in a realistic use case, demonstrating their combined functionality.

Thank you Team,
Looking forward to your feedback!


manager = CrewAIToolManager(arcade_client, user_id)
# Retrieve the tools from the specified toolkit
tools = manager.get_tools(toolkits=["google"])
Copy link
Member

@EricGustin EricGustin Dec 10, 2024

Choose a reason for hiding this comment

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

@lgesuellip @lpetralli Google calendar tools require authorization. I suspect you have already authorized Arcade for the google calendar tool with the cloud engine, so you likely did not run into this issue. You can use the arcade_client.tools.authorize function to authorize a specific tool. See this example for authorizing a specific Google tool.

I also recommend running a local engine when developing so that authorizations are reset on each engine startup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey Eric, thank you for the feedback.

The tool includes logic to verify authentication, similar to the langgraph integration. If authentication is required but hasn’t been completed, it returns a link for the user to authenticate (

def create_tool_function(self, tool_name: str, **kwargs: Any) -> Callable[..., Any]:
)

What do you think?
Would you recommend adding any extra logic to the example, such as waiting until the authorization process is completed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@EricGustin I wanted to check if you've had a chance to review it.
Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Hey @lgesuellip , I'm running the example1 locally without prior Google authorization and it doesn't provide a link for me to authenticate. I believe the example itself needs to check if the tool returned an auth link, and then provide that link to the user before trying again.

Here's the full output:

~/r/Team/arcade-ai/ex/c/1. tool-example old *81 !2 ?5 ❯ python agent_crewai.py                            old 18:09:14
INFO:httpx:HTTP Request: GET http://localhost:9099/v1/tools/list?toolkit=google "HTTP/1.1 200 OK"
INFO:httpx:HTTP Request: GET http://localhost:9099/v1/tools/list?toolkit=google "HTTP/1.1 200 OK"
INFO:__main__:Starting the CrewAI agent workflow.
# Agent: Main Agent
## Task: 
# Task
You are an AI assistant designed to help the team.

# Guidelines
Your responses should be:
- Friendly and approachable, using a warm tone

# User Request
Complete the following request using the tools at your disposal: Please schedule a calendar event for tomorrow from 10:00 PM to 11:00 PM Argentina time. The event is a meeting combined with team building activities.

18:09:18 - LiteLLM:INFO: utils.py:2765 - 
LiteLLM completion() model= gpt-4o; provider = openai
INFO:LiteLLM:
LiteLLM completion() model= gpt-4o; provider = openai
INFO:httpx:HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
18:09:19 - LiteLLM:INFO: utils.py:894 - Wrapper: Completed Call, calling success_handler
INFO:LiteLLM:Wrapper: Completed Call, calling success_handler
18:09:19 - LiteLLM:INFO: utils.py:2765 - 
LiteLLM completion() model= gpt-4o; provider = openai
INFO:LiteLLM:
LiteLLM completion() model= gpt-4o; provider = openai
INFO:httpx:HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
18:09:21 - LiteLLM:INFO: utils.py:894 - Wrapper: Completed Call, calling success_handler
INFO:LiteLLM:Wrapper: Completed Call, calling success_handler


# Agent: Main Agent
## Thought: Thought: To schedule the calendar event at the correct time, I need to adjust the time to match Argentina time, which is UTC-3. Therefore, the event should be scheduled from 10:00 PM to 11:00 PM UTC-3 tomorrow. I will proceed to create the event.
## Using tool: Google_CreateEvent
## Tool Input: 
"{\"summary\": \"Meeting with Team Building Activities\", \"start_datetime\": \"2023-11-28T22:00:00-03:00\", \"end_datetime\": \"2023-11-28T23:00:00-03:00\", \"calendar_id\": \"primary\", \"description\": \"A meeting combined with team building activities.\", \"location\": \"\", \"visibility\": \"default\", \"attendee_emails\": []}"
## Tool Output: 
Authorization required for Google_CreateEvent.
18:09:21 - LiteLLM:INFO: utils.py:2765 - 
LiteLLM completion() model= gpt-4o; provider = openai
INFO:LiteLLM:
LiteLLM completion() model= gpt-4o; provider = openai
INFO:httpx:HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
18:09:22 - LiteLLM:INFO: utils.py:894 - Wrapper: Completed Call, calling success_handler
INFO:LiteLLM:Wrapper: Completed Call, calling success_handler


# Agent: Main Agent
## Final Answer: 
It looks like I encountered an issue while trying to schedule the event in your calendar. However, you can easily create this event in your calendar application by setting the details as follows: 

Tomorrow, from 10:00 PM to 11:00 PM Argentina time, schedule a meeting combined with team-building activities. You can add this to your calendar and include any additional details or invite team members as needed.

If you have any questions or need further assistance, feel free to ask! 😊


INFO:__main__:Workflow executed: It looks like I encountered an issue while trying to schedule the event in your calendar. However, you can easily create this event in your calendar application by setting the details as follows: 

Tomorrow, from 10:00 PM to 11:00 PM Argentina time, schedule a meeting combined with team-building activities. You can add this to your calendar and include any additional details or invite team members as needed.

If you have any questions or need further assistance, feel free to ask! 😊

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey Eric,

I just added a custom wait_for_completion method for authorization handling (avoiding infinite loops):

  • Introduced a new wait_for_completion method in ArcadeAuthMixin to manage the authorization process with a timeout.
  • Updated CrewAIToolManager to use the new method for handling authorization status.
  • Enhanced test cases in test_manager.py to mock and verify the behavior of the new authorization waiting logic.

Let me know what you think!

Copy link
Member

@EricGustin EricGustin left a comment

Choose a reason for hiding this comment

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

Thanks @lgesuellip ! I left some comments inline.

Additionally, adding an empty py.typed file in contrib/common will get rid of 'no Any import' linting issues that I was running into.

Copy link
Member

Choose a reason for hiding this comment

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

it would be really cool if this example played the recommended song by using the Arcade tool Spotify.StartTracksPlaybackById or Spotify.PlayTrackByName

@lgesuellip
Copy link
Contributor Author

@EricGustin thank you so much for all the suggestions, I just pushed them!
Let me know your thoughts when you have a chance.

@lgesuellip
Copy link
Contributor Author

Hey Team, are we good to merge the PR?

@EricGustin
Copy link
Member

Closing in favor of #253

@EricGustin EricGustin closed this Feb 19, 2025
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.

3 participants