-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathuninterruptable.py
37 lines (29 loc) · 1.17 KB
/
uninterruptable.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# This agent isn't interruptable, so it will keep talking even if the user tries to speak.
from pathlib import Path
from dotenv import load_dotenv
from livekit.agents import JobContext, WorkerOptions, cli
from livekit.agents.voice import Agent, AgentSession
from livekit.plugins import deepgram, openai
load_dotenv(dotenv_path=Path(__file__).parent.parent / '.env')
class UninterruptableAgent(Agent):
def __init__(self) -> None:
super().__init__(
instructions="""
You are a helpful assistant communicating through voice who is not interruptable.
""",
stt=deepgram.STT(),
llm=openai.LLM(model="gpt-4o"),
tts=openai.TTS(),
allow_interruptions=False
)
async def on_enter(self):
self.session.generate_reply(user_input="Say something somewhat long and boring so I can test if you're interruptable.")
async def entrypoint(ctx: JobContext):
await ctx.connect()
session = AgentSession()
await session.start(
agent=UninterruptableAgent(),
room=ctx.room
)
if __name__ == "__main__":
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))