Using Composio With LiveKit

Star A Repository on Github

In this example, we will use LiveKit to build a voice a Agent to star a repository on GitHub using Composio Tools. Follow LiveKit’s Guide for basic setup before proceeding.

1

Install Packages

Python
$pip install composio-livekit
2

Set Environment Variables

.env
1DEEPGRAM_API_KEY=
2OPENAI_API_KEY=
3CARTESIA_API_KEY=
4LIVEKIT_API_KEY=
5LIVEKIT_API_SECRET=
6LIVEKIT_URL=
7COMPOSIO_API_KEY=
3

Import Libraries & Initialize ComposioToolSet

Python
1from composio_livekit import Action, ComposioToolSet
2from livekit import agents
3from livekit.agents.voice import Agent, AgentSession, room_io
4from livekit.plugins import (
5 cartesia,
6 deepgram,
7 noise_cancellation,
8 openai,
9 silero,
10 turn_detector,
11)
12
13toolset = ComposioToolSet()
4

Connect Your GitHub Account

You need to have an active GitHub Integration. Learn how to do this here
$composio login
>composio add github
5

Get the Star A Repository Action

Python
1tools = toolset.get_tools(
2 actions=[Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER]
3)
6

Define the Agent

Define the agent and pass the tools to it

Python
1class Assistant(Agent):
2 def __init__(self) -> None:
3 super().__init__(
4 instructions="You are a helpful voice AI assistant.", tools=tools
5 )
6
7async def entrypoint(ctx: agents.JobContext):
8 await ctx.connect()
9
10 session = AgentSession(
11 stt=deepgram.STT(),
12 llm=openai.LLM(model="gpt-4o"),
13 tts=cartesia.TTS(),
14 vad=silero.VAD.load(),
15 turn_detection=turn_detector.EOUModel(),
16 )
17
18 await session.start(
19 room=ctx.room,
20 agent=Assistant(),
21 room_input_options=room_io.RoomInputOptions(
22 noise_cancellation=noise_cancellation.BVC(),
23 ),
24 )
25
26 await session.generate_reply()
27
28if __name__ == "__main__":
29 agents.cli.run_app(agents.WorkerOptions(entrypoint_fnc=entrypoint))
7

Speak To Your Agent

Start your agent in console mode to run inside your terminal:

Python
$python main.py console

Your agent speaks to you in the terminal, and you can speak to it as well.