-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathcalling_agent.py
More file actions
64 lines (56 loc) · 1.9 KB
/
calling_agent.py
File metadata and controls
64 lines (56 loc) · 1.9 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
59
60
61
62
63
64
"""
---
title: Outbound Calling Agent
category: telephony
tags: [telephony, outbound-calls, survey, ice-cream-preference]
difficulty: beginner
description: Agent that makes outbound calls to ask about ice cream preferences
demonstrates:
- Outbound call agent configuration
- Goal-oriented conversation flow
- Focused questioning strategy
- Brief and direct interaction patterns
- Automatic greeting generation
---
"""
import logging
import os
from pathlib import Path
from dotenv import load_dotenv
from livekit.agents import JobContext, WorkerOptions, cli, Agent, AgentSession
from livekit.plugins import openai, silero, deepgram
load_dotenv()
logger = logging.getLogger("calling-agent")
logger.setLevel(logging.INFO)
class SimpleAgent(Agent):
def __init__(self) -> None:
super().__init__(
instructions="""
You are calling someone on the phone. Your goal is to know if they prefer
chocolate or vanilla ice cream. That's the only question you should ask, and
you should get right to the point. Say something like "Hello, I'm calling to
ask you a question about ice cream. Do you prefer chocolate or vanilla?"
""",
stt=inference.STT(
model="deepgram/nova-3-general"
),
llm=inference.LLM(
model="openai/gpt-5-mini",
provider="openai",
),
tts=inference.TTS(
model="cartesia/sonic-3",
voice="9626c31c-bec5-4cca-baa8-f8ba9e84c8bc",
),
vad=silero.VAD.load()
)
async def on_enter(self):
self.session.generate_reply()
async def entrypoint(ctx: JobContext):
session = AgentSession()
await session.start(
agent=SimpleAgent(),
room=ctx.room
)
if __name__ == "__main__":
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))