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_YAcWiy4Ee2mG
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
51 changes: 28 additions & 23 deletions src/agent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Agent, dedent, inference } from '@livekit/agents';
import { Agent, beta, dedent, inference } from '@livekit/agents';

// Build a custom voice AI assistant with the functional `Agent.create` API
export function createAgent() {
Expand Down Expand Up @@ -47,29 +47,34 @@ export function createAgent() {
// (Note: This is for OpenAI GPT-Live. For other models, see https://docs.livekit.io/agents/models/realtime/)
// llm: new inference.DuplexModel({ model: 'openai/gpt-live-1', voice: 'marin' }),

// To add tools, specify `tools` in the constructor.
// The end call tool 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/
//
// To add your own tools, add them to the `tools` array.
// Here's an example that adds a simple weather tool.
// You also have to add `import { tool } from '@livekit/agents'` and `import { z } from 'zod'` to the top of this file
// tools: [
// tool({
// name: 'getWeather',
// description: dedent`
// Use this tool to look up current weather information in the given location.
//
// If the location is not supported by the weather service, the tool will indicate this.
// You must tell the user the location's weather is unavailable.
// `,
// parameters: z.object({
// location: z
// .string()
// .describe('The location to look up weather information for (e.g. city name)'),
// }),
// execute: async ({ location }) => {
// console.log(`Looking up weather for ${location}`);
//
// return 'sunny with a temperature of 70 degrees.';
// },
// }),
// ],
tools: [
beta.createEndCallTool(),
// tool({
// name: 'getWeather',
// description: dedent`
// Use this tool to look up current weather information in the given location.
//
// If the location is not supported by the weather service, the tool will indicate this.
// You must tell the user the location's weather is unavailable.
// `,
// parameters: z.object({
// location: z
// .string()
// .describe('The location to look up weather information for (e.g. city name)'),
// }),
// execute: async ({ location }) => {
// console.log(`Looking up weather for ${location}`);
//
// return 'sunny with a temperature of 70 degrees.';
// },
// }),
],
});
}
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default defineAgent({
// Speech-to-text (STT) is your agent's ears, turning the user's speech into text that the LLM can understand
// See all available models at https://docs.livekit.io/agents/models/stt/
stt: new inference.STT({
model: 'assemblyai/universal-3-6-pro',
model: 'assemblyai/assemblyai-stt-3-7-realtime-agent',
}),

// Keyterms bias the STT toward distinctive words it would otherwise misspell.
Expand All @@ -34,6 +34,9 @@ export default defineAgent({
tts: new inference.TTS({
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' }],
}),

turnHandling: {
Expand Down
Loading