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
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@
"devDependencies": {
"@eslint/js": "^9.39.2",
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
"@types/node": "^22.19.7",
"@types/node": "^22.19.11",
"eslint": "^9.39.2",
"globals": "^16.5.0",
"jiti": "^2.6.1",
"typescript": "^5.9.3",
"typescript-eslint": "^8.54.0",
"typescript-eslint": "^8.55.0",
"vite": "^7.3.1",
"vitest": "^4.0.18"
},
"dependencies": {
"@livekit/agents": "^1.0.40",
"@livekit/agents-plugin-livekit": "^1.0.40",
"@livekit/agents-plugin-silero": "^1.0.40",
"@livekit/agents": "^1.0.43",
"@livekit/agents-plugin-livekit": "^1.0.43",
"@livekit/agents-plugin-silero": "^1.0.43",
"@livekit/noise-cancellation-node": "^0.1.9",
"dotenv": "^17.2.3",
"dotenv": "^17.2.4",
"zod": "^3.25.76"
}
}
4 changes: 2 additions & 2 deletions src/agent.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { inference, initializeLogger, voice } from '@livekit/agents';
import dotenv from 'dotenv';
import { afterEach, beforeEach, describe, it } from 'vitest';
import { Assistant } from './agent.js';
import { Agent } from './agent';

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

Expand All @@ -15,7 +15,7 @@ describe('agent evaluation', () => {
beforeEach(async () => {
llmInstance = new inference.LLM({ model: 'openai/gpt-5.1' });
session = new voice.AgentSession({ llm: llmInstance });
await session.start({ agent: new Assistant() });
await session.start({ agent: new Agent() });
});

afterEach(async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/agent.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { voice } from '@livekit/agents';

// Define a custom voice AI assistant by extending the base Agent class
export class Assistant extends voice.Agent {
export class Agent extends voice.Agent {
constructor() {
super({
instructions: `You are a helpful voice AI assistant. The user is interacting with you via voice, even if you perceive the conversation as text.
Expand Down
11 changes: 8 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as silero from '@livekit/agents-plugin-silero';
import { BackgroundVoiceCancellation } from '@livekit/noise-cancellation-node';
import dotenv from 'dotenv';
import { fileURLToPath } from 'node:url';
import { Assistant } from './agent.js';
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 Down Expand Up @@ -84,7 +84,7 @@ export default defineAgent({

// Start the session, which initializes the voice pipeline and warms up the models
await session.start({
agent: new Assistant(),
agent: new Agent(),
room: ctx.room,
inputOptions: {
// LiveKit Cloud enhanced noise cancellation
Expand All @@ -105,4 +105,9 @@ export default defineAgent({
});

// Run the agent server
cli.runApp(new ServerOptions({ agent: fileURLToPath(import.meta.url) }));
cli.runApp(
new ServerOptions({
agent: fileURLToPath(import.meta.url),
agentName: 'my-agent',
}),
);
6 changes: 3 additions & 3 deletions taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ vars:
INDENT: 4
REL_PATH: "{{ relPath .USER_WORKING_DIR .ROOT_DIR }}"
VENV_DIR: ".venv"
NODE_MAIN: '{{ joinPath "./src" "agent.ts" }}'
NODE_MAIN: '{{ joinPath "./src" "main.ts" }}'

tasks:
post_create:
Expand All @@ -31,8 +31,8 @@ tasks:
- test -z "$LIVEKIT_AGENT_NAME"
cmds:
- |
old="WorkerOptions("
new="WorkerOptions(agent_name=\"{{ .LIVEKIT_AGENT_NAME }}\", "
old="agentName: 'my-agent'"
new="agentName: '{{ .LIVEKIT_AGENT_NAME }}'"
file="{{ .NODE_MAIN }}"
tmp="$(mktemp)"
while IFS= read -r line; do
Expand Down