in src/ZGOOG_DEMO_RAP_AGENT/src/zcl_goog_rap_generative_model.clas.abap [0:0]
METHOD invoke_sap_function.
DATA:
lv_function_response TYPE string,
lv_function_module_name TYPE rs38l_fnam,
lv_prompt_text TYPE string,
lv_error_text TYPE string,
lo_cx_root TYPE REF TO cx_root.
lv_function_module_name = iv_function_name.
lv_prompt_text = iv_prompt_text.
TRY.
rap_call(
EXPORTING
iv_function_name = iv_function_name
it_function_parameters = it_function_parameters
IMPORTING
ev_function_response = lv_function_response
CHANGING
cv_prompt = lv_prompt_text ).
IF lv_function_response IS NOT INITIAL.
es_content_response = set_function_call( iv_function_name = iv_function_name
it_function_parameters = it_function_parameters
)->set_function_response( iv_function_name = iv_function_name
iv_function_response = lv_function_response
)->generate_content( iv_prompt_text = lv_prompt_text
)->get_response( ).
ELSE.
lv_error_text = TEXT-003.
CALL METHOD /goog/cl_vertex_ai_sdk_utility=>raise_error
EXPORTING
iv_ret_code = /goog/cl_http_client=>c_ret_code_461
iv_err_text = lv_error_text.
ENDIF.
CATCH cx_root INTO lo_cx_root.
lv_error_text = lo_cx_root->get_text( ).
CALL METHOD /goog/cl_vertex_ai_sdk_utility=>raise_error
EXPORTING
iv_ret_code = /goog/cl_http_client=>c_ret_code_461
iv_err_text = lv_error_text.
ENDTRY.