Skip to content
Merged
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
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
"vitest": "^4.1.4"
},
"dependencies": {
"@livekit/agents": "^1.3.0",
"@livekit/agents-plugin-livekit": "^1.3.0",
"@livekit/agents-plugin-silero": "^1.3.0",
"@livekit/plugins-ai-coustics": "^0.2.10",
"@livekit/agents": "^1.4.0",
"@livekit/agents-plugin-livekit": "^1.4.0",
"@livekit/agents-plugin-silero": "^1.4.0",
"@livekit/plugins-ai-coustics": "^0.2.12",
"dotenv": "^17.4.1",
"zod": "^3.25.76"
}
Expand Down
8 changes: 2 additions & 6 deletions src/agent.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { dedent, inference, initializeLogger, voice } from '@livekit/agents';
import dotenv from 'dotenv';
import { afterEach, beforeEach, describe, it } from 'vitest';
import { AGENT_MODEL, Agent } from './agent';
import { Agent } from './agent';

dotenv.config({ path: '.env.local' });

Expand All @@ -11,20 +11,16 @@ initializeLogger({ pretty: true, level: 'warn' });

describe('agent evaluation', () => {
let session: voice.AgentSession;
let agentLlm: inference.LLM;
let judgeLlm: inference.LLM;

beforeEach(async () => {
agentLlm = new inference.LLM({ model: AGENT_MODEL });
// The judge LLM can be a cheaper model since it only evaluates agent responses
judgeLlm = new inference.LLM({ model: 'openai/gpt-4.1-mini' });
session = new voice.AgentSession({ llm: agentLlm });
session = new voice.AgentSession();
await session.start({ agent: new Agent() });
});

afterEach(async () => {
await session?.close();
await agentLlm?.aclose();
await judgeLlm?.aclose();
});

Expand Down
17 changes: 14 additions & 3 deletions src/agent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { dedent, voice } from '@livekit/agents';

export const AGENT_MODEL = 'openai/gpt-5.2-chat-latest';
import { dedent, inference, voice } from '@livekit/agents';

// Define a custom voice AI assistant by extending the base Agent class
export class Agent extends voice.Agent {
Expand Down Expand Up @@ -40,6 +38,19 @@ export class Agent extends voice.Agent {
- Protect privacy and minimize sensitive data.
`,

// A Large Language Model (LLM) is your agent's brain, processing user input and generating a response
// See all available models at https://docs.livekit.io/agents/models/llm/
llm: new inference.LLM({ model: 'openai/gpt-5.2-chat-latest' }),

// To use a realtime model instead of a voice pipeline, replace the LLM
// with a RealtimeModel and remove the STT/TTS from the AgentSession
// (Note: This is for the OpenAI Realtime API. For other providers, see https://docs.livekit.io/agents/models/realtime/)
// 1. Install '@livekit/agents-plugin-openai'
// 2. Set OPENAI_API_KEY in .env.local
// 3. Add `import * as openai from '@livekit/agents-plugin-openai'` to the top of this file
// 4. Replace the llm option with:
// llm: new openai.realtime.RealtimeModel({ voice: 'marin' }),

// To add tools, specify `tools` in the constructor.
// Here's an example that adds a simple weather tool.
// You also have to add `import { llm } from '@livekit/agents' and `import { z } from 'zod'` to the top of this file
Expand Down
18 changes: 1 addition & 17 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as silero from '@livekit/agents-plugin-silero';
import { audioEnhancement } from '@livekit/plugins-ai-coustics';
import dotenv from 'dotenv';
import { fileURLToPath } from 'node:url';
import { AGENT_MODEL, Agent } from './agent';
import { Agent } from './agent';

// Load environment variables from a local file.
// Make sure to set LIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET
Expand All @@ -29,12 +29,6 @@ export default defineAgent<ProcessUserData>({
language: 'multi',
}),

// A Large Language Model (LLM) is your agent's brain, processing user input and generating a response
// See all providers at https://docs.livekit.io/agents/models/llm/
llm: new inference.LLM({
model: AGENT_MODEL,
}),

// 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: new inference.TTS({
Expand All @@ -52,16 +46,6 @@ export default defineAgent<ProcessUserData>({
},
});

// To use a realtime model instead of a voice pipeline, use the following session setup instead.
// (Note: This is for the OpenAI Realtime API. For other providers, see https://docs.livekit.io/agents/models/realtime/))
// 1. Install '@livekit/agents-plugin-openai'
// 2. Set OPENAI_API_KEY in .env.local
// 3. Add import `import * as openai from '@livekit/agents-plugin-openai'` to the top of this file
// 4. Use the following session setup instead of the version above
// const session = new voice.AgentSession({
// llm: new openai.realtime.RealtimeModel({ voice: 'marin' }),
// });

// Start the session, which initializes the voice pipeline and warms up the models
await session.start({
agent: new Agent(),
Expand Down
Loading