@pipedog/openai 0.0.0 → 0.3.0

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,8 @@
1
+ // Copyright (c) 2024-2026, Daily
2
+ // Copyright (c) 2026, pipedog contributors
3
+ // SPDX-License-Identifier: BSD-2-Clause
4
+ //
5
+ // Ported from pipecat: src/pipecat/services/openai/realtime/__init__.py
6
+ // Upstream's package __init__ is empty: import the submodules directly.
7
+ export {};
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,457 @@
1
+ /**
2
+ * OpenAI Realtime LLM service implementation with WebSocket support.
3
+ *
4
+ * Porting notes:
5
+ * - The deprecated `model` and `sessionProperties` constructor options are
6
+ * not ported; use `settings: new OpenAIRealtimeLLMService.Settings({ model,
7
+ * sessionProperties })` instead.
8
+ * - The websocket is `websocketConnect()` from core (the global `WebSocket`).
9
+ * - Video frames are encoded with core's `encodeImage()` (upstream: Pillow).
10
+ * - The tracing decorators are applied in a static block (decorator syntax is
11
+ * not erasable).
12
+ */
13
+ import { Future, type Task } from "@pipedog/asyncio";
14
+ import type { BaseLLMAdapter } from "@pipedog/core/adapters/base_llm_adapter";
15
+ import type { ToolsSchema } from "@pipedog/core/adapters/schemas/tools_schema";
16
+ import { type CancelFrame, type EndFrame, type Frame, FunctionCallCancelFrame, FunctionCallResultFrame, InputAudioRawFrame, InputImageRawFrame, LLMMessagesAppendFrame, LLMServiceMetadataFrame, SpeechControlParamsFrame, UserStartedSpeakingFrame, UserStoppedSpeakingFrame } from "@pipedog/core/frames/frames";
17
+ import { type LLMContext } from "@pipedog/core/processors/aggregators/llm_context";
18
+ import { FrameDirection, type FrameProcessorSetup } from "@pipedog/core/processors/frame_processor";
19
+ import { type LLMAdapterClass, LLMService, type LLMServiceOptions } from "@pipedog/core/services/llm_service";
20
+ import { LLMSettings, type LLMSettingsOptions, type ServiceSettings } from "@pipedog/core/services/settings";
21
+ import { type WebsocketClientConnection } from "@pipedog/core/services/websocket_service";
22
+ import { Language } from "@pipedog/core/transcriptions/language";
23
+ import { type NotGiven } from "@pipedog/core/utils/types";
24
+ import { OpenAIRealtimeLLMAdapter } from "../open_ai_realtime_adapter.ts";
25
+ import * as events from "./events.ts";
26
+ export declare const AUTOSIZED_USER_AUDIO_PREROLL_MARGIN_SECS = 0.3;
27
+ export declare const DEFAULT_USER_AUDIO_PREROLL_SECS = 0.5;
28
+ type RealtimeAdapter = OpenAIRealtimeLLMAdapter & BaseLLMAdapter;
29
+ export interface CurrentAudioResponseOptions {
30
+ /** Unique identifier for the audio response item. */
31
+ itemId: string;
32
+ /** Index of the audio content within the item. */
33
+ contentIndex: number;
34
+ /** Timestamp when the audio response started in milliseconds. */
35
+ startTimeMs: number;
36
+ /** Total size of audio data received in bytes. Defaults to 0. */
37
+ totalSize?: number;
38
+ /** ID of the server response the item belongs to. Defaults to "". */
39
+ responseId?: string;
40
+ }
41
+ /**
42
+ * Tracks the current audio response from the assistant.
43
+ *
44
+ * - `itemId`: unique identifier for the audio response item.
45
+ * - `contentIndex`: index of the audio content within the item.
46
+ * - `startTimeMs`: timestamp when the audio response started in milliseconds.
47
+ * - `totalSize`: total size of audio data received in bytes. Defaults to 0.
48
+ * - `responseId`: ID of the server response the item belongs to. Defaults to "".
49
+ */
50
+ export declare class CurrentAudioResponse {
51
+ itemId: string;
52
+ contentIndex: number;
53
+ startTimeMs: number;
54
+ totalSize: number;
55
+ responseId: string;
56
+ constructor(options: CurrentAudioResponseOptions);
57
+ }
58
+ export interface OpenAIRealtimeLLMSettingsOptions extends LLMSettingsOptions {
59
+ /**
60
+ * OpenAI Realtime session properties (modalities, audio config, tools,
61
+ * etc.). `model` and `instructions` are synced bidirectionally with the
62
+ * top-level `model` and `systemInstruction` fields.
63
+ */
64
+ sessionProperties?: events.SessionProperties | NotGiven;
65
+ }
66
+ /**
67
+ * Settings for OpenAIRealtimeLLMService.
68
+ *
69
+ * - `sessionProperties`: OpenAI Realtime session properties (modalities,
70
+ * audio config, tools, etc.). `model` and `instructions` are synced
71
+ * bidirectionally with the top-level `model` and `systemInstruction` fields.
72
+ */
73
+ export declare class OpenAIRealtimeLLMSettings extends LLMSettings {
74
+ sessionProperties: events.SessionProperties | NotGiven;
75
+ constructor(options?: OpenAIRealtimeLLMSettingsOptions);
76
+ /** Push top-level `model`/`systemInstruction` into `sessionProperties`. */
77
+ static _syncTopLevelToSp(settings: OpenAIRealtimeLLMSettings): void;
78
+ /**
79
+ * Merge a delta, keeping `model`/`systemInstruction` in sync with SP.
80
+ *
81
+ * When the delta contains `sessionProperties`, it **replaces** the stored
82
+ * SP wholesale (matching legacy behaviour). Top-level field values always
83
+ * take precedence over conflicting SP values.
84
+ */
85
+ applyUpdate(delta: this): Record<string, unknown>;
86
+ /**
87
+ * Build a delta from a plain dict, routing SP keys into `sessionProperties`.
88
+ *
89
+ * Keys that correspond to `SessionProperties` fields (except `model`) are
90
+ * collected into a nested `sessionProperties` value. `model` is always
91
+ * routed to the top-level field. Unknown keys go to `extra`. Keys may use
92
+ * upstream's snake_case spelling or the camelCase field names.
93
+ */
94
+ static fromMapping<T extends ServiceSettings>(this: new (options?: object) => T, settings: Record<string, unknown>): T;
95
+ }
96
+ export interface OpenAIRealtimeLLMServiceOptions extends LLMServiceOptions {
97
+ /** OpenAI API key for authentication. */
98
+ apiKey: string;
99
+ /**
100
+ * WebSocket base URL for the realtime API. Defaults to
101
+ * "wss://api.openai.com/v1/realtime".
102
+ */
103
+ baseUrl?: string;
104
+ /** Runtime-updatable settings for this service. */
105
+ settings?: OpenAIRealtimeLLMSettings | null;
106
+ /** Whether to start with audio input paused. Defaults to false. */
107
+ startAudioPaused?: boolean;
108
+ /** Whether to start with video input paused. Defaults to false. */
109
+ startVideoPaused?: boolean;
110
+ /**
111
+ * Detail level for video processing. Can be "auto", "low", or "high". This
112
+ * sets the image_detail parameter in the OpenAI Realtime API. "auto" lets
113
+ * the model decide, "low" is faster and uses fewer tokens, "high" provides
114
+ * more detail. Defaults to "auto".
115
+ */
116
+ videoFrameDetail?: events.ImageDetail;
117
+ /**
118
+ * In manual turn-detection mode (`turn_detection=False`, locally-driven
119
+ * turns), how much recent audio to replay after an interruption clears the
120
+ * input audio buffer, so the speech onset isn't lost. Defaults to null:
121
+ * auto-sized to the upstream VAD's `startSecs` plus a small margin, falling
122
+ * back to `DEFAULT_USER_AUDIO_PREROLL_SECS` when no VAD is present.
123
+ * Auto-sizing assumes VAD drives turn starts (the default
124
+ * `VADUserTurnStartStrategy`); set this explicitly if you use a non-VAD
125
+ * turn-start strategy. No effect when server-side turn detection is enabled.
126
+ */
127
+ userAudioPrerollSecs?: number | null;
128
+ }
129
+ /**
130
+ * OpenAI Realtime LLM service providing real-time audio and text communication.
131
+ *
132
+ * Implements the OpenAI Realtime API with WebSocket communication for
133
+ * low-latency bidirectional audio and text interactions. Supports function
134
+ * calling, conversation management, and real-time transcription.
135
+ *
136
+ * Proposes turn boundaries from OpenAI's server-side VAD events, which the
137
+ * recommended external user turn strategies resolve into
138
+ * `UserStartedSpeakingFrame` / `UserStoppedSpeakingFrame`, so pipeline
139
+ * processors that depend on those frames (RTVI client speech events,
140
+ * `TurnTrackingObserver`, `AudioBufferProcessor` turn recording,
141
+ * `UserIdleController`, user mute strategies, voicemail detector) work out of
142
+ * the box. `LLMContextAggregatorPair` auto-detects this realtime service and
143
+ * decouples context writes from those frames; see the
144
+ * `examples/realtime/realtime-openai.py` example.
145
+ *
146
+ * If you wire local VAD (`LLMUserAggregatorParams.vadAnalyzer`) on top of this
147
+ * service, disable OpenAI's server-side turn detection first
148
+ * (`turn_detection=False`); otherwise both sources broadcast duplicate
149
+ * user-turn frames. See
150
+ * `examples/realtime/realtime-openai-locally-driven-turns.py`.
151
+ */
152
+ export declare class OpenAIRealtimeLLMService extends LLMService<RealtimeAdapter> {
153
+ static Settings: typeof OpenAIRealtimeLLMSettings;
154
+ protected _settings: OpenAIRealtimeLLMSettings;
155
+ static adapterClass: LLMAdapterClass | null;
156
+ static _REASONING_CAPABLE_MODEL_SUBSTRINGS: readonly string[];
157
+ apiKey: string;
158
+ baseUrl: string;
159
+ protected _audioInputPaused: boolean;
160
+ protected _videoInputPaused: boolean;
161
+ protected _videoFrameDetail: events.ImageDetail;
162
+ protected _lastSentTime: number;
163
+ protected _websocket: WebsocketClientConnection | null;
164
+ protected _receiveTask: Task<unknown> | null;
165
+ protected _context: LLMContext | null;
166
+ protected _llmNeedsConversationSetup: boolean;
167
+ protected _disconnecting: boolean;
168
+ protected _apiSessionReady: boolean;
169
+ protected _runLlmWhenApiSessionReady: boolean;
170
+ protected _currentAssistantResponse: events.ConversationItem | null;
171
+ protected _currentAudioResponse: CurrentAudioResponse | null;
172
+ protected _resampler: import("@pipedog/core/audio/resamplers/base_audio_resampler").BaseAudioResampler;
173
+ protected _userAudioPrerollBuffer: Uint8Array;
174
+ protected _userAudioPrerollSecsOverride: number | null;
175
+ protected _userAudioPrerollSecs: number;
176
+ protected _messagesAddedManually: Map<string, boolean>;
177
+ protected _pendingFunctionCalls: Map<string, events.ConversationItem>;
178
+ protected _completedToolCalls: Set<string>;
179
+ protected _openFunctionCalls: Set<string>;
180
+ protected _resultsAwaitingResponse: boolean;
181
+ protected _responseCreateOwed: boolean;
182
+ protected _responseActive: boolean;
183
+ protected _reasoningStripWarned: boolean;
184
+ protected _retrieveConversationItemFutures: Map<string, Future<events.ConversationItem>[]>;
185
+ /**
186
+ * Initialize the OpenAI Realtime LLM service.
187
+ *
188
+ * @param options.apiKey OpenAI API key for authentication.
189
+ * @param options.baseUrl WebSocket base URL for the realtime API.
190
+ * @param options.settings Runtime-updatable settings for this service.
191
+ * @param options.startAudioPaused Whether to start with audio input paused.
192
+ * @param options.startVideoPaused Whether to start with video input paused.
193
+ * @param options.videoFrameDetail Detail level for video processing.
194
+ * @param options.userAudioPrerollSecs Pre-roll replayed after an
195
+ * interruption clears the input audio buffer, in manual turn-detection
196
+ * mode. See `OpenAIRealtimeLLMServiceOptions.userAudioPrerollSecs`.
197
+ * Other options are passed to the parent LLMService.
198
+ */
199
+ constructor(options: OpenAIRealtimeLLMServiceOptions);
200
+ /** Drop input transcription prompt settings unsupported by the selected model. */
201
+ static _omitUnsupportedInputAudioTranscriptionPrompt(sessionProperties: events.SessionProperties): boolean;
202
+ /**
203
+ * Check if the service can generate usage metrics.
204
+ *
205
+ * @returns True if metrics generation is supported.
206
+ */
207
+ canGenerateMetrics(): boolean;
208
+ /**
209
+ * Set whether audio input is paused.
210
+ *
211
+ * @param paused True to pause audio input, false to resume.
212
+ */
213
+ setAudioInputPaused(paused: boolean): void;
214
+ /**
215
+ * Set whether video input is paused.
216
+ *
217
+ * @param paused True to pause video input, false to resume.
218
+ */
219
+ setVideoInputPaused(paused: boolean): void;
220
+ /**
221
+ * Set the detail level for video processing.
222
+ *
223
+ * @param detail Detail level - "auto", "low", or "high".
224
+ */
225
+ setVideoFrameDetail(detail: string): void;
226
+ /** Check if a specific modality is enabled, "text" or "audio". */
227
+ protected _isModalityEnabled(modality: string): boolean;
228
+ /** Get the list of enabled modalities. */
229
+ protected _getEnabledModalities(): events.Modality[];
230
+ /**
231
+ * Retrieve a conversation item by ID from the server.
232
+ *
233
+ * @param itemId The ID of the conversation item to retrieve.
234
+ * @returns The retrieved conversation item.
235
+ */
236
+ retrieveConversationItem(itemId: string): Promise<events.ConversationItem>;
237
+ /**
238
+ * Set up the service and connect.
239
+ *
240
+ * @param setup Configuration object containing setup parameters.
241
+ */
242
+ setup(setup: FrameProcessorSetup): Promise<void>;
243
+ /** Release realtime LLM resources at teardown. */
244
+ cleanup(): Promise<void>;
245
+ /**
246
+ * Stop the service and close WebSocket connection.
247
+ *
248
+ * @param frame The end frame triggering service shutdown.
249
+ */
250
+ stop(frame: EndFrame): Promise<void>;
251
+ /**
252
+ * Cancel the service and close WebSocket connection.
253
+ *
254
+ * @param frame The cancel frame triggering service cancellation.
255
+ */
256
+ cancel(frame: CancelFrame): Promise<void>;
257
+ /**
258
+ * Whether server-side turn detection is explicitly disabled.
259
+ *
260
+ * `null` and `false` are different. `null` means we're using OpenAI's
261
+ * built-in turn detection defaults (so server VAD is active); `false` is
262
+ * the opt-out that puts the service in manual mode.
263
+ */
264
+ protected _isTurnDetectionDisabled(): boolean;
265
+ /**
266
+ * Intermediate results reach the model as conversation items.
267
+ *
268
+ * The API takes one output per function call, so an intermediate result
269
+ * goes in beside the call instead of through it (see `pushFrame`).
270
+ */
271
+ get acceptsIntermediateFunctionCallResults(): boolean;
272
+ /** Realtime service; recommends external turn strategies when server-side VAD is active. */
273
+ serviceMetadataFrame(): LLMServiceMetadataFrame;
274
+ protected _handleInterruption(): Promise<void>;
275
+ protected _handleUserStartedSpeaking(_frame: UserStartedSpeakingFrame): Promise<void>;
276
+ protected _handleUserStoppedSpeaking(_frame: UserStoppedSpeakingFrame): Promise<void>;
277
+ protected _handleBotStoppedSpeaking(): Promise<void>;
278
+ /** Calculate audio duration in milliseconds based on PCM audio parameters. */
279
+ protected _calculateAudioDurationMs(totalBytes: number, sampleRate?: number, bytesPerSample?: number): number;
280
+ /**
281
+ * Truncates the current audio response at the appropriate duration.
282
+ *
283
+ * Calculates the actual duration of the audio content and truncates at the
284
+ * shorter of either the wall clock time or the actual audio duration to
285
+ * prevent invalid truncation requests.
286
+ */
287
+ protected _truncateCurrentAudioResponse(): Promise<void>;
288
+ /** Return the tools configured on `sessionProperties`, if any. */
289
+ protected _serviceTools(): ToolsSchema | unknown[] | null;
290
+ /**
291
+ * Process incoming frames from the pipeline.
292
+ *
293
+ * @param frame The frame to process.
294
+ * @param direction The direction of frame flow in the pipeline.
295
+ */
296
+ processFrame(frame: Frame, direction: FrameDirection): Promise<void>;
297
+ /**
298
+ * Push a frame, delivering function call outcomes to the API on the way.
299
+ *
300
+ * Function call results and cancellations are broadcast by the base
301
+ * service; the downstream copy is observed here and sent to the API as it
302
+ * is produced, intermediate results included. The frames travel on to the
303
+ * assistant aggregator, which records them in the context and decides when
304
+ * inference should run.
305
+ *
306
+ * @param frame The frame to push.
307
+ * @param direction The direction of frame pushing.
308
+ */
309
+ pushFrame(frame: Frame, direction?: FrameDirection): Promise<void>;
310
+ protected _handleContext(context: LLMContext, direction: FrameDirection): Promise<void>;
311
+ /**
312
+ * Put appended messages into the conversation as items, for the model to
313
+ * take in.
314
+ *
315
+ * Whether the model answers them is the aggregator's call: an append that
316
+ * asks to run comes back to this service as the context frame the assistant
317
+ * aggregator pushes upstream, which creates the response (see
318
+ * `_handleContext`). Before the session's conversation is set up, nothing
319
+ * is sent: the setup sends the context, which the aggregator records the
320
+ * messages in.
321
+ */
322
+ protected _handleMessagesAppend(frame: LLMMessagesAppendFrame): Promise<void>;
323
+ /**
324
+ * Send a client event to the OpenAI Realtime API.
325
+ *
326
+ * @param event The client event to send.
327
+ */
328
+ sendClientEvent(event: events.ClientEvent): Promise<void>;
329
+ protected _connect(): Promise<void>;
330
+ protected _disconnect(): Promise<void>;
331
+ protected _wsSend(realtimeMessage: Record<string, unknown>): Promise<void>;
332
+ /** Apply a settings delta, sending a session update when needed. */
333
+ protected _updateSettings(delta: LLMSettings): Promise<Record<string, unknown>>;
334
+ /**
335
+ * Drop `reasoning` from an outgoing session.update if the model can't use it.
336
+ *
337
+ * The server otherwise rejects the whole update and kills the session.
338
+ * Returns a copy when stripping; the user's stored config is preserved.
339
+ */
340
+ protected _stripUnsupportedReasoning(settings: events.SessionProperties): events.SessionProperties;
341
+ protected _sendSessionUpdate(): Promise<void>;
342
+ protected _receiveTaskHandler(): Promise<void>;
343
+ protected _handleEvtSessionCreated(_evt: events.SessionCreatedEvent): Promise<void>;
344
+ protected _handleEvtSessionUpdated(_evt: events.SessionUpdatedEvent): Promise<void>;
345
+ protected _handleEvtAudioDelta(evt: events.ResponseAudioDelta): Promise<void>;
346
+ /** Handle conversation.item.added event - item is added but may still be processing. */
347
+ protected _handleEvtConversationItemAdded(evt: events.ConversationItemAdded): Promise<void>;
348
+ /** Handle conversation.item.done event - item is fully completed. */
349
+ protected _handleEvtConversationItemDone(evt: events.ConversationItemDone): Promise<void>;
350
+ protected _handleEvtInputAudioTranscriptionDelta(evt: events.ConversationItemInputAudioTranscriptionDelta): Promise<void>;
351
+ /** Handle a transcription result with tracing. */
352
+ protected _handleUserTranscription(_transcript: string, _isFinal: boolean, _language?: Language | null): Promise<void>;
353
+ /**
354
+ * Handle completion of input audio transcription.
355
+ *
356
+ * @param evt The transcription completed event.
357
+ */
358
+ handleEvtInputAudioTranscriptionCompleted(evt: events.ConversationItemInputAudioTranscriptionCompleted): Promise<void>;
359
+ protected _handleConversationItemRetrieved(evt: events.ConversationItemRetrieved): Promise<void>;
360
+ /** Note the response, which takes in everything delivered before it. */
361
+ protected _handleEvtResponseCreated(_evt: events.ResponseCreated): Promise<void>;
362
+ protected _handleEvtResponseDone(evt: events.ResponseDone): Promise<void>;
363
+ protected _handleEvtTextDelta(evt: events.ResponseTextDelta): Promise<void>;
364
+ protected _handleEvtAudioTranscriptDelta(evt: events.ResponseAudioTranscriptDelta): Promise<void>;
365
+ protected _pushOutputTranscriptTextFrames(text: string): Promise<void>;
366
+ /**
367
+ * Handle completion of function call arguments.
368
+ *
369
+ * @param evt The response.function_call_arguments.done event.
370
+ */
371
+ protected _handleEvtFunctionCallArgumentsDone(evt: events.ResponseFunctionCallArgumentsDone): Promise<void>;
372
+ protected _handleEvtSpeechStarted(_evt: events.InputAudioBufferSpeechStarted): Promise<void>;
373
+ protected _handleEvtSpeechStopped(_evt: events.InputAudioBufferSpeechStopped): Promise<void>;
374
+ /**
375
+ * Maybe handle an error event related to retrieving a conversation item.
376
+ *
377
+ * If the given error event is an error retrieving a conversation item:
378
+ *
379
+ * - set an exception on the future that `retrieveConversationItem()` is
380
+ * waiting on
381
+ * - return true
382
+ *
383
+ * Otherwise:
384
+ *
385
+ * - return false
386
+ */
387
+ protected _maybeHandleEvtRetrieveConversationItemError(evt: events.ErrorEvent): Promise<boolean>;
388
+ protected _handleEvtError(evt: events.ErrorEvent): Promise<void>;
389
+ /**
390
+ * Reset the conversation by disconnecting and reconnecting.
391
+ *
392
+ * This is the safest way to start a new conversation. Note that this will
393
+ * fail if called from the receive task.
394
+ */
395
+ resetConversation(): Promise<void>;
396
+ protected _createResponse(): Promise<void>;
397
+ /**
398
+ * Send any tool result the context holds that hasn't reached the API yet.
399
+ *
400
+ * Results this service produced are already sent, as they are produced (see
401
+ * `pushFrame`), so what this finds is a result written into the context
402
+ * some other way, plus, with `sendNewResults` false, the results a context
403
+ * brings with it at the start of a session.
404
+ */
405
+ protected _processCompletedFunctionCalls(sendNewResults: boolean): Promise<void>;
406
+ /**
407
+ * Auto-size the pre-roll from the upstream VAD's startSecs.
408
+ *
409
+ * `VADController` broadcasts the current `VADParams` at pipeline start (and
410
+ * on any runtime change), so the pre-roll tracks `startSecs` — the leading
411
+ * speech local turn detection consumes before confirming the turn — plus a
412
+ * margin.
413
+ *
414
+ * This assumes VAD drives turn starts (the default
415
+ * `VADUserTurnStartStrategy`). With a non-VAD turn-start strategy the
416
+ * onset-to-turn-start gap isn't governed by `startSecs`; in that case the
417
+ * developer should pin a pre-roll duration via `userAudioPrerollSecs`
418
+ * (which short-circuits this).
419
+ *
420
+ * This mechanism is harmless when server-side turn detection is enabled
421
+ * (the buffer is simply unused).
422
+ */
423
+ protected _handleSpeechControlParams(frame: SpeechControlParamsFrame): void;
424
+ protected _sendUserAudio(frame: InputAudioRawFrame): Promise<void>;
425
+ /**
426
+ * Re-append the buffered pre-roll audio to the input buffer.
427
+ *
428
+ * Called right after `InputAudioBufferClearEvent` so the speech onset
429
+ * (appended before local turn detection fired the interruption) survives
430
+ * the clear. The buffer is left intact — it's a rolling window, so a later
431
+ * interruption can restore the onset again.
432
+ */
433
+ protected _replayUserAudioPreroll(): Promise<void>;
434
+ /**
435
+ * Send user video frame to OpenAI Realtime API.
436
+ *
437
+ * @param frame The InputImageRawFrame to send.
438
+ */
439
+ protected _sendUserVideo(frame: InputImageRawFrame): Promise<void>;
440
+ protected _sendToolResult(toolCallId: string, result: string | null): Promise<void>;
441
+ /** Put text into the conversation for the model to take in, without answering it. */
442
+ protected _sendMessageItem(text: string, role?: string): Promise<void>;
443
+ /**
444
+ * Send one function call result to the API as it is produced.
445
+ *
446
+ * An intermediate result can't go through the tool-result channel — the
447
+ * API takes one output per call — so it goes in as a message carrying the
448
+ * same envelope a text LLM would read from the context. A final result
449
+ * answers the call, unless a reconnect has left the API without the id to
450
+ * answer, in which case it goes in as a message too.
451
+ */
452
+ protected _handleFunctionCallResult(frame: FunctionCallResultFrame): Promise<void>;
453
+ /** Settle a cancelled call, so the API isn't left waiting on it. */
454
+ protected _handleFunctionCallCancel(frame: FunctionCallCancelFrame): Promise<void>;
455
+ }
456
+ export {};
457
+ //# sourceMappingURL=llm.d.ts.map