TsgcAIOpenAIChatBot › Events › OnError

OnError Event

Fires when the transcription or ChatCompletion request fails; exposes the error message.

Syntax

property OnError: TsgcOpenAIChatBotError;
// TsgcOpenAIChatBotError = procedure(Sender: TObject; const aError: string) of object

Default Value

—

Remarks

Raised when the request that sends the recorded audio to Whisper for transcription and then to ChatCompletion fails, for example because the OpenSSL libraries are missing, the API key is invalid, there is a quota or billing error, or the network is unavailable. aError contains the exception message, and after the event the ChatBot starts recording again. If no handler is assigned, the error is not reported anywhere and the bot simply never answers. Typical use: show or log the message so the user knows why there is no reply.

Example

procedure TForm1.sgcChatBotError(Sender: TObject; const aError: string);
begin
  Memo1.Lines.Add('Error: ' + aError);
end;

Back to Events