-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent.py
More file actions
58 lines (45 loc) · 1.44 KB
/
agent.py
File metadata and controls
58 lines (45 loc) · 1.44 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from dotenv import load_dotenv
from livekit import agents
from livekit.agents import AgentSession, Agent, RoomInputOptions
from livekit.plugins import (
noise_cancellation,
)
from livekit.plugins import google
from prompts import AGENT_INSTRUCTION, SESSION_INSTRUCTION
from tools import get_weather, search_web, send_email
load_dotenv()
class Assistant(Agent):
def __init__(self) -> None:
super().__init__(
instructions=AGENT_INSTRUCTION,
llm=google.beta.realtime.RealtimeModel(
voice="Aoede",
temperature=0.8,
),
tools=[
get_weather,
search_web,
send_email
],
)
async def entrypoint(ctx: agents.JobContext):
session = AgentSession(
)
await session.start(
room=ctx.room,
agent=Assistant(),
room_input_options=RoomInputOptions(
# LiveKit Cloud enhanced noise cancellation
# - If self-hosting, omit this parameter
# - For telephony applications, use `BVCTelephony` for best results
video_enabled=True,
audio_enabled=True,
noise_cancellation=noise_cancellation.BVC(),
),
)
await ctx.connect()
await session.generate_reply(
instructions=SESSION_INSTRUCTION,
)
if __name__ == "__main__":
agents.cli.run_app(agents.WorkerOptions(entrypoint_fnc=entrypoint))