TsgcAIChat › Events › OnChatMessage

OnChatMessage Event

Fired when a complete assistant response has been received.

Syntax

property OnChatMessage: TsgcAIChatMessageEvent;
// TsgcAIChatMessageEvent = procedure(Sender: TObject; const aRole, aContent: string) of object

Default Value

—

Remarks

Raised by Chat, ChatStream and ChatWithSystem once the assistant reply has been parsed and stored in history. aRole is always assistant and aContent carries the full response text (for ChatStream it is the concatenation of every streamed chunk). Use it to render or persist the final turn without handling the lower-level streaming event.

Example

procedure TForm1.oChatChatMessage(Sender: TObject; const aRole, aContent: string);
begin
  Memo1.Lines.Add(aRole + ': ' + aContent);
end;

Back to Events