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

Add Interoperable protocol and implement tool import from multiple frameworks #197

Merged
merged 93 commits into from
Dec 19, 2024

Conversation

davorrunje
Copy link
Collaborator

@davorrunje davorrunje commented Dec 12, 2024

Why are these changes needed?

This PR introduces several new functionality to the AG2:

  1. New class Tool with methods register_for_execution and register_for_llm.

  2. The new Interoperable protocol to enable interoperability with other frameworks and the new Interoperability class to expose interoperability classes implementing the Interoperable protocol. The following frameworks are supported for tool import:

    • CrewAI
    • LangChain
    • Pydantic AI

Install

Available extras are: interop-crewai, interop-langchain and interop-pydantic.

An example on how to install support forCrewAI tools:

pip install ag2[interop-crewai]

Usage

An example on how to convert FileReadTool and register it for execution and LLM:

from crewai_tools import 

# create CrewAI tool
crewai_tool = FileReadTool()

# converts CrewAI tool into AG2 Tool
tool = Interoperability.convert_tool(type="crewai", tool=crewai_tool)

# register AG2 tool for LLM and execution
tool.register_for_execution(user_proxy)
tool.register_for_llm(chatbot)

The list of supported frameworks can be dynamically retrieved using the Interoperability.get_supported_types method:

supported_types = Interoperability.get_supported_types()
print(supported_types)
# expected output
# ["crewai", "langchain", "pydanticai"]

Related issue number

Closes #208

Checks

Copy link
Collaborator

@marklysze marklysze left a comment

Choose a reason for hiding this comment

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

Great PR, thanks, let's go!

@marklysze marklysze added this pull request to the merge queue Dec 19, 2024
Merged via the queue into main with commit 5ec0198 Dec 19, 2024
212 of 215 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Enable interoperability with CrewAI tools
5 participants