Interface for streaming chat completion callbacks

interface StreamingChatCallbacks {
    OnComplete?: ((finalResponse) => void);
    OnContent?: ((chunk, isComplete) => void);
    OnError?: ((error) => void);
}

Properties

OnComplete?: ((finalResponse) => void)

Called when the stream is complete

Type declaration

    • (finalResponse): void
    • Parameters

      Returns void

OnContent?: ((chunk, isComplete) => void)

Called when a new chunk of content is received

Type declaration

    • (chunk, isComplete): void
    • Parameters

      • chunk: string

        The new content chunk

      • isComplete: boolean

        Whether this is the final chunk

      Returns void

OnError?: ((error) => void)

Called when an error occurs during streaming

Type declaration

    • (error): void
    • Parameters

      • error: any

        The error that occurred

      Returns void