TsgcAIOpenAIChatBotMethods › ChatAsUser

ChatAsUser Method

Sends a text prompt as the user role and triggers a ChatCompletion reply (spoken via TextToSpeech).

Syntax

void __fastcall ChatAsUser(const UnicodeString aPrompt, TsgcOpenAIArray_Request_Completion_Messages * aHistory = nil);

Parameters

NameTypeDescription
aPromptconst stringThe user message sent to the ChatCompletion API.
aHistoryTsgcOpenAIArray_Request_Completion_MessagesOptional previous messages prepended to the request to preserve conversation context. Pass nil for a single-turn call.

Remarks

Builds a ChatCompletion request using ChatBotOptions.ChatCompletion.Model, appends aHistory (if any) followed by the new user message, and calls the OpenAI API. The assistant reply is raised via OnChatCompletion and then forwarded to TextToSpeech (speech is always on for this method).

Example

Back to Methods