Skip to content

Commit 8c2b967

Browse files
authored
livekit-agents 1.3.0 (#3956)
2 parents bb871e3 + 6fed34a commit 8c2b967

File tree

248 files changed

+8966
-2558
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

248 files changed

+8966
-2558
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
paths-ignore:
77
- '**/*.md'
88
pull_request:
9-
branches: [main, 0.x]
109
paths-ignore:
1110
- '**/*.md'
1211
workflow_dispatch:

examples/avatar_agents/anam/agent_worker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33

44
from dotenv import load_dotenv
55

6-
from livekit.agents import Agent, AgentSession, JobContext, WorkerOptions, WorkerType, cli
6+
from livekit.agents import Agent, AgentServer, AgentSession, JobContext, cli
77
from livekit.plugins import anam, openai
88

99
logger = logging.getLogger("anam-avatar-example")
1010
logger.setLevel(logging.INFO)
1111

1212
load_dotenv()
1313

14+
server = AgentServer()
1415

16+
17+
@server.rtc_session()
1518
async def entrypoint(ctx: JobContext):
1619
session = AgentSession(
1720
llm=openai.realtime.RealtimeModel(voice="alloy"),
@@ -44,4 +47,4 @@ async def entrypoint(ctx: JobContext):
4447

4548

4649
if __name__ == "__main__":
47-
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint, worker_type=WorkerType.ROOM))
50+
cli.run_app(server)

examples/avatar_agents/audio_wave/agent_worker.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,18 @@
88
from dotenv import load_dotenv
99

1010
from livekit import api, rtc
11-
from livekit.agents import JobContext, WorkerOptions, WorkerType, cli
12-
from livekit.agents.voice import Agent, AgentSession
11+
from livekit.agents import Agent, AgentServer, AgentSession, JobContext, cli
1312
from livekit.agents.voice.avatar import DataStreamAudioOutput
1413
from livekit.agents.voice.io import PlaybackFinishedEvent
15-
from livekit.agents.voice.room_io import ATTRIBUTE_PUBLISH_ON_BEHALF, RoomOutputOptions
14+
from livekit.agents.voice.room_io import ATTRIBUTE_PUBLISH_ON_BEHALF
1615
from livekit.plugins import openai
1716

18-
logger = logging.getLogger("avatar-example")
19-
logger.setLevel(logging.INFO)
20-
2117
load_dotenv()
2218

19+
logger = logging.getLogger("avatar-example")
20+
logger.setLevel(logging.INFO)
2321

22+
server = AgentServer()
2423
AVATAR_IDENTITY = "avatar_worker"
2524

2625

@@ -83,10 +82,6 @@ async def entrypoint(ctx: JobContext, avatar_dispatcher_url: str):
8382
await session.start(
8483
agent=agent,
8584
room=ctx.room,
86-
room_output_options=RoomOutputOptions(
87-
audio_enabled=False,
88-
transcription_enabled=True,
89-
),
9085
)
9186

9287
@session.output.audio.on("playback_finished")
@@ -107,9 +102,5 @@ def on_playback_finished(ev: PlaybackFinishedEvent) -> None:
107102
args, remaining_args = parser.parse_known_args()
108103
sys.argv = sys.argv[:1] + remaining_args
109104

110-
cli.run_app(
111-
WorkerOptions(
112-
entrypoint_fnc=partial(entrypoint, avatar_dispatcher_url=args.avatar_url),
113-
worker_type=WorkerType.ROOM,
114-
)
115-
)
105+
server.rtc_session(partial(entrypoint, avatar_dispatcher_url=args.avatar_url))
106+
cli.run_app(server)

examples/avatar_agents/bey/agent_worker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33

44
from dotenv import load_dotenv
55

6-
from livekit.agents import Agent, AgentSession, JobContext, WorkerOptions, WorkerType, cli
6+
from livekit.agents import Agent, AgentServer, AgentSession, JobContext, cli
77
from livekit.plugins import bey, openai
88

99
logger = logging.getLogger("bey-avatar-example")
1010
logger.setLevel(logging.INFO)
1111

1212
load_dotenv()
1313

14+
server = AgentServer()
1415

16+
17+
@server.rtc_session()
1518
async def entrypoint(ctx: JobContext):
1619
session = AgentSession(
1720
llm=openai.realtime.RealtimeModel(voice="alloy"),
@@ -31,4 +34,4 @@ async def entrypoint(ctx: JobContext):
3134

3235

3336
if __name__ == "__main__":
34-
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint, worker_type=WorkerType.ROOM))
37+
cli.run_app(server)

examples/avatar_agents/bithuman/agent_cloud.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66

77
from livekit.agents import (
88
Agent,
9+
AgentServer,
910
AgentSession,
1011
JobContext,
11-
RoomOutputOptions,
12-
WorkerOptions,
13-
WorkerType,
1412
cli,
13+
room_io,
1514
)
1615
from livekit.plugins import bithuman, openai
1716

@@ -20,7 +19,10 @@
2019

2120
load_dotenv()
2221

22+
server = AgentServer()
2323

24+
25+
@server.rtc_session()
2426
async def entrypoint(ctx: JobContext):
2527
await ctx.connect()
2628

@@ -40,9 +42,9 @@ async def entrypoint(ctx: JobContext):
4042
agent=Agent(instructions="Talk to me!"),
4143
room=ctx.room,
4244
# audio is forwarded to the avatar, so we disable room audio output
43-
room_output_options=RoomOutputOptions(audio_enabled=False),
45+
room_options=room_io.RoomOptions(audio_output=False),
4446
)
4547

4648

4749
if __name__ == "__main__":
48-
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint, worker_type=WorkerType.ROOM))
50+
cli.run_app(server)

examples/avatar_agents/bithuman/agent_local.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66

77
from livekit.agents import (
88
Agent,
9+
AgentServer,
910
AgentSession,
1011
JobContext,
1112
JobProcess,
12-
WorkerOptions,
13-
WorkerType,
1413
cli,
1514
)
1615
from livekit.plugins import bithuman, openai
@@ -23,7 +22,10 @@
2322
bithuman_model_path = os.getenv("BITHUMAN_MODEL_PATH")
2423
bithuman_api_secret = os.getenv("BITHUMAN_API_SECRET")
2524

25+
server = AgentServer(job_memory_warn_mb=1500, initialize_process_timeout=60, num_idle_processes=1)
2626

27+
28+
@server.rtc_session()
2729
async def entrypoint(ctx: JobContext):
2830
session = AgentSession(
2931
llm=openai.realtime.RealtimeModel(voice="ash"),
@@ -43,6 +45,7 @@ async def entrypoint(ctx: JobContext):
4345
)
4446

4547

48+
@server.setup()
4649
def prewarm(proc: JobProcess):
4750
if not bithuman_model_path:
4851
return
@@ -57,13 +60,4 @@ def prewarm(proc: JobProcess):
5760

5861

5962
if __name__ == "__main__":
60-
cli.run_app(
61-
WorkerOptions(
62-
entrypoint_fnc=entrypoint,
63-
worker_type=WorkerType.ROOM,
64-
job_memory_warn_mb=1500,
65-
prewarm_fnc=prewarm,
66-
initialize_process_timeout=60,
67-
num_idle_processes=1,
68-
)
69-
)
63+
cli.run_app(server)

examples/avatar_agents/bithuman/agent_worker.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66

77
from livekit.agents import (
88
Agent,
9+
AgentServer,
910
AgentSession,
1011
JobContext,
1112
JobProcess,
12-
WorkerOptions,
13-
WorkerType,
1413
cli,
1514
)
1615
from livekit.plugins import bithuman, openai
@@ -23,7 +22,10 @@
2322
bithuman_model_path = os.getenv("BITHUMAN_MODEL_PATH")
2423
bithuman_api_secret = os.getenv("BITHUMAN_API_SECRET")
2524

25+
server = AgentServer(job_memory_warn_mb=1500, initialize_process_timeout=60, num_idle_processes=1)
2626

27+
28+
@server.rtc_session()
2729
async def entrypoint(ctx: JobContext):
2830
session = AgentSession(
2931
llm=openai.realtime.RealtimeModel(voice="ash"),
@@ -43,6 +45,7 @@ async def entrypoint(ctx: JobContext):
4345
)
4446

4547

48+
@server.setup()
4649
def prewarm(proc: JobProcess):
4750
if not bithuman_model_path:
4851
return
@@ -57,13 +60,4 @@ def prewarm(proc: JobProcess):
5760

5861

5962
if __name__ == "__main__":
60-
cli.run_app(
61-
WorkerOptions(
62-
entrypoint_fnc=entrypoint,
63-
worker_type=WorkerType.ROOM,
64-
job_memory_warn_mb=1500,
65-
prewarm_fnc=prewarm,
66-
initialize_process_timeout=60,
67-
num_idle_processes=1,
68-
)
69-
)
63+
cli.run_app(server)

examples/avatar_agents/hedra/agent_worker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44
from dotenv import load_dotenv
55
from PIL import Image
66

7-
from livekit.agents import Agent, AgentSession, JobContext, WorkerOptions, WorkerType, cli
7+
from livekit.agents import Agent, AgentServer, AgentSession, JobContext, cli
88
from livekit.plugins import hedra, openai
99

1010
logger = logging.getLogger("hedra-avatar-example")
1111
logger.setLevel(logging.INFO)
1212

1313
load_dotenv()
1414

15+
server = AgentServer()
1516

17+
18+
@server.rtc_session()
1619
async def entrypoint(ctx: JobContext):
1720
session = AgentSession(
1821
llm=openai.realtime.RealtimeModel(voice="alloy"),
@@ -33,4 +36,4 @@ async def entrypoint(ctx: JobContext):
3336

3437

3538
if __name__ == "__main__":
36-
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint, worker_type=WorkerType.ROOM))
39+
cli.run_app(server)

examples/avatar_agents/simli/agent_worker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from dotenv import load_dotenv
55

6-
from livekit.agents import Agent, AgentSession, JobContext, WorkerOptions, WorkerType, cli
6+
from livekit.agents import Agent, AgentServer, AgentSession, JobContext, cli
77
from livekit.plugins import openai, simli
88

99
# from livekit.plugins import deepgram, elevenlabs, silero
@@ -13,7 +13,10 @@
1313

1414
load_dotenv()
1515

16+
server = AgentServer()
1617

18+
19+
@server.rtc_session()
1720
async def entrypoint(ctx: JobContext):
1821
session = AgentSession(
1922
llm=openai.realtime.RealtimeModel(voice="alloy"),
@@ -39,4 +42,4 @@ async def entrypoint(ctx: JobContext):
3942

4043

4144
if __name__ == "__main__":
42-
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint, worker_type=WorkerType.ROOM))
45+
cli.run_app(server)

examples/avatar_agents/tavus/agent_worker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33

44
from dotenv import load_dotenv
55

6-
from livekit.agents import Agent, AgentSession, JobContext, WorkerOptions, WorkerType, cli
6+
from livekit.agents import Agent, AgentServer, AgentSession, JobContext, cli
77
from livekit.plugins import openai, tavus
88

99
logger = logging.getLogger("tavus-avatar-example")
1010
logger.setLevel(logging.INFO)
1111

1212
load_dotenv()
1313

14+
server = AgentServer()
1415

16+
17+
@server.rtc_session()
1518
async def entrypoint(ctx: JobContext):
1619
session = AgentSession(
1720
llm=openai.realtime.RealtimeModel(voice="alloy"),
@@ -33,4 +36,4 @@ async def entrypoint(ctx: JobContext):
3336

3437

3538
if __name__ == "__main__":
36-
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint, worker_type=WorkerType.ROOM))
39+
cli.run_app(server)

0 commit comments

Comments
 (0)