Skip to content

Commit fb0e17a

Browse files
committed
README
1 parent 4a3abf3 commit fb0e17a

File tree

10 files changed

+2815
-272
lines changed

10 files changed

+2815
-272
lines changed

.env.example

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
LIVEKIT_URL=
22
LIVEKIT_API_KEY=
33
LIVEKIT_API_SECRET=
4-
5-
OPENAI_API_KEY=
6-
DEEPGRAM_API_KEY=
7-
CARTESIA_API_KEY=

.github/assets/livekit-mark.png

-832 Bytes
Binary file not shown.

.github/workflows/template-check.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@ jobs:
2828

2929
- name: Run tests
3030
env:
31-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
31+
LIVEKIT_URL: ${{ secrets.LIVEKIT_URL }}
32+
LIVEKIT_API_KEY: ${{ secrets.LIVEKIT_API_KEY }}
33+
LIVEKIT_API_SECRET: ${{ secrets.LIVEKIT_API_SECRET }}
3234
run: uv run pytest -v

README.md

Lines changed: 20 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,25 @@
1-
<a href="https://livekit.io/">
2-
<img src="./.github/assets/livekit-mark.png" alt="LiveKit logo" width="100" height="100">
3-
</a>
1+
# Voice Agent Hackathon Template
42

5-
# LiveKit Agents Starter - Python
6-
7-
A complete starter project for building voice AI apps with [LiveKit Agents for Python](https://github.com/livekit/agents).
8-
9-
The starter project includes:
10-
11-
- A simple voice AI assistant based on the [Voice AI quickstart](https://docs.livekit.io/agents/start/voice-ai/)
12-
- Voice AI pipeline based on [OpenAI](https://docs.livekit.io/agents/integrations/llm/openai/), [Cartesia](https://docs.livekit.io/agents/integrations/tts/cartesia/), and [Deepgram](https://docs.livekit.io/agents/integrations/llm/deepgram/)
13-
- Easily integrate your preferred [LLM](https://docs.livekit.io/agents/integrations/llm/), [STT](https://docs.livekit.io/agents/integrations/stt/), and [TTS](https://docs.livekit.io/agents/integrations/tts/) instead, or swap to a realtime model like the [OpenAI Realtime API](https://docs.livekit.io/agents/integrations/realtime/openai)
14-
- Eval suite based on the LiveKit Agents [testing & evaluation framework](https://docs.livekit.io/agents/build/testing/)
15-
- [LiveKit Turn Detector](https://docs.livekit.io/agents/build/turns/turn-detector/) for contextually-aware speaker detection, with multilingual support
16-
- [LiveKit Cloud enhanced noise cancellation](https://docs.livekit.io/home/cloud/noise-cancellation/)
17-
- Integrated [metrics and logging](https://docs.livekit.io/agents/build/metrics/)
3+
Welcome to the Voice Agent Hackathon! This template contains a ready-to-use voice agent built with [AssemblyAI](https://assemblyai.com) and [Rime](https://rime.ai). All you need to run it is a [LiveKit Cloud](https://cloud.livekit.io) project.
184

195
This starter app is compatible with any [custom web/mobile frontend](https://docs.livekit.io/agents/start/frontend/) or [SIP-based telephony](https://docs.livekit.io/agents/start/telephony/).
206

21-
## Dev Setup
7+
## Setup
228

23-
Clone the repository and install dependencies to a virtual environment:
9+
Step 1: Copy this repository (Click the green "Use this template" button on GitHub)
10+
Step 2: Clone your new copy to your local machine
11+
Step 3: Install dependencies using uv
2412

2513
```console
26-
cd agent-starter-python
14+
cd voice-agent-hackathon
2715
uv sync
2816
```
2917

30-
Set up the environment by copying `.env.example` to `.env.local` and filling in the required values:
18+
Step 4: Set up the environment by copying `.env.example` to `.env.local` and filling in the required values from your [LiveKit Cloud](https://cloud.livekit.io) project
3119

32-
- `LIVEKIT_URL`: Use [LiveKit Cloud](https://cloud.livekit.io/) or [run your own](https://docs.livekit.io/home/self-hosting/)
20+
- `LIVEKIT_URL`
3321
- `LIVEKIT_API_KEY`
3422
- `LIVEKIT_API_SECRET`
35-
- `OPENAI_API_KEY`: [Get a key](https://platform.openai.com/api-keys) or use your [preferred LLM provider](https://docs.livekit.io/agents/integrations/llm/)
36-
- `DEEPGRAM_API_KEY`: [Get a key](https://console.deepgram.com/) or use your [preferred STT provider](https://docs.livekit.io/agents/integrations/stt/)
37-
- `CARTESIA_API_KEY`: [Get a key](https://play.cartesia.ai/keys) or use your [preferred TTS provider](https://docs.livekit.io/agents/integrations/tts/)
3823

3924
You can load the LiveKit environment automatically using the [LiveKit CLI](https://docs.livekit.io/home/cli/cli-setup):
4025

@@ -56,19 +41,19 @@ Next, run this command to speak to your agent directly in your terminal:
5641
uv run python src/agent.py console
5742
```
5843

59-
To run the agent for use with a frontend or telephony, use the `dev` command:
44+
## Web playground
6045

61-
```console
62-
uv run python src/agent.py dev
63-
```
46+
## Web frontend
6447

65-
In production, use the `start` command:
48+
This agent is compatible with the [LiveKit Agents Playground](https://agents-playground.livekit.io).
6649

67-
```console
68-
uv run python src/agent.py start
69-
```
50+
To run the agent for the playground, use the `dev` subcomand:
7051

71-
## Frontend & Telephony
52+
```shell
53+
uv run agent.py dev
54+
```
55+
56+
## Custom frontend & telephony
7257

7358
Get started quickly with our pre-built frontend starter apps, or add telephony support:
7459

@@ -92,20 +77,8 @@ This project includes a complete suite of evals, based on the LiveKit Agents [te
9277
uv run pytest
9378
```
9479

95-
## Using this template repo for your own project
96-
97-
Once you've started your own project based on this repo, you should:
98-
99-
1. **Check in your `uv.lock`**: This file is currently untracked for the template, but you should commit it to your repository for reproducible builds and proper configuration management. (The same applies to `livekit.toml`, if you run your agents in LiveKit Cloud)
100-
101-
2. **Remove the git tracking test**: Delete the "Check files not tracked in git" step from `.github/workflows/tests.yml` since you'll now want this file to be tracked. These are just there for development purposes in the template repo itself.
102-
103-
3. **Add your own repository secrets**: You must [add secrets](https://docs.github.com/en/actions/how-tos/writing-workflows/choosing-what-your-workflow-does/using-secrets-in-github-actions) for `OPENAI_API_KEY` or your other LLM provider so that the tests can run in CI.
80+
To run the tests in a CI environment, you must also [add repository secrets](https://docs.github.com/en/actions/how-tos/writing-workflows/choosing-what-your-workflow-does/using-secrets-in-github-actions) for `LIVEKIT_URL`, `LIVEKIT_API_KEY`, and `LIVEKIT_API_SECRET`.
10481

10582
## Deploying to production
10683

107-
This project is production-ready and includes a working `Dockerfile`. To deploy it to LiveKit Cloud or another environment, see the [deploying to production](https://docs.livekit.io/agents/ops/deployment/) guide.
108-
109-
## License
110-
111-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
84+
This project is production-ready and includes a working `Dockerfile`. To deploy it to LiveKit Cloud or another environment, see the [deploying to production](https://docs.livekit.io/agents/ops/deployment/) guide.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "Simple voice AI assistant built with LiveKit Agents for Python"
99
requires-python = ">=3.9"
1010

1111
dependencies = [
12-
"livekit-agents[openai,turn-detector,silero,cartesia,deepgram]~=1.2",
12+
"livekit-agents[turn-detector,silero]~=1.2.11",
1313
"livekit-plugins-noise-cancellation~=0.2",
1414
"python-dotenv",
1515
]

src/agent.py

Lines changed: 55 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@
1010
JobProcess,
1111
MetricsCollectedEvent,
1212
RoomInputOptions,
13-
RunContext,
1413
WorkerOptions,
1514
cli,
1615
metrics,
1716
)
18-
from livekit.agents.llm import function_tool
19-
from livekit.plugins import cartesia, deepgram, noise_cancellation, openai, silero
20-
from livekit.plugins.turn_detector.multilingual import MultilingualModel
17+
from livekit.plugins import noise_cancellation, silero
18+
from livekit.plugins.turn_detector.english import EnglishModel
2119

2220
logger = logging.getLogger("agent")
2321

@@ -33,21 +31,22 @@ def __init__(self) -> None:
3331
You are curious, friendly, and have a sense of humor.""",
3432
)
3533

36-
# all functions annotated with @function_tool will be passed to the LLM when this
37-
# agent is active
38-
@function_tool
39-
async def lookup_weather(self, context: RunContext, location: str):
40-
"""Use this tool to look up current weather information in the given location.
41-
42-
If the location is not supported by the weather service, the tool will indicate this. You must tell the user the location's weather is unavailable.
43-
44-
Args:
45-
location: The location to look up weather information for (e.g. city name)
46-
"""
47-
48-
logger.info(f"Looking up weather for {location}")
49-
50-
return "sunny with a temperature of 70 degrees."
34+
# To add tools, use the @function_tool decorator.
35+
# Here's an example that adds a simple weather tool.
36+
# You also have to add `from livekit.agents.llm import function_tool, RunContext` to the top of this file
37+
# @function_tool
38+
# async def lookup_weather(self, context: RunContext, location: str):
39+
# """Use this tool to look up current weather information in the given location.
40+
#
41+
# If the location is not supported by the weather service, the tool will indicate this. You must tell the user the location's weather is unavailable.
42+
#
43+
# Args:
44+
# location: The location to look up weather information for (e.g. city name)
45+
# """
46+
#
47+
# logger.info(f"Looking up weather for {location}")
48+
#
49+
# return "sunny with a temperature of 70 degrees."
5150

5251

5352
def prewarm(proc: JobProcess):
@@ -61,32 +60,47 @@ async def entrypoint(ctx: JobContext):
6160
"room": ctx.room.name,
6261
}
6362

64-
# Set up a voice AI pipeline using OpenAI, Cartesia, Deepgram, and the LiveKit turn detector
63+
# Set up a voice AI pipeline using OpenAI, Rime, AssemblyAI, and the LiveKit turn detector
6564
session = AgentSession(
66-
# A Large Language Model (LLM) is your agent's brain, processing user input and generating a response
67-
# See all providers at https://docs.livekit.io/agents/integrations/llm/
68-
llm=openai.LLM(model="gpt-4o-mini"),
69-
# Speech-to-text (STT) is your agent's ears, turning the user's speech into text that the LLM can understand
70-
# See all providers at https://docs.livekit.io/agents/integrations/stt/
71-
stt=deepgram.STT(model="nova-3", language="multi"),
72-
# Text-to-speech (TTS) is your agent's voice, turning the LLM's text into speech that the user can hear
73-
# See all providers at https://docs.livekit.io/agents/integrations/tts/
74-
tts=cartesia.TTS(voice="6f84f4b8-58a2-430c-8c79-688dad597532"),
75-
# VAD and turn detection are used to determine when the user is speaking and when the agent should respond
76-
# See more at https://docs.livekit.io/agents/build/turns
77-
turn_detection=MultilingualModel(),
65+
# This starter template uses GPT-4o-mini via LiveKit Cloud.
66+
# For a list of available models, see https://github.com/livekit/agents/blob/main/livekit-agents/livekit/agents/inference/llm.py
67+
# Or, for a wider range of models, see plugins at https://docs.livekit.io/agents/integrations/llm/
68+
llm="azure/gpt-4o-mini",
69+
70+
# This starter template uses AssemblyAI via LiveKit Cloud.
71+
# To send extra parameters, use the following session setup instead of the version above:
72+
# 1. add `from livekit.agents import inference` to the top of this file
73+
# 2. Use the following session setup instead of the version above:
74+
# stt=inference.STT(model="assemblyai", extra_kwargs={ ... })
75+
# See available configuration at https://github.com/livekit/agents/blob/main/livekit-agents/livekit/agents/inference/stt.py#L57
76+
#
77+
# Or to use your own AssemblyAI account:
78+
# 1. Install livekit-agents[assemblyai]
79+
# 2. Set ASSEMBLYAI_API_KEY in .env.local
80+
# 3. Add `from livekit.plugins import assemblyai` to the top of this file
81+
# 4. Use the following session setup instead of the version above
82+
# stt=assemblyai.STT()
83+
# See available configuration at https://docs.livekit.io/agents/integrations/stt/assemblyai/
84+
stt="assemblyai",
85+
86+
# This starter template uses Rime via LiveKit Cloud
87+
# To change the voice, alter the voice name (currently "luna") after the colon.
88+
# See available voices at https://docs.livekit.io/agents/integrations/tts/rime/#voices
89+
#
90+
# Or, to use your own Rime account:
91+
# 1. Install livekit-agents[rime]
92+
# 2. Set RIME_API_KEY in .env.local
93+
# 3. Add `from livekit.plugins import rime` to the top of this file
94+
# 4. Use the following session setup instead of the version above
95+
# tts=rime.TTS(model="arcana", speaker="luna")
96+
# See available configuration at https://docs.livekit.io/agents/integrations/tts/rime/
97+
tts="rime/arcana:luna",
98+
99+
turn_detection=EnglishModel(),
78100
vad=ctx.proc.userdata["vad"],
79-
# allow the LLM to generate a response while waiting for the end of turn
80-
# See more at https://docs.livekit.io/agents/build/audio/#preemptive-generation
81101
preemptive_generation=True,
82102
)
83103

84-
# To use a realtime model instead of a voice pipeline, use the following session setup instead:
85-
# session = AgentSession(
86-
# # See all providers at https://docs.livekit.io/agents/integrations/realtime/
87-
# llm=openai.realtime.RealtimeModel(voice="marin")
88-
# )
89-
90104
# sometimes background noise could interrupt the agent session, these are considered false positive interruptions
91105
# when it's detected, you may resume the agent's speech
92106
@session.on("agent_false_interruption")
@@ -109,22 +123,12 @@ async def log_usage():
109123

110124
ctx.add_shutdown_callback(log_usage)
111125

112-
# # Add a virtual avatar to the session, if desired
113-
# # For other providers, see https://docs.livekit.io/agents/integrations/avatar/
114-
# avatar = hedra.AvatarSession(
115-
# avatar_id="...", # See https://docs.livekit.io/agents/integrations/avatar/hedra
116-
# )
117-
# # Start the avatar and wait for it to join
118-
# await avatar.start(session, room=ctx.room)
119-
120126
# Start the session, which initializes the voice pipeline and warms up the models
121127
await session.start(
122128
agent=Assistant(),
123129
room=ctx.room,
124130
room_input_options=RoomInputOptions(
125-
# LiveKit Cloud enhanced noise cancellation
126-
# - If self-hosting, omit this parameter
127-
# - For telephony applications, use `BVCTelephony` for best results
131+
# For telephony applications, use `BVCTelephony` for best results
128132
noise_cancellation=noise_cancellation.BVC(),
129133
),
130134
)

taskfile.yaml

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)