📖 Using Composio With PraisonAI

Composio enables your PraisonAI agents to connect with many tools!

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

Install Packages & Connect a Tool

These commands prepare your environment for seamless interaction between PraisonAI and GitHub.

Run command
$pip install PraisonAI -q
>pip install composio-praisonai
># login to composio
>composio login
># Connect your GitHub using command below, so agents can use it.
>composio add github
># Check all different apps which you can connect with
>composio apps

Goal: Use PraisonAI Agent to Interact with Github using Composio

1

Import Base Packages

Prepare your environment by initializing necessary imports from PraisonAI and setting up your client.

Default Imports
1import os
2import yaml
3from praisonai import PraisonAI
4
5from composio_praisonai import Action, ComposioToolSet
2

Write the Praison-supported Composio Tools in tools.py file.

This step involves fetching and integrating GitHub tools provided by Composio, and writing them in PraisonAI supported Format, returning the name of tools in a format, that should be added to agents.yml file.

Write the tools
1composio_toolset = ComposioToolSet()
2tools = composio_toolset.get_tools(
3 actions=[Action.GITHUB_ACTIVITY_STAR_REPO_FOR_AUTHENTICATED_USER]
4)
5tool_section_str = composio_toolset.get_tools_section(tools)
6print(tool_section_str)
3

Define the agents.yml either in a separate file, or in your script.

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

Define agent.yml
1agent_yaml = """
2framework: "crewai"
3topic: "Github Management"
4
5roles:
6 developer:
7 role: "Developer"
8 goal: "An expert programmer"
9 backstory: "A developer exploring new codebases and having certain tools available to execute different tasks."
10 tasks:
11 star_github:
12 description: "Star a repo composiohq/composio on GitHub"
13 expected_output: "Response whether the task was executed."
14""" + tool_section_str
15
16print(agent_yaml)
4

Run the PraisonAI Agents to execute the goal/task.

Here you initialize PraisonAI class, and execute.

Define agent.yml
1# Create a PraisonAI instance with the agent_yaml content
2praison_ai = PraisonAI(agent_yaml=agent_yaml)
3
4# Run PraisonAI
5result = praison_ai.main()
6
7# Print the result
8print(result)
Built with