diff --git a/package.json b/package.json index 388ecef..eda6c56 100644 --- a/package.json +++ b/package.json @@ -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" } diff --git a/src/agent.test.ts b/src/agent.test.ts index 366c04e..46de9fa 100644 --- a/src/agent.test.ts +++ b/src/agent.test.ts @@ -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' }); @@ -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(); }); diff --git a/src/agent.ts b/src/agent.ts index f739453..35da056 100644 --- a/src/agent.ts +++ b/src/agent.ts @@ -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 { @@ -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 diff --git a/src/main.ts b/src/main.ts index 407db5e..50877b8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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 @@ -29,12 +29,6 @@ export default defineAgent({ 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({ @@ -52,16 +46,6 @@ export default defineAgent({ }, }); - // 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(),