aiwrapper
Version:
A Universal AI Wrapper for JavaScript & TypeScript
29 lines (28 loc) • 1.01 kB
TypeScript
import { LangMessage, LangMessages } from "../messages.ts";
/**
* Handles streaming deltas from OpenAI-compatible chat completions APIs
* and keeps the LangMessages collection in sync with streamed content.
*/
export declare class OpenAIChatCompletionsStreamHandler {
private messages;
private onResult?;
private currentAssistantMessage?;
private toolCallItems;
private toolArgBuffers;
constructor(messages: LangMessages, onResult?: (result: LangMessage) => void);
setOnResult(onResult?: (result: LangMessage) => void): void;
handleEvent(data: any): void;
private ensureAssistantMessage;
private getOrCreateTextItem;
private getOrCreateReasoningItem;
private appendText;
private appendReasoning;
private appendImageFromUrl;
private appendImageFromBase64;
private handleContentDelta;
private handleReasoningDelta;
private handleToolCalls;
private handleFunctionCall;
private getOrCreateToolItem;
private finalizeToolArguments;
}