export interface StreamableData { type: StreamableDataType; content: string; success: boolean; wrappedMessage?: string; } export class StreamMessageWrapper { public static readonly startIndicator = "dc-start-indicator-1234567890"; public static readonly endIndicator = "dc-end-indicator-1234567890"; public static wrapMessage(message: string) : string { return this.startIndicator + message + this.endIndicator; } public static unwrapMessage(message: string) : string { return message.substring(this.startIndicator.length, message.length - this.endIndicator.length); } } export enum StreamableDataType { /** It's a string, which can be parsed to a json object of type T, T being the type of the response */ ParsableResponse, Start, Failure, /** The main answer to the request, which is meant to be streamed. Typically a regular string, but can be a parsable JSON string, depending on the endpoint */ Answer, FinishReason, MessageId }