TsgcAIChat › Events › OnChatStream

OnChatStream Event

Fired for every partial chunk delivered while streaming.

Syntax

property OnChatStream: TsgcAIChatStreamEvent;
// TsgcAIChatStreamEvent = procedure(Sender: TObject; const aChunk: string; var Cancel: Boolean) of object

Default Value

—

Remarks

Raised by ChatStream for each server-sent event chunk that carries assistant text. aChunk contains the incremental token text already decoded from the provider's JSON envelope. Set Cancel to True to abort further chunks; the partial text received so far is still stored in history. Use this event to progressively render the response in a UI.

Example

procedure TForm1.oChatChatStream(Sender: TObject; const aChunk: string;
  var Cancel: Boolean);
begin
  Memo1.Text := Memo1.Text + aChunk;
end;

Back to Events