Skip to main content

Use Composio to get array of strongly typed tools for Smol Agents

Project description

🚀🔗 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

composio_smol-0.7.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

composio_smol-0.7.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file composio_smol-0.7.1.tar.gz.

File metadata

  • Download URL: composio_smol-0.7.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for composio_smol-0.7.1.tar.gz
Algorithm Hash digest
SHA256 f0946eea576d14ba7de9d20cf96d68fc2846928301df65ea3d3238166f1038aa
MD5 f4f236036cf350e5a47bc071b852659a
BLAKE2b-256 bd1561e0538b90dd0815e46a2016f2e98dafd0cca2b45ae6413c4ee5fa065d2b

See more details on using hashes here.

File details

Details for the file composio_smol-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: composio_smol-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for composio_smol-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c1e2a3d6796439288fb5de75df6c5b94e991e3cccce620257e9309fc64471bd9
MD5 6c4953b2d7700536a978f666787da4fd
BLAKE2b-256 197e84593878022f37bb8a2281b53edf761303daf957cb0db7f619452d7ee40d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page