Skip to content

/AWS1/IF_BDZ=>INVOKEFLOW()

About InvokeFlow

Invokes an alias of a flow to run the inputs that you specify and return the output of each node as a stream. If there's an error, the error is returned. For more information, see Test a flow in Amazon Bedrock in the Amazon Bedrock User Guide.

The CLI doesn't support streaming operations in Amazon Bedrock, including InvokeFlow.

Method Signature

METHODS /AWS1/IF_BDZ~INVOKEFLOW
  IMPORTING
    !IV_FLOWIDENTIFIER TYPE /AWS1/BDZFLOWIDENTIFIER OPTIONAL
    !IV_FLOWALIASIDENTIFIER TYPE /AWS1/BDZFLOWALIASIDENTIFIER OPTIONAL
    !IT_INPUTS TYPE /AWS1/CL_BDZFLOWINPUT=>TT_FLOWINPUTS OPTIONAL
    !IV_ENABLETRACE TYPE /AWS1/BDZBOOLEAN OPTIONAL
    !IO_MODELPERFORMANCECONF TYPE REF TO /AWS1/CL_BDZMDELPERFORMANCEC00 OPTIONAL
    !IV_EXECUTIONID TYPE /AWS1/BDZFLOWEXECUTIONID OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_bdzinvokeflowresponse
  RAISING
    /AWS1/CX_BDZACCESSDENIEDEX
    /AWS1/CX_BDZBADGATEWAYEX
    /AWS1/CX_BDZCONFLICTEXCEPTION
    /AWS1/CX_BDZDEPENDENCYFAILEDEX
    /AWS1/CX_BDZINTERNALSERVEREX
    /AWS1/CX_BDZRESOURCENOTFOUNDEX
    /AWS1/CX_BDZSERVICEQUOTAEXCDEX
    /AWS1/CX_BDZTHROTTLINGEX
    /AWS1/CX_BDZVALIDATIONEX
    /AWS1/CX_BDZCLIENTEXC
    /AWS1/CX_BDZSERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

iv_flowidentifier TYPE /AWS1/BDZFLOWIDENTIFIER /AWS1/BDZFLOWIDENTIFIER

The unique identifier of the flow.

iv_flowaliasidentifier TYPE /AWS1/BDZFLOWALIASIDENTIFIER /AWS1/BDZFLOWALIASIDENTIFIER

The unique identifier of the flow alias.

it_inputs TYPE /AWS1/CL_BDZFLOWINPUT=>TT_FLOWINPUTS TT_FLOWINPUTS

A list of objects, each containing information about an input into the flow.

Optional arguments:

iv_enabletrace TYPE /AWS1/BDZBOOLEAN /AWS1/BDZBOOLEAN

Specifies whether to return the trace for the flow or not. Traces track inputs and outputs for nodes in the flow. For more information, see Track each step in your prompt flow by viewing its trace in Amazon Bedrock.

io_modelperformanceconf TYPE REF TO /AWS1/CL_BDZMDELPERFORMANCEC00 /AWS1/CL_BDZMDELPERFORMANCEC00

Model performance settings for the request.

iv_executionid TYPE /AWS1/BDZFLOWEXECUTIONID /AWS1/BDZFLOWEXECUTIONID

The unique identifier for the current flow execution. If you don't provide a value, Amazon Bedrock creates the identifier for you.

RETURNING

oo_output TYPE REF TO /aws1/cl_bdzinvokeflowresponse /AWS1/CL_BDZINVOKEFLOWRESPONSE

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->invokeflow(
  io_modelperformanceconf = new /aws1/cl_bdzmdelperformancec00( new /aws1/cl_bdzperformanceconf( |string| ) )
  it_inputs = VALUE /aws1/cl_bdzflowinput=>tt_flowinputs(
    (
      new /aws1/cl_bdzflowinput(
        io_content = new /aws1/cl_bdzflowinputcontent(
          io_document = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
        )
        iv_nodeinputname = |string|
        iv_nodename = |string|
        iv_nodeoutputname = |string|
      )
    )
  )
  iv_enabletrace = ABAP_TRUE
  iv_executionid = |string|
  iv_flowaliasidentifier = |string|
  iv_flowidentifier = |string|
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  TRY.
    WHILE lo_result->get_responsestream( )->/aws1/if_rt_stream_reader~data_available( ) = ABAP_TRUE.
      lo_event = lo_result->get_responsestream( )->READ( ).
      IF lo_event->get_flowoutputevent( ) IS NOT INITIAL.
        " process this kind of event
      ELSEIF lo_event->get_flowcompletionevent( ) IS NOT INITIAL.
        " process this kind of event
      ELSEIF lo_event->get_flowtraceevent( ) IS NOT INITIAL.
        " process this kind of event
      ELSEIF lo_event->get_flowmultiturninpreqevent( ) IS NOT INITIAL.
        " process this kind of event
      ENDIF.
    ENDWHILE.
  CATCH /aws1/cx_bdzaccessdeniedex.
    " handle error in stream
  CATCH /aws1/cx_bdzinternalserverex.
    " handle error in stream
  CATCH /aws1/cx_bdzvalidationex.
    " handle error in stream
  CATCH /aws1/cx_bdzthrottlingex.
    " handle error in stream
  CATCH /aws1/cx_bdzdependencyfailedex.
    " handle error in stream
  CATCH /aws1/cx_bdzbadgatewayex.
    " handle error in stream
  CATCH /aws1/cx_bdzresourcenotfoundex.
    " handle error in stream
  CATCH /aws1/cx_bdzservicequotaexcdex.
    " handle error in stream
  CATCH /aws1/cx_bdzconflictexception.
    " handle error in stream
  ENDTRY.
  lv_flowexecutionid = lo_result->get_executionid( ).
ENDIF.