Using Composio With Smol Agents

Star A Repository on GitHub

In this example, we will use SmolAgent’s Code Agent to star a repository on GitHub using Composio Tools

1

Install Packages

Python
$pip install composio-smol smolagents
2

Import Libraries & Initialize ComposioToolSet

Python
1from composio_smol import ComposioToolSet, Action, App
2from smolagents import CodeAgent, HfApiModel
3from dotenv import load_dotenv
4
5load_dotenv()
6
7composio_toolset = ComposioToolSet()
3

Connect Your GitHub Account

You need to have an active GitHub Integration. Learn how to do this here
$composio login
>composio add github

Don’t forget to set your COMPOSIO_API_KEY in your environment variables.

4

Get All GitHub Tools

You can get all the tools for a given app as shown below, but you can get specific actions and filter actions using usecase & tags. Learn more here

Python
1tools = composio_toolset.get_tools(actions=[Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER])
5

Define the Agent

Python
1agent = CodeAgent(tools=tools, model=HfApiModel())
6

Execute the Agent

Python
1task = "Star a repo composiohq/composio on GitHub"
2agent.run(task)
Built with