From e397f1d05a4f0f1ec5fd2b568cb3e42556b59544 Mon Sep 17 00:00:00 2001 From: Kat Ahn Date: Thu, 6 Nov 2025 12:57:33 -0800 Subject: [PATCH 1/6] 1.3 update --- README.md | 4 ++-- pyproject.toml | 2 +- src/agent.py | 10 ++++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 180b332..cbcbdbc 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Clone the repository and install dependencies to a virtual environment: ```console cd agent-starter-python -uv sync +uv sync --prerelease=allow ``` Sign up for [LiveKit Cloud](https://cloud.livekit.io/) then set up the environment by copying `.env.example` to `.env.local` and filling in the required keys: @@ -139,4 +139,4 @@ You can also self-host LiveKit instead of using LiveKit Cloud. See the [self-hos ## License -This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. \ No newline at end of file +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. diff --git a/pyproject.toml b/pyproject.toml index 621bc8a..a5ff793 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ description = "Simple voice AI assistant built with LiveKit Agents for Python" requires-python = ">=3.9" dependencies = [ - "livekit-agents[silero,turn-detector]~=1.2", + "livekit-agents[silero,turn-detector]~=1.3.0rc1", "livekit-plugins-noise-cancellation~=0.2", "python-dotenv", ] diff --git a/src/agent.py b/src/agent.py index d85c794..df7767c 100644 --- a/src/agent.py +++ b/src/agent.py @@ -3,6 +3,7 @@ from dotenv import load_dotenv from livekit.agents import ( Agent, + AgentServer, AgentSession, JobContext, JobProcess, @@ -48,11 +49,16 @@ def __init__(self) -> None: # return "sunny with a temperature of 70 degrees." +server = AgentServer() + + +@server.setup() def prewarm(proc: JobProcess): proc.userdata["vad"] = silero.VAD.load() -async def entrypoint(ctx: JobContext): +@server.rtc_session() +async def my_agent(ctx: JobContext): # Logging setup # Add any other context you want in all log entries here ctx.log_context_fields = { @@ -129,4 +135,4 @@ async def log_usage(): if __name__ == "__main__": - cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint, prewarm_fnc=prewarm)) + cli.run_app(server) From 56b28e369c8977a8b5f481000f39444dcff12eac Mon Sep 17 00:00:00 2001 From: Kat Ahn Date: Sun, 16 Nov 2025 20:59:27 -0800 Subject: [PATCH 2/6] Updates per feedback; prewarm_fnc updates --- pyproject.toml | 3 ++- src/agent.py | 37 +++++++++++-------------------------- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a5ff793..599965c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,8 @@ description = "Simple voice AI assistant built with LiveKit Agents for Python" requires-python = ">=3.9" dependencies = [ - "livekit-agents[silero,turn-detector]~=1.3.0rc1", + "livekit-agents[turn-detector]~=1.3.0rc2", + "livekit-plugins-silero~=1.3.0rc1", "livekit-plugins-noise-cancellation~=0.2", "python-dotenv", ] diff --git a/src/agent.py b/src/agent.py index df7767c..4175fc9 100644 --- a/src/agent.py +++ b/src/agent.py @@ -7,12 +7,9 @@ AgentSession, JobContext, JobProcess, - MetricsCollectedEvent, - RoomInputOptions, - WorkerOptions, cli, inference, - metrics, + room_io, ) from livekit.plugins import noise_cancellation, silero from livekit.plugins.turn_detector.multilingual import MultilingualModel @@ -49,14 +46,15 @@ def __init__(self) -> None: # return "sunny with a temperature of 70 degrees." -server = AgentServer() - - -@server.setup() def prewarm(proc: JobProcess): proc.userdata["vad"] = silero.VAD.load() +server = AgentServer( + setup_fnc = prewarm, +) + + @server.rtc_session() async def my_agent(ctx: JobContext): # Logging setup @@ -97,21 +95,6 @@ async def my_agent(ctx: JobContext): # llm=openai.realtime.RealtimeModel(voice="marin") # ) - # Metrics collection, to measure pipeline performance - # For more information, see https://docs.livekit.io/agents/build/metrics/ - usage_collector = metrics.UsageCollector() - - @session.on("metrics_collected") - def _on_metrics_collected(ev: MetricsCollectedEvent): - metrics.log_metrics(ev.metrics) - usage_collector.collect(ev.metrics) - - async def log_usage(): - summary = usage_collector.get_summary() - logger.info(f"Usage: {summary}") - - ctx.add_shutdown_callback(log_usage) - # # Add a virtual avatar to the session, if desired # # For other providers, see https://docs.livekit.io/agents/models/avatar/ # avatar = hedra.AvatarSession( @@ -124,9 +107,11 @@ async def log_usage(): await session.start( agent=Assistant(), room=ctx.room, - room_input_options=RoomInputOptions( - # For telephony applications, use `BVCTelephony` for best results - noise_cancellation=noise_cancellation.BVC(), + room_options=room_io.RoomOptions( + audio_input=room_io.AudioInputOptions( + # For telephony applications, use `BVCTelephony` for best results + noise_cancellation=noise_cancellation.BVC(), + ), ), ) From c542b747242bd71aa6ae472d5351eaa430a165fb Mon Sep 17 00:00:00 2001 From: Kat Ahn Date: Mon, 17 Nov 2025 00:14:21 -0800 Subject: [PATCH 3/6] Release updates --- README.md | 2 +- pyproject.toml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cbcbdbc..01e9562 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Clone the repository and install dependencies to a virtual environment: ```console cd agent-starter-python -uv sync --prerelease=allow +uv sync ``` Sign up for [LiveKit Cloud](https://cloud.livekit.io/) then set up the environment by copying `.env.example` to `.env.local` and filling in the required keys: diff --git a/pyproject.toml b/pyproject.toml index 599965c..f4f4fd5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,8 +9,7 @@ description = "Simple voice AI assistant built with LiveKit Agents for Python" requires-python = ">=3.9" dependencies = [ - "livekit-agents[turn-detector]~=1.3.0rc2", - "livekit-plugins-silero~=1.3.0rc1", + "livekit-agents[silero,turn-detector]~=1.3.2", "livekit-plugins-noise-cancellation~=0.2", "python-dotenv", ] From b1ec4f205b2edb4eedd7314e3cd12de9f7129577 Mon Sep 17 00:00:00 2001 From: Kat Ahn Date: Mon, 17 Nov 2025 09:13:01 -0800 Subject: [PATCH 4/6] Update pyproject.toml Co-authored-by: Ben Cherry --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f4f4fd5..3f6a5ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ description = "Simple voice AI assistant built with LiveKit Agents for Python" requires-python = ">=3.9" dependencies = [ - "livekit-agents[silero,turn-detector]~=1.3.2", + "livekit-agents[silero,turn-detector]~=1.3", "livekit-plugins-noise-cancellation~=0.2", "python-dotenv", ] From 3eb2c81415545f1ec38d2139dad706ca3a15a624 Mon Sep 17 00:00:00 2001 From: Kat Ahn Date: Mon, 17 Nov 2025 09:13:12 -0800 Subject: [PATCH 5/6] Update src/agent.py Co-authored-by: Ben Cherry --- src/agent.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/agent.py b/src/agent.py index 4175fc9..0dc97a0 100644 --- a/src/agent.py +++ b/src/agent.py @@ -107,10 +107,9 @@ async def my_agent(ctx: JobContext): await session.start( agent=Assistant(), room=ctx.room, - room_options=room_io.RoomOptions( +room_options=room_io.RoomOptions( audio_input=room_io.AudioInputOptions( - # For telephony applications, use `BVCTelephony` for best results - noise_cancellation=noise_cancellation.BVC(), + noise_cancellation=lambda params: noise_cancellation.BVCTelephony() if params.participant.kind == rtc.ParticipantKind.PARTICIPANT_KIND_SIP else noise_cancellation.BVC(), ), ), ) From 168d8926025ac1bf111db23f3fd66801565c35f8 Mon Sep 17 00:00:00 2001 From: Kat Ahn Date: Mon, 17 Nov 2025 09:17:23 -0800 Subject: [PATCH 6/6] Update prewarm; fix issues with recent commits --- src/agent.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/agent.py b/src/agent.py index 0dc97a0..aab4ded 100644 --- a/src/agent.py +++ b/src/agent.py @@ -1,6 +1,7 @@ import logging from dotenv import load_dotenv +from livekit import rtc from livekit.agents import ( Agent, AgentServer, @@ -46,13 +47,14 @@ def __init__(self) -> None: # return "sunny with a temperature of 70 degrees." +server = AgentServer() + + def prewarm(proc: JobProcess): proc.userdata["vad"] = silero.VAD.load() -server = AgentServer( - setup_fnc = prewarm, -) +server.setup_fnc = prewarm @server.rtc_session() @@ -107,9 +109,11 @@ async def my_agent(ctx: JobContext): await session.start( agent=Assistant(), room=ctx.room, -room_options=room_io.RoomOptions( + room_options=room_io.RoomOptions( audio_input=room_io.AudioInputOptions( - noise_cancellation=lambda params: noise_cancellation.BVCTelephony() if params.participant.kind == rtc.ParticipantKind.PARTICIPANT_KIND_SIP else noise_cancellation.BVC(), + noise_cancellation=lambda params: noise_cancellation.BVCTelephony() + if params.participant.kind == rtc.ParticipantKind.PARTICIPANT_KIND_SIP + else noise_cancellation.BVC(), ), ), )