import { Message, Text, ImageFile, TextDelta, Messages } from 'openai/resources/beta/threads/messages'; import * as Core from 'openai/core'; import { RequestOptions } from 'openai/core'; import { Run, RunCreateParamsBase, Runs, RunSubmitToolOutputsParamsBase } from 'openai/resources/beta/threads/runs/runs'; import { type ReadableStream } from 'openai/_shims/index'; import { AssistantStreamEvent } from 'openai/resources/beta/assistants'; import { RunStep, RunStepDelta, ToolCall, ToolCallDelta } from 'openai/resources/beta/threads/runs/steps'; import { ThreadCreateAndRunParamsBase, Threads } from 'openai/resources/beta/threads/threads'; import { BaseEvents, EventStream } from "./EventStream.js"; import MessageDelta = Messages.MessageDelta; export interface AssistantStreamEvents extends BaseEvents { run: (run: Run) => void; messageCreated: (message: Message) => void; messageDelta: (message: MessageDelta, snapshot: Message) => void; messageDone: (message: Message) => void; runStepCreated: (runStep: RunStep) => void; runStepDelta: (delta: RunStepDelta, snapshot: Runs.RunStep) => void; runStepDone: (runStep: Runs.RunStep, snapshot: Runs.RunStep) => void; toolCallCreated: (toolCall: ToolCall) => void; toolCallDelta: (delta: ToolCallDelta, snapshot: ToolCall) => void; toolCallDone: (toolCall: ToolCall) => void; textCreated: (content: Text) => void; textDelta: (delta: TextDelta, snapshot: Text) => void; textDone: (content: Text, snapshot: Message) => void; imageFileDone: (content: ImageFile, snapshot: Message) => void; event: (event: AssistantStreamEvent) => void; } export type ThreadCreateAndRunParamsBaseStream = Omit & { stream?: true; }; export type RunCreateParamsBaseStream = Omit & { stream?: true; }; export type RunSubmitToolOutputsParamsStream = Omit & { stream?: true; }; export declare class AssistantStream extends EventStream implements AsyncIterable { #private; [Symbol.asyncIterator](): AsyncIterator; static fromReadableStream(stream: ReadableStream): AssistantStream; protected _fromReadableStream(readableStream: ReadableStream, options?: Core.RequestOptions): Promise; toReadableStream(): ReadableStream; static createToolAssistantStream(threadId: string, runId: string, runs: Runs, params: RunSubmitToolOutputsParamsStream, options: RequestOptions | undefined): AssistantStream; protected _createToolAssistantStream(run: Runs, threadId: string, runId: string, params: RunSubmitToolOutputsParamsStream, options?: Core.RequestOptions): Promise; static createThreadAssistantStream(params: ThreadCreateAndRunParamsBaseStream, thread: Threads, options?: RequestOptions): AssistantStream; static createAssistantStream(threadId: string, runs: Runs, params: RunCreateParamsBaseStream, options?: RequestOptions): AssistantStream; currentEvent(): AssistantStreamEvent | undefined; currentRun(): Run | undefined; currentMessageSnapshot(): Message | undefined; currentRunStepSnapshot(): Runs.RunStep | undefined; finalRunSteps(): Promise; finalMessages(): Promise; finalRun(): Promise; protected _createThreadAssistantStream(thread: Threads, params: ThreadCreateAndRunParamsBase, options?: Core.RequestOptions): Promise; protected _createAssistantStream(run: Runs, threadId: string, params: RunCreateParamsBase, options?: Core.RequestOptions): Promise; static accumulateDelta(acc: Record, delta: Record): Record; protected _addRun(run: Run): Run; protected _threadAssistantStream(params: ThreadCreateAndRunParamsBase, thread: Threads, options?: Core.RequestOptions): Promise; protected _runAssistantStream(threadId: string, runs: Runs, params: RunCreateParamsBase, options?: Core.RequestOptions): Promise; protected _runToolAssistantStream(threadId: string, runId: string, runs: Runs, params: RunSubmitToolOutputsParamsStream, options?: Core.RequestOptions): Promise; } //# sourceMappingURL=AssistantStream.d.ts.map