Using Composio With Lyzr

Composio enables your Lyzr agents to connect with many tools!

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

Install Packages & Connect a Tool

These commands prepare your environment for seamless interaction between Lyzr and Github.

Run command
$ pip install lyzr-automata -q
> pip install composio_lyzr
> #Connect your Github so agents can use it.
> composio add github
> #Check all different apps which you can connect with
> composio apps

Goal: Use Lyzr Agent to Interact with Github using Composio

1

Import Base Packages

Default Imports
1 from lyzr_automata import Task, Agent
2 from lyzr_automata.ai_models.openai import OpenAIModel
3 from composio_lyzr import ComposioToolSet, App, Action
4 from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
5
6
7 open_ai_text_completion_model = OpenAIModel( api_key="sk-...", parameters={"model": "gpt-4-turbo"})
2

Execute the Agent

Lyzr Agent Executes Task
1 lyzr_agent = Agent(
2 role="Github Agent",
3 prompt_persona="You are AI agent that is responsible for taking actions on Github on users behalf. You need to take action on Github using Github APIs",
4 )
5
6 composio_toolset = ComposioToolSet().get_lyzr_tool(Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER)
7
8 task = Task(
9 name="Github Starring",
10 agent=lyzr_agent,
11 tool=composio_toolset,
12 model=open_ai_text_completion_model,
13 instructions="Star a repo composiohq/composio on GitHub",
14 )
15
16 LinearSyncPipeline(name="Composio Lyzr", completion_message="Task completed",tasks=[task]).run()
3

Check Response

Lyzr agent output
$ START PIPELINE Composio Lyzr :: start time : 1713439069.754745
> START TASK Github Starring :: start time : 1713439069.7548192
> output : {'execution_details': {'executed': True}, 'response_data': ''}
> END TASK Github Starring :: end time : 1713439073.961327 :: execution time : 4.206507921218872
> END PIPELINE Composio Lyzr :: end time : 1713439073.961421 :: execution time : 4.206676006317139
> Task completed
> [{'task_id': UUID('d0280a9d-89ef-4f8b-8145-58588aebcb6c'), 'task_output': {'execution_details': {'executed': True}, 'response_data': ''}}]
Built with