3.17 SET_TOOL_RESULT Procedure Signature 2
Use this procedure within Response Handler procedures to set a tool call result.
Syntax
PROCEDURE apex_ai.set_tool_result (
p_response_handler_param IN t_chat_response_handler_param,
p_response_handler_result IN OUT NOCOPY t_chat_response_handler_result,
p_tool_call IN t_chat_message_tool_call,
p_result IN CLOB );Parameters
| Parameter | Description |
|---|---|
p_response_handler_param |
The response handler parameter. |
p_response_handler_result |
The response handler result. |
p_tool_call |
The specific tool call for which to provide a result. |
p_result |
The tool result. |
Example
set serveroutput on;
create or replace procedure response_handler_proc (
p_param in apex_ai.t_chat_response_handler_param,
p_result in out nocopy apex_ai.t_chat_response_handler_result )
as
begin
if p_result.response.type = apex_ai.c_response_type_tool_calls then
for i in 1 .. p_param.pending_tool_calls.count loop
if p_param.pending_tool_calls( i ).name = 'get_secret_number' then
apex_ai.set_tool_result (
p_response_handler_param => p_param,
p_response_handler_result => p_result,
p_tool_call => p_param.pending_tool_calls( i ),
p_result => '42' );
end if;
end loop;
end if;
end response_handler_proc;
/
show errors;
declare
l_response clob;
begin
apex_session.create_session (
p_app_id => 100,
p_page_id => 1,
p_username => 'USER' );
l_response :=
apex_ai.generate (
p_service_static_id => 'my_ai_service',
p_prompt => 'What''s the secret number?',
p_tools =>
apex_ai.t_tools (
apex_ai.t_tool (
name => 'get_secret_number' ) ),
p_response_handler_procedure => 'response_handler_proc' );
sys.dbms_output.put_line( l_response );
apex_session.delete_session;
exception
when others then
apex_session.delete_session;
raise;
end;
/
Parent topic: APEX_AI