aiwrapper
Version:
A Universal AI Wrapper for JavaScript & TypeScript
37 lines (36 loc) • 1.54 kB
TypeScript
import { LangMessages, LangMessage } from "../../messages";
import type { LangMessageItem, LangMessageItemText, LangMessageItemTool, LangMessageItemImage } from "../../messages";
import { MessageItem } from "../responses-stream-types";
type OpenAIResponseItem = {
id: string;
type: string;
targetMessage?: LangMessage;
[key: string]: any;
};
/**
* Stream response handler for the OpenAI Responses API
*/
export declare class OpenAIResponseStreamHandler {
id: string;
items: OpenAIResponseItem[];
itemIdToMessageItemIndex: Map<string, number>;
itemIdToSummaryIndex: Map<string, number>;
newMessage: LangMessage;
messages: LangMessages;
onResult?: (result: LangMessage) => void;
constructor(messages: LangMessages, onResult?: (result: LangMessage) => void);
handleEvent(data: any): void;
handleNewResponse(data: any): void;
handleNewItem(data: any): void;
handleItemFinished(data: any): void;
applyItemToMessage(resItem: OpenAIResponseItem, messageItem: LangMessageItem): void;
applyTextMessage(res: MessageItem, target: LangMessageItemText): void;
applyFunctionCall(res: any, target: LangMessageItemTool): void;
applyPatchCall(res: any, target: LangMessageItemTool): void;
applyImageGenerationCall(res: any, target: LangMessageItemImage): void;
getNewMessageItem(itemId: string): LangMessageItem | undefined;
applyTextDelta(data: any): void;
applyToolArgsDelta(data: any): void;
applyReasoningSummaryTextDelta(data: any): void;
}
export {};