3.4 GENERATE Function

This function generates a response for a given prompt.

Syntax

APEX_AI.GENERATE (
    p_prompt            IN              VARCHAR2,
    p_service_static_id IN              VARCHAR2            DEFAULT NULL,
    p_temperature       IN              NUMBER              DEFAULT NULL )
    RETURN CLOB;

Parameters

Parameter Description
p_prompt The user prompt.
p_service_static_id The Generative AI Service static ID. If not provided, uses the app's default AI Service.
p_temperature The temperature to use. How the temperature is interpreted depends on the Generative AI Service implementation. Higher temperatures result in more "creative" responses. See the documentation of the Generative AI provider for details and allowed values.

Returns

The response for the given prompt and type.

Example

The following example generates a response with the configured Generative AI Service MY_AI_SERVICE for the given prompt.

DECLARE
  l_response clob;
BEGIN
  l_response := apex_ai.generate(
    p_prompt            => 'What is Oracle APEX',
    p_service_static_id => 'MY_AI_SERVICE');
END;