3.4 CHAT Function Signature 2
This function chats with a Generative AI service given a prompt and potential earlier responses.
Syntax
APEX_AI.CHAT (
    p_config_static_id  IN              VARCHAR2,
    p_prompt            IN              CLOB,
    p_messages          IN OUT NOCOPY   t_chat_messages )
    RETURN CLOB;Parameters
| Parameter | Description | 
|---|---|
| p_config_static_id | The static ID of the AI configuration defined under the application's Shared Components. | 
| p_prompt | The user prompt. | 
| p_messages | (Optional) The responses from an earlier conversation. Responses are automatically added to p_responsesfor an easy conversational experience. | 
Returns
The response for the given prompt and type.
Example
The following example chats with the assistant configured as my-oracle-assistant where in the first interaction a system prompt is given and then in further interactions the context is passed to the generative AI service in the form of parameter p_messages.
                  
DECLARE
  l_messages  t_chat_messages := c_chat_messages;
  l_response1 clob;
  l_response2 clob;
BEGIN
  l_response1 := apex_ai.chat(
    p_config_static_id  => 'my-oracle-assistant',
    p_prompt            => 'What is Oracle APEX',
    p_messages          => l_messages);
  l_response2 := apex_ai.chat(
    p_config_static_id  => 'my-oracle-assistant',
    p_prompt            => 'What is new in 23.2',
    p_messages          => l_messages)
END;Parent topic: APEX_AI