/AWS1/CL_BDC=>INVOKECODEINTERPRETER()
¶
About InvokeCodeInterpreter¶
Executes code within an active code interpreter session in Amazon Bedrock. This operation processes the provided code, runs it in a secure environment, and returns the execution results including output, errors, and generated visualizations.
To execute code, you must specify the code interpreter identifier, session ID, and the code to run in the arguments parameter. The operation returns a stream containing the execution results, which can include text output, error messages, and data visualizations.
This operation is subject to request rate limiting based on your account's service quotas.
The following operations are related to InvokeCodeInterpreter
:
Method Signature¶
IMPORTING¶
Required arguments:¶
iv_codeinterpreteridentifier
TYPE /AWS1/BDCSTRING
/AWS1/BDCSTRING
¶
The unique identifier of the code interpreter associated with the session. This must match the identifier used when creating the session with
StartCodeInterpreterSession
.
iv_name
TYPE /AWS1/BDCTOOLNAME
/AWS1/BDCTOOLNAME
¶
The name of the code interpreter to invoke.
Optional arguments:¶
iv_sessionid
TYPE /AWS1/BDCCODEINTERPTRSESSIONID
/AWS1/BDCCODEINTERPTRSESSIONID
¶
The unique identifier of the code interpreter session to use. This must be an active session created with
StartCodeInterpreterSession
. If the session has expired or been stopped, the request will fail.
io_arguments
TYPE REF TO /AWS1/CL_BDCTOOLARGUMENTS
/AWS1/CL_BDCTOOLARGUMENTS
¶
The arguments for the code interpreter. This includes the code to execute and any additional parameters such as the programming language, whether to clear the execution context, and other execution options. The structure of this parameter depends on the specific code interpreter being used.
RETURNING¶
oo_output
TYPE REF TO /aws1/cl_bdcinvokecodeintrsp
/AWS1/CL_BDCINVOKECODEINTRSP
¶
Domain /AWS1/RT_ACCOUNT_ID Primitive Type NUMC
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->/aws1/if_bdc~invokecodeinterpreter(
io_arguments = new /aws1/cl_bdctoolarguments(
it_content = VALUE /aws1/cl_bdcinputcontentblock=>tt_inputcontentblocklist(
(
new /aws1/cl_bdcinputcontentblock(
iv_blob = '5347567362473873563239796247513D'
iv_path = |string|
iv_text = |string|
)
)
)
it_paths = VALUE /aws1/cl_bdcstringlist_w=>tt_stringlist(
( new /aws1/cl_bdcstringlist_w( |string| ) )
)
iv_clearcontext = ABAP_TRUE
iv_code = |string|
iv_command = |string|
iv_directorypath = |string|
iv_language = |string|
iv_path = |string|
iv_taskid = |string|
)
iv_codeinterpreteridentifier = |string|
iv_name = |string|
iv_sessionid = |string|
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
lv_codeinterpretersessioni = lo_result->get_sessionid( ).
TRY.
WHILE lo_result->get_stream( )->/aws1/if_rt_stream_reader~data_available( ) = ABAP_TRUE.
lo_event = lo_result->get_stream( )->READ( ).
IF lo_event->get_result( ) IS NOT INITIAL.
" process this kind of event
ENDIF.
ENDWHILE.
CATCH /aws1/cx_bdcaccessdeniedex.
" handle error in stream
CATCH /aws1/cx_bdcinternalserverex.
" handle error in stream
CATCH /aws1/cx_bdcvalidationex.
" handle error in stream
CATCH /aws1/cx_bdcthrottlingex.
" handle error in stream
CATCH /aws1/cx_bdcresourcenotfoundex.
" handle error in stream
CATCH /aws1/cx_bdcservicequotaexcdex.
" handle error in stream
CATCH /aws1/cx_bdcconflictexception.
" handle error in stream
ENDTRY.
ENDIF.