TsgcAIChat › Methods › ChatWithSystem

ChatWithSystem Method

One-shot chat with a custom system prompt that is not persisted.

Syntax

function ChatWithSystem(const aSystem, aMessage: string): string;

Parameters

NameTypeDescription
aSystemconst stringSystem prompt used only for this call; the previous SystemMessage is restored afterwards.
aMessageconst stringUser message delivered to the selected provider.

Return Value

Assistant reply for this request. Empty on failure. (string)

Remarks

Temporarily overrides SystemMessage with aSystem, invokes Chat(aMessage) and restores the previous value in a try/finally, even if the request fails. Handy for changing persona or task instructions for a single turn without touching component state. Conversation history is still updated like a regular Chat call.

Example

WriteLn(oChat.ChatWithSystem('Reply in French.', 'Good morning!'));

Back to Methods