TsgcAIChat › Methods › ChatWithSystem
One-shot chat with a custom system prompt that is not persisted.
function ChatWithSystem(const aSystem, aMessage: string): string;
| Name | Type | Description |
|---|---|---|
aSystem | const string | System prompt used only for this call; the previous SystemMessage is restored afterwards. |
aMessage | const string | User message delivered to the selected provider. |
Assistant reply for this request. Empty on failure. (string)
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.
WriteLn(oChat.ChatWithSystem('Reply in French.', 'Good morning!'));