TsgcAIOpenAIChatBotEvents › OnChatCompletion

OnChatCompletion Event

Fires when the OpenAI ChatCompletion API returns an assistant reply; exposes Role and Content.

Syntax

__property TsgcOpenAIChatCompletion OnChatCompletion;
// typedef void __fastcall (__closure *TsgcOpenAIChatCompletion)(TObject * Sender, const UnicodeString Role, const UnicodeString Content);

Default Value

Remarks

Raised once per choice returned by the ChatCompletion API. Role is typically assistant, and Content is the reply text. The event fires before the text is handed to TextToSpeech, so you can log, persist to chat history, or update the UI from this handler. Keep the handler short — it runs in the context of the HTTP callback.

Example

Back to Events