Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions scenarios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,17 @@ scenarios:
alternative, such as the friend using the official account recovery flow.
tags:
feature: guardrails

- id: SCN_TtzF5iELiBRA
label: Ends the call when the user is done
instructions: |
PERSONA: A user with one quick question who wants to hang up as soon as it's answered.
OPENING LINE: "What's the capital of France?"
DO, IN ORDER:
1. Once the assistant answers, say: "Great, that's all I needed. Bye!"
agent_expectations: >
Answers the question briefly, then says goodbye and ends the call with the
end_call tool once the user says they are done. Does not end the call
before the question is answered.
tags:
feature: end-call
15 changes: 12 additions & 3 deletions src/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
inference,
room_io,
)
from livekit.agents.beta import EndCallTool
from livekit.plugins import ai_coustics

logger = logging.getLogger("agent")
Expand Down Expand Up @@ -67,9 +68,13 @@ def __init__(self) -> None:
- Protect privacy and minimize sensitive data.
"""
),
# EndCallTool lets the agent hang up when the user is done, and deletes the room
# so every participant, including SIP callers, is disconnected.
# See more at https://docs.livekit.io/agents/prebuilt/tools/end-call-tool/
tools=[EndCallTool()],
)

# To add tools, use the @function_tool decorator.
# To add your own tools, use the @function_tool decorator.
# Here's an example that adds a simple weather tool.
# You also have to add `from livekit.agents import function_tool, RunContext` to the top of this file
# @function_tool
Expand All @@ -91,7 +96,7 @@ def __init__(self) -> None:


@server.rtc_session(agent_name="my-agent")
async def my_agent(ctx: JobContext):
async def my_agent(ctx: JobContext) -> None:
# Logging setup
# Add any other context you want in all log entries here
ctx.log_context_fields = {
Expand All @@ -115,7 +120,11 @@ async def my_agent(ctx: JobContext):
# Text-to-speech (TTS) is your agent's voice, turning the LLM's text into speech that the user can hear
# See all available models as well as voice selections at https://docs.livekit.io/agents/models/tts/
tts=inference.TTS(
model="fishaudio/s2.1-pro", voice="fa4c9eb3dccc4806b382b40d61c6b10a"
model="fishaudio/s2.1-pro",
voice="fa4c9eb3dccc4806b382b40d61c6b10a",
# If the primary model fails, LiveKit Inference tries these models in order
# See more at https://docs.livekit.io/agents/logic/fallback-strategies/
fallback=[{"model": "rime/coda", "voice": "astra"}],
),
turn_handling=TurnHandlingOptions(
# The LiveKit turn detector determines when the user is done speaking and the agent should respond.
Expand Down
Loading
Loading