aiwrapper
Version:
A Universal AI Wrapper for JavaScript & TypeScript
29 lines (28 loc) • 973 B
TypeScript
import { LangMessage, LangMessages } from "../messages.ts";
/**
* Handles streaming events from the Anthropic Messages API and keeps
* LangMessages in sync with streamed content.
*/
export declare class AnthropicStreamHandler {
private messages;
private onResult?;
private currentAssistantMessage?;
private textBlocks;
private reasoningBlocks;
private toolBlocks;
private toolArgBuffers;
constructor(messages: LangMessages, onResult?: (result: LangMessage) => void);
setOnResult(onResult?: (result: LangMessage) => void): void;
handleEvent(data: any): void;
private ensureAssistantMessage;
private handleMessageStart;
private handleContentBlockStart;
private handleContentBlockDelta;
private handleMessageStop;
private getOrCreateTextItem;
private getOrCreateReasoningItem;
private createToolItem;
private applyToolDelta;
private tryParseToolArguments;
private finalizeToolArguments;
}