Skip to content

Commit 4e4e194

Browse files
committed
initial implementation of oai response ws
1 parent 3e0c6be commit 4e4e194

9 files changed

Lines changed: 799 additions & 10 deletions

File tree

examples/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
},
1818
"devDependencies": {
1919
"@types/node": "^22.5.5",
20+
"@types/ws": "^8.18.1",
2021
"tsx": "^4.19.2",
2122
"typescript": "^5.0.0",
2223
"vitest": "^3.2.2",
@@ -48,8 +49,8 @@
4849
"@opentelemetry/exporter-logs-otlp-http": "^0.54.0",
4950
"@opentelemetry/exporter-trace-otlp-http": "^0.54.0",
5051
"@opentelemetry/otlp-exporter-base": "^0.54.0",
51-
"@opentelemetry/sdk-logs": "^0.54.0",
5252
"@opentelemetry/resources": "^1.28.0",
53+
"@opentelemetry/sdk-logs": "^0.54.0",
5354
"@opentelemetry/sdk-trace-base": "^1.28.0",
5455
"@opentelemetry/sdk-trace-node": "^1.28.0",
5556
"@opentelemetry/semantic-conventions": "^1.28.0",

examples/src/basic_agent_task.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export default defineAgent({
117117
const session = new voice.AgentSession({
118118
vad: ctx.proc.userData.vad as silero.VAD,
119119
stt: new inference.STT({ model: 'deepgram/nova-3' }),
120-
llm: new openai.responses.LLM(),
120+
llm: new openai.ws.LLM(),
121121
tts: new inference.TTS({
122122
model: 'cartesia/sonic-3',
123123
voice: '9626c31c-bec5-4cca-baa8-f8ba9e84c8bc',

plugins/openai/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
},
5151
"peerDependencies": {
5252
"@livekit/agents": "workspace:*",
53-
"@livekit/rtc-node": "catalog:"
53+
"@livekit/rtc-node": "catalog:",
54+
"zod": "^3.25.76 || ^4.1.8"
5455
}
5556
}

plugins/openai/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export * as realtime from './realtime/index.js';
99
export * as responses from './responses/index.js';
1010
export { STT, type STTOptions } from './stt.js';
1111
export { ChunkedStream, TTS, type TTSOptions } from './tts.js';
12+
export * as ws from './ws/index.js';
1213

1314
class OpenAIPlugin extends Plugin {
1415
constructor() {

plugins/openai/src/ws/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// SPDX-FileCopyrightText: 2025 LiveKit, Inc.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
export { LLM, LLMStream, ResponsesWebSocket } from './llm.js';
6+
export * from './types.js';

plugins/openai/src/ws/llm.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// SPDX-FileCopyrightText: 2025 LiveKit, Inc.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
import { llm, llmStrict } from '@livekit/agents-plugins-test';
5+
import { describe } from 'vitest';
6+
import { LLM } from './llm.js';
7+
8+
describe('OpenAI Responses WS', async () => {
9+
await llm(
10+
new LLM({
11+
temperature: 0,
12+
strictToolSchema: false,
13+
}),
14+
true,
15+
);
16+
});
17+
18+
describe('OpenAI Responses WS strict tool schema', async () => {
19+
await llmStrict(
20+
new LLM({
21+
temperature: 0,
22+
strictToolSchema: true,
23+
}),
24+
);
25+
});

0 commit comments

Comments
 (0)