🐫 Using Composio With CAMEL-AI

Composio enables your CAMEL agents to connect with many tools!

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

Install Packages & Connect a Tool

Ensure you have the necessary packages installed and connect your GitHub account to allow your CAMEL-AI agents to utilize GitHub functionalities.

Run command
$pip install camel-ai
>pip install composio-camel -U
># Connect your GitHub so agents can use it.
>composio add github
># Check all different apps which you can connect with
>composio apps

Goal: Prepare your environment by initializing necessary imports from Composio & CAMEL.

1

Import Base Packages

Prepare your environment by initializing necessary imports from Composio & CAMEL.

Default Imports
1from colorama import Fore
2from camel.agents import ChatAgent
3from camel.configs import ChatGPTConfig
4from camel.messages import BaseMessage
5from camel.models import ModelFactory
6from camel.types import ModelPlatformType, ModelType
7from camel.utils import print_text_animated
8from composio_camel import ComposioToolSet, Action
2

Integrating GitHub Tools with Composio

This step involves fetching and integrating GitHub tools provided by Composio, enabling enhanced functionality for CAMEL operations.

CAMEL Supported tools from Composio
1composio_toolset = ComposioToolSet()
2tools = composio_toolset.get_tools(
3 actions=[Action.GITHUB_ACTIVITY_STAR_REPO_FOR_AUTHENTICATED_USER]
4)
3

CAMEL Agent Setup

This step involves configuring and executing the agent to carry out actions, such as starring a GitHub repository.

CAMEL Agent Setup
1assistant_model_config = ChatGPTConfig(
2 temperature=0.0,
3 tools=tools,
4)
5
6model = ModelFactory.create(
7 model_platform=ModelPlatformType.OPENAI,
8 model_type=ModelType.GPT_3_5_TURBO,
9 model_config_dict=assistant_model_config.__dict__,
10)
11
12
13# set up agent
14assistant_sys_msg = BaseMessage.make_assistant_message(
15 role_name="Developer",
16 content=(
17 "You are a programmer as well an experienced github user. "
18 "When asked given a instruction, "
19 "you try to use available tools, and execute it"
20 ),
21)
22
23agent = ChatAgent(
24 assistant_sys_msg,
25 model,
26 tools=tools,
27)
28agent.reset()
4

Execute with your prompt/task.

Execute the following code to execute the agent, ensuring that the intended task has been successfully completed.

CAMEL Agent Execution
1prompt = (
2 "I have created a new GitHub Repo,"
3 "Please star my github repository: camel-ai/camel"
4)
5user_msg = BaseMessage.make_user_message(role_name="User", content=prompt)
6print(Fore.YELLOW + f"User prompt:\n{prompt}\n")
7
8response = agent.step(user_msg)
9for msg in response.msgs:
10 print_text_animated(Fore.GREEN + f"Agent response:\n{msg.content}\n")
Built with