Composio enables your Autogen agents to connect with many tools!

Install Packages & Connect a Tool

Goal: Star a repository on GitHub with natural language & Autogen Agent

These commands prepare your environment for seamless interaction between Autogen and Github.

pip install composio-autogen

#Connect your Github so agents can use it
composio-cli add github 

#Check all supported apps 
composio-cli show-apps

Import Base Packages & Create default Autogen Agent

from autogen import AssistantAgent, UserProxyAgent
from composio_autogen import ComposioToolset, App, Action
import os

llm_config = {"config_list": [{"model": "gpt-4", "api_key": os.environ["OPENAI_API_KEY"]}]}

chatbot = AssistantAgent(
    system_message="Reply TERMINATE when the task is done or when user's content is empty",

# create a UserProxyAgent instance named "user_proxy"
user_proxy = UserProxyAgent(
    is_termination_msg=lambda x: x.get("content", "") and "TERMINATE" in x.get("content", ""),
    human_input_mode="NEVER", # Don't take input from User
    code_execution_config = {"use_docker": False}

Fetch all Github Autogen Tools via Composio

# Import from composio_autogen
from composio_autogen import ComposioToolset, App, Action

# Initialise the Composio Tool Set
composio_tools = ComposioToolset()

# Register the preferred Applications, with right executor. 
composio_tools.register_tools(tools=[App.GITHUB],caller=chatbot, executor=user_proxy)


Execute the Task via Agent

task = "Star a repo SamparkAI/composio_sdk on GitHub"

response = user_proxy.initiate_chat(chatbot,message=task)


Check Response

[{'content': 'I have starred the repository "docs" for you on GitHub under the account "SamparkAI".', 'role': 'user'}, 
{'content': '', 'role': 'assistant'}, {'content': 'TERMINATE', 'role': 'user'}]

Use Specific Actions

# To restrict agents from using all the actions, filter specific actions 

Use Specific Apps

# To restrict agents from using all tools, filter specific tools
composio_tools.register_tools(apps=[App.ASANA, App.GITHUB])

Filter apps actions by tags

# To restrict agents from using all actions, filter the actions by tags
composio_tools.register_tools(apps=[App.ASANA], tags=[Tag.ASANA_TASKS])