Skip to main content

🚀🔗 Leveraging Smol Agents with Composio

Integrate Smol Agents with Composio to enable direct interaction with external applications, enhancing their capabilities through strongly-typed, validated tools.

Objective

  • Automate GitHub operations using type-safe instructions via Smol Agent's Tool system.
  • Demonstrate how to use Composio's tools with Smol Agent's CodeAgent.

Installation and Setup

Install the necessary packages and connect your GitHub account to enable agent interactions with GitHub:

# Install Composio Smol Agents package
pip install composio-smol

# Connect your GitHub account
composio add github

# View available applications you can connect with
composio apps

Usage Steps

1. Import Required Packages

Set up your environment by importing the necessary components from Composio & Smol Agents:

from dotenv import load_dotenv
import os

from composio import Action
from composio_smol import ComposioToolSet
from smolagents import HfApiModel, CodeAgent

2. Initialize Tools with Composio

Configure and fetch GitHub tools provided by Composio:

# Initialize toolset
composio_toolset = ComposioToolSet()

# Get GitHub tools with retry configuration
tools = composio_toolset.get_tools(
    actions=[Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER],
)

3. Set Up the Smol Agent

Create and configure a Smol agent with the Composio tools:

# Create an agent with the tools
agent = CodeAgent(
    tools=tools,
    model=HfApiModel()
)

4. Execute Tasks

Run your agent with specific tasks:

# Define task
agent.run("Star the composiohq/composio repo")

Advanced Usage

The integration supports more complex scenarios:

# Using multiple tools
tools = composio_toolset.get_tools(
    actions=[
        Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER,
        Action.GITHUB_CREATE_REPOSITORY
    ],
)

# Using app-specific tools
tools = composio_toolset.get_tools(
    apps=[App.GITHUB],
)

Best Practices

  1. Always use proper type hints in your code
  2. Handle validation errors appropriately
  3. Use the latest version of both Smol Agent and Composio
  4. Leverage async operations for better performance
  5. Keep your API keys secure using environment variables
  6. Configure retries based on the specific needs of each tool

Release files for composio-smol 0.7.20

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for composio-smol 0.7.20
File Size Uploaded
composio_smol-0.7.20.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for composio-smol 0.7.20
File Interpreter ABI Platform
composio_smol-0.7.20-py3-none-any.whl Python 3 none any Details

Total release size: 8.8 kB

Release files / composio_smol-0.7.20.tar.gz

Download URL composio_smol-0.7.20.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
35b7b3e85b927bb49e2a3b40f42c74146096fba1f3a02495de9dba551d8ee3a8
BLAKE2b-256 checksum
How to use checksums
cd4f4216c635e46fda174f668cade9e81f2fbfaaa7b687d2281d2400a1cb885a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / composio_smol-0.7.20-py3-none-any.whl

Download URL composio_smol-0.7.20-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc551ef833fbf43f4d0da4a0316b1186e1ba0e9a5a4fc7339e3e2a9496a2fefe
BLAKE2b-256 checksum
How to use checksums
f429bd3feb4bc736fa69085c08c24e907554a4a78a61122141653812537d8c6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page