@livekit/agents-plugin-openai 1.9.2 → 1.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/models.cjs.map +1 -1
- package/dist/models.d.cts +1 -0
- package/dist/models.d.ts +1 -0
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/realtime/api_proto.cjs +3 -21
- package/dist/realtime/api_proto.cjs.map +1 -1
- package/dist/realtime/api_proto.d.cts +1 -504
- package/dist/realtime/api_proto.d.ts +1 -504
- package/dist/realtime/api_proto.d.ts.map +1 -1
- package/dist/realtime/api_proto.js +1 -12
- package/dist/realtime/api_proto.js.map +1 -1
- package/dist/realtime/gpt_live_model.cjs +7 -851
- package/dist/realtime/gpt_live_model.cjs.map +1 -1
- package/dist/realtime/gpt_live_model.d.cts +6 -178
- package/dist/realtime/gpt_live_model.d.ts +6 -178
- package/dist/realtime/gpt_live_model.d.ts.map +1 -1
- package/dist/realtime/gpt_live_model.js +7 -850
- package/dist/realtime/gpt_live_model.js.map +1 -1
- package/dist/realtime/gpt_live_model.test.cjs +32 -1
- package/dist/realtime/gpt_live_model.test.cjs.map +1 -1
- package/dist/realtime/gpt_live_model.test.js +32 -1
- package/dist/realtime/gpt_live_model.test.js.map +1 -1
- package/dist/realtime/gpt_live_types.cjs +6 -0
- package/dist/realtime/gpt_live_types.cjs.map +1 -1
- package/dist/realtime/gpt_live_types.d.cts +1 -169
- package/dist/realtime/gpt_live_types.d.ts +1 -169
- package/dist/realtime/gpt_live_types.d.ts.map +1 -1
- package/dist/realtime/gpt_live_types.js +1 -0
- package/dist/realtime/gpt_live_types.js.map +1 -1
- package/dist/realtime/index.cjs +8 -1
- package/dist/realtime/index.cjs.map +1 -1
- package/dist/realtime/index.d.cts +5 -0
- package/dist/realtime/index.d.ts +5 -0
- package/dist/realtime/index.d.ts.map +1 -1
- package/dist/realtime/index.js +6 -1
- package/dist/realtime/index.js.map +1 -1
- package/dist/realtime/realtime_model.cjs +3 -1890
- package/dist/realtime/realtime_model.cjs.map +1 -1
- package/dist/realtime/realtime_model.d.cts +1 -236
- package/dist/realtime/realtime_model.d.ts +1 -236
- package/dist/realtime/realtime_model.d.ts.map +1 -1
- package/dist/realtime/realtime_model.js +1 -1886
- package/dist/realtime/realtime_model.js.map +1 -1
- package/dist/realtime/realtime_model.test.cjs +11 -1141
- package/dist/realtime/realtime_model.test.cjs.map +1 -1
- package/dist/realtime/realtime_model.test.js +16 -1147
- package/dist/realtime/realtime_model.test.js.map +1 -1
- package/dist/tool_utils.test.cjs +3 -1
- package/dist/tool_utils.test.cjs.map +1 -1
- package/dist/tool_utils.test.js +3 -1
- package/dist/tool_utils.test.js.map +1 -1
- package/package.json +5 -6
- package/src/models.ts +2 -0
- package/src/realtime/api_proto.ts +2 -715
- package/src/realtime/gpt_live_model.test.ts +42 -1
- package/src/realtime/gpt_live_model.ts +17 -1030
- package/src/realtime/gpt_live_types.ts +1 -136
- package/src/realtime/index.ts +7 -0
- package/src/realtime/realtime_model.test.ts +17 -1454
- package/src/realtime/realtime_model.ts +2 -2408
- package/src/tool_utils.test.ts +3 -1
|
@@ -1,237 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { AudioFrame } from '@livekit/rtc-node';
|
|
3
|
-
import * as api_proto from './api_proto.js';
|
|
4
|
-
type Modality = 'text' | 'audio';
|
|
5
|
-
interface RealtimeOptions {
|
|
6
|
-
model: api_proto.Model;
|
|
7
|
-
voice: api_proto.Voice;
|
|
8
|
-
toolChoice?: llm.ToolChoice;
|
|
9
|
-
inputAudioTranscription?: api_proto.InputAudioTranscription | null;
|
|
10
|
-
inputAudioNoiseReduction?: api_proto.NoiseReduction | null;
|
|
11
|
-
turnDetection?: api_proto.TurnDetectionType | null;
|
|
12
|
-
maxResponseOutputTokens?: number | 'inf';
|
|
13
|
-
speed?: number;
|
|
14
|
-
tracing?: api_proto.TracingConfig | null;
|
|
15
|
-
reasoning?: api_proto.Reasoning;
|
|
16
|
-
apiKey?: string;
|
|
17
|
-
baseURL: string;
|
|
18
|
-
isAzure: boolean;
|
|
19
|
-
azureDeployment?: string;
|
|
20
|
-
entraToken?: string;
|
|
21
|
-
apiVersion?: string;
|
|
22
|
-
maxSessionDuration: number;
|
|
23
|
-
connOptions: APIConnectOptions;
|
|
24
|
-
modalities: Modality[];
|
|
25
|
-
}
|
|
26
|
-
/** @internal */
|
|
27
|
-
export interface MessageGeneration {
|
|
28
|
-
messageId: string;
|
|
29
|
-
textChannel: stream.StreamChannel<string | TimedString>;
|
|
30
|
-
audioChannel: stream.StreamChannel<AudioFrame>;
|
|
31
|
-
audioTranscript: string;
|
|
32
|
-
modalities: Future<('text' | 'audio')[]>;
|
|
33
|
-
}
|
|
34
|
-
/** @internal */
|
|
35
|
-
export interface ResponseGeneration {
|
|
36
|
-
messageChannel: stream.StreamChannel<llm.MessageGeneration>;
|
|
37
|
-
functionChannel: stream.StreamChannel<llm.FunctionCall>;
|
|
38
|
-
messages: Map<string, MessageGeneration>;
|
|
39
|
-
/** @internal */
|
|
40
|
-
_doneFut: Future;
|
|
41
|
-
/** @internal */
|
|
42
|
-
_createdTimestamp: number;
|
|
43
|
-
/** @internal */
|
|
44
|
-
_firstTokenTimestamp?: number;
|
|
45
|
-
}
|
|
46
|
-
/** @internal */
|
|
47
|
-
export declare class DiscardedGeneration {
|
|
48
|
-
readonly discarded = true;
|
|
49
|
-
}
|
|
50
|
-
/** @internal Exported for testing purposes */
|
|
51
|
-
export declare function isFatalError(error: unknown): boolean;
|
|
52
|
-
export declare class RealtimeModel extends llm.RealtimeModel {
|
|
53
|
-
sampleRate: number;
|
|
54
|
-
numChannels: number;
|
|
55
|
-
inFrameSize: number;
|
|
56
|
-
outFrameSize: number;
|
|
57
|
-
_options: RealtimeOptions;
|
|
58
|
-
get model(): string;
|
|
59
|
-
get provider(): string;
|
|
60
|
-
label(): string;
|
|
61
|
-
constructor(options?: {
|
|
62
|
-
model?: string;
|
|
63
|
-
reasoning?: api_proto.Reasoning;
|
|
64
|
-
voice?: string;
|
|
65
|
-
/** @deprecated Unused in GA API (v1). Temperature is no longer supported. */
|
|
66
|
-
temperature?: number;
|
|
67
|
-
toolChoice?: llm.ToolChoice;
|
|
68
|
-
baseURL?: string;
|
|
69
|
-
modalities?: Modality[];
|
|
70
|
-
inputAudioTranscription?: api_proto.InputAudioTranscription | null;
|
|
71
|
-
inputAudioNoiseReduction?: api_proto.NoiseReduction | null;
|
|
72
|
-
turnDetection?: api_proto.TurnDetectionType | null;
|
|
73
|
-
speed?: number;
|
|
74
|
-
tracing?: api_proto.TracingConfig | null;
|
|
75
|
-
azureDeployment?: string;
|
|
76
|
-
apiKey?: string;
|
|
77
|
-
entraToken?: string;
|
|
78
|
-
apiVersion?: string;
|
|
79
|
-
maxSessionDuration?: number;
|
|
80
|
-
connOptions?: APIConnectOptions;
|
|
81
|
-
});
|
|
82
|
-
/**
|
|
83
|
-
* Create a RealtimeModel instance configured for Azure OpenAI Service.
|
|
84
|
-
*
|
|
85
|
-
* @param azureDeployment - The name of your Azure OpenAI deployment.
|
|
86
|
-
* @param azureEndpoint - The endpoint URL for your Azure OpenAI resource. If undefined, will attempt to read from the environment variable AZURE_OPENAI_ENDPOINT.
|
|
87
|
-
* @param apiVersion - **Deprecated.** API version for legacy Azure OpenAI preview models. Will be removed on April 30, 2026. Omit for GA models.
|
|
88
|
-
* @param apiKey - Azure OpenAI API key. If undefined, will attempt to read from the environment variable AZURE_OPENAI_API_KEY.
|
|
89
|
-
* @param entraToken - Azure Entra authentication token. Required if not using API key authentication.
|
|
90
|
-
* @param baseURL - Base URL for the API endpoint. If undefined, constructed from the azure_endpoint.
|
|
91
|
-
* @param voice - Voice setting for audio outputs. Defaults to "marin".
|
|
92
|
-
* @param inputAudioTranscription - Options for transcribing input audio. Defaults to @see DEFAULT_INPUT_AUDIO_TRANSCRIPTION.
|
|
93
|
-
* @param inputAudioNoiseReduction - Options for noise reduction. Defaults to undefined.
|
|
94
|
-
* @param turnDetection - Options for server-based voice activity detection (VAD). Defaults to @see DEFAULT_SERVER_VAD_OPTIONS.
|
|
95
|
-
* @param speed - Speed of the audio output. Defaults to 1.0.
|
|
96
|
-
* @param tracing - Tracing configuration. Defaults to undefined.
|
|
97
|
-
*
|
|
98
|
-
* @returns A RealtimeModel instance configured for Azure OpenAI Service.
|
|
99
|
-
*
|
|
100
|
-
* @throws Error if required Azure parameters are missing or invalid.
|
|
101
|
-
*/
|
|
102
|
-
static withAzure({ azureDeployment, azureEndpoint, apiVersion, apiKey, entraToken, baseURL, voice, temperature, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
103
|
-
inputAudioTranscription, inputAudioNoiseReduction, turnDetection, speed, tracing, }: {
|
|
104
|
-
azureDeployment: string;
|
|
105
|
-
azureEndpoint?: string;
|
|
106
|
-
apiVersion?: string;
|
|
107
|
-
apiKey?: string;
|
|
108
|
-
entraToken?: string;
|
|
109
|
-
baseURL?: string;
|
|
110
|
-
voice?: string;
|
|
111
|
-
/** @deprecated Unused in GA API (v1). Temperature is no longer supported. */
|
|
112
|
-
temperature?: number;
|
|
113
|
-
inputAudioTranscription?: api_proto.InputAudioTranscription;
|
|
114
|
-
inputAudioNoiseReduction?: api_proto.NoiseReduction;
|
|
115
|
-
turnDetection?: api_proto.TurnDetectionType;
|
|
116
|
-
speed?: number;
|
|
117
|
-
tracing?: api_proto.TracingConfig;
|
|
118
|
-
}): RealtimeModel;
|
|
119
|
-
session(): RealtimeSession;
|
|
120
|
-
close(): Promise<void>;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Build the conversational Realtime API WebSocket URL.
|
|
124
|
-
*
|
|
125
|
-
* The scheme of `baseURL` is respected: `http://` maps to `ws://`
|
|
126
|
-
* and `https://` maps to `wss://`.
|
|
127
|
-
*
|
|
128
|
-
* @internal
|
|
129
|
-
*/
|
|
130
|
-
export declare function processBaseURL({ baseURL, model, isAzure, azureDeployment, apiVersion, }: {
|
|
131
|
-
baseURL: string;
|
|
132
|
-
model: string;
|
|
133
|
-
isAzure: boolean;
|
|
134
|
-
azureDeployment?: string;
|
|
135
|
-
apiVersion?: string;
|
|
136
|
-
}): string;
|
|
137
|
-
/**
|
|
138
|
-
* A session for the OpenAI Realtime API.
|
|
139
|
-
*
|
|
140
|
-
* This class is used to interact with the OpenAI Realtime API.
|
|
141
|
-
* It is responsible for sending events to the OpenAI Realtime API and receiving events from it.
|
|
142
|
-
*
|
|
143
|
-
* It exposes two more events:
|
|
144
|
-
* - openai_server_event_received: expose the raw server events from the OpenAI Realtime API
|
|
145
|
-
* - openai_client_event_queued: expose the raw client events sent to the OpenAI Realtime API
|
|
146
|
-
*/
|
|
147
|
-
export declare class RealtimeSession extends llm.RealtimeSession {
|
|
148
|
-
#private;
|
|
149
|
-
private _tools;
|
|
150
|
-
protected remoteChatCtx: llm.RemoteChatContext;
|
|
151
|
-
private messageChannel;
|
|
152
|
-
private inputResampler?;
|
|
153
|
-
private instructions?;
|
|
154
|
-
private oaiRealtimeModel;
|
|
155
|
-
private _options;
|
|
156
|
-
protected currentGeneration?: ResponseGeneration | DiscardedGeneration;
|
|
157
|
-
private responseCreatedFutures;
|
|
158
|
-
private discardedEventIds;
|
|
159
|
-
private textModeRecoveryRetries;
|
|
160
|
-
private itemCreateFutures;
|
|
161
|
-
private itemDeleteFutures;
|
|
162
|
-
private chatCtxEventFutures;
|
|
163
|
-
private sentChatCtxEvents;
|
|
164
|
-
private replayItemCreateEventIds;
|
|
165
|
-
private replayItemCreateEventItems;
|
|
166
|
-
private inputTranscriptAccumulators;
|
|
167
|
-
private audioCapableItemIds;
|
|
168
|
-
private updateChatCtxLock;
|
|
169
|
-
private updateFuncCtxLock;
|
|
170
|
-
private bstream;
|
|
171
|
-
private pushedDurationMs;
|
|
172
|
-
constructor(realtimeModel: RealtimeModel);
|
|
173
|
-
private hasInflightResponse;
|
|
174
|
-
sendEvent(command: api_proto.ClientEvent): void;
|
|
175
|
-
private createSessionUpdateEvent;
|
|
176
|
-
get chatCtx(): llm.ChatContext;
|
|
177
|
-
get tools(): llm.ToolContext<unknown>;
|
|
178
|
-
updateChatCtx(_chatCtx: llm.ChatContext): Promise<void>;
|
|
179
|
-
protected createChatCtxUpdateEvents(chatCtx: llm.ChatContext, addMockAudio?: boolean): Promise<(api_proto.ConversationItemCreateEvent | api_proto.ConversationItemDeleteEvent)[]>;
|
|
180
|
-
updateTools(_tools: llm.ToolContext): Promise<void>;
|
|
181
|
-
private createToolsUpdateEvent;
|
|
182
|
-
updateInstructions(_instructions: string): Promise<void>;
|
|
183
|
-
updateOptions({ toolChoice }: {
|
|
184
|
-
toolChoice?: llm.ToolChoice;
|
|
185
|
-
}): void;
|
|
186
|
-
pushAudio(frame: AudioFrame): void;
|
|
187
|
-
commitAudio(): Promise<void>;
|
|
188
|
-
clearAudio(): Promise<void>;
|
|
189
|
-
generateReply(instructions?: string, options?: {
|
|
190
|
-
signal?: AbortSignal;
|
|
191
|
-
}): Promise<llm.GenerationCreatedEvent>;
|
|
192
|
-
interrupt(): Promise<void>;
|
|
193
|
-
truncate(_options: {
|
|
194
|
-
messageId: string;
|
|
195
|
-
audioEndMs: number;
|
|
196
|
-
modalities?: Modality[];
|
|
197
|
-
audioTranscript?: string;
|
|
198
|
-
}): Promise<void>;
|
|
199
|
-
private loggableEvent;
|
|
200
|
-
protected closeCurrentGeneration(reason?: string): void;
|
|
201
|
-
private rejectResponseCreatedFutures;
|
|
202
|
-
private createWsConn;
|
|
203
|
-
private runWs;
|
|
204
|
-
close(): Promise<void>;
|
|
205
|
-
protected resetInputTurnState(): void;
|
|
206
|
-
protected handleInputAudioBufferSpeechStarted(_event: api_proto.InputAudioBufferSpeechStartedEvent): void;
|
|
207
|
-
private handleInputAudioBufferSpeechStopped;
|
|
208
|
-
protected handleResponseCreated(event: api_proto.ResponseCreatedEvent): void;
|
|
209
|
-
private handleResponseOutputItemAdded;
|
|
210
|
-
protected handleConversationItemCreated(event: api_proto.ConversationItemCreatedEvent): void;
|
|
211
|
-
private handleConversationItemDeleted;
|
|
212
|
-
private handleConversationItemInputAudioTranscriptionDelta;
|
|
213
|
-
private clearAccumulator;
|
|
214
|
-
protected handleConversationItemInputAudioTranscriptionCompleted(event: api_proto.ConversationItemInputAudioTranscriptionCompletedEvent): void;
|
|
215
|
-
private handleConversationItemInputAudioTranscriptionFailed;
|
|
216
|
-
private finalizePartialOnTranscriptionFailure;
|
|
217
|
-
private handleResponseContentPartAdded;
|
|
218
|
-
private handleResponseContentPartDone;
|
|
219
|
-
protected handleResponseTextDelta(event: api_proto.ResponseTextDeltaEvent): void;
|
|
220
|
-
private handleResponseTextDone;
|
|
221
|
-
private handleResponseAudioTranscriptDelta;
|
|
222
|
-
protected handleResponseAudioDelta(event: api_proto.ResponseAudioDeltaEvent): void;
|
|
223
|
-
private handleResponseAudioTranscriptDone;
|
|
224
|
-
private handleResponseAudioDone;
|
|
225
|
-
private handleResponseOutputItemDone;
|
|
226
|
-
private handleResponseDone;
|
|
227
|
-
private handleResponseDoneButNotComplete;
|
|
228
|
-
private handleError;
|
|
229
|
-
private consumeReplayItemCreate;
|
|
230
|
-
private emitError;
|
|
231
|
-
private resampleAudio;
|
|
232
|
-
private createResponse;
|
|
233
|
-
}
|
|
234
|
-
/** @internal Exported for testing purposes */
|
|
235
|
-
export declare function livekitItemToOpenAIItem(item: llm.ChatItem): Promise<api_proto.ItemResource>;
|
|
236
|
-
export {};
|
|
1
|
+
export * from '@livekit/agents/llm/openai_realtime/realtime_model';
|
|
237
2
|
//# sourceMappingURL=realtime_model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"realtime_model.d.ts","sourceRoot":"","sources":["../../src/realtime/realtime_model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"realtime_model.d.ts","sourceRoot":"","sources":["../../src/realtime/realtime_model.ts"],"names":[],"mappings":"AAIA,cAAc,oDAAoD,CAAC"}
|