Skip to content

/AWS1/IF_BDR=>INVOKEGUARDRAILCHECKS()

About InvokeGuardrailChecks

Evaluates messages against inline guardrail checks. You specify the check configurations directly in the request, and Amazon Bedrock returns per-check results with severity or confidence scores.

Method Signature

METHODS /AWS1/IF_BDR~INVOKEGUARDRAILCHECKS
  IMPORTING
    !IT_MESSAGES TYPE /AWS1/CL_BDRGDRAILCHECKSMSG=>TT_GUARDRAILCHECKSMESSAGELIST OPTIONAL
    !IO_CHECKS TYPE REF TO /AWS1/CL_BDRGDRAILCHECKSCONFIG OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_bdrinvkgdrailchksrsp
  RAISING
    /AWS1/CX_BDRACCESSDENIEDEX
    /AWS1/CX_BDRINTERNALSERVEREX
    /AWS1/CX_BDRSERVICEUNAVAILEX
    /AWS1/CX_BDRTHROTTLINGEX
    /AWS1/CX_BDRVALIDATIONEX
    /AWS1/CX_BDRCLIENTEXC
    /AWS1/CX_BDRSERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

it_messages TYPE /AWS1/CL_BDRGDRAILCHECKSMSG=>TT_GUARDRAILCHECKSMESSAGELIST TT_GUARDRAILCHECKSMESSAGELIST

The messages to evaluate against the specified guardrail checks. Each message includes a role and one or more content blocks.

io_checks TYPE REF TO /AWS1/CL_BDRGDRAILCHECKSCONFIG /AWS1/CL_BDRGDRAILCHECKSCONFIG

The inline check configurations that specify which guardrail checks to run against the messages.

RETURNING

oo_output TYPE REF TO /aws1/cl_bdrinvkgdrailchksrsp /AWS1/CL_BDRINVKGDRAILCHKSRSP

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->invokeguardrailchecks(
  io_checks = new /aws1/cl_bdrgdrailchecksconfig(
    io_contentfilter = new /aws1/cl_bdrgdrlchxcontfltcfg(
      it_categories = VALUE /aws1/cl_bdrgdrchxcontfltcat00=>tt_gdrailchkscontfiltcatcfglst(
        ( new /aws1/cl_bdrgdrchxcontfltcat00( |string| ) )
      )
    )
    io_promptattack = new /aws1/cl_bdrgdrlchxprattccfg(
      it_categories = VALUE /aws1/cl_bdrgdrchxprattcatcfg=>tt_gdrlchxpromptattccatcfglist(
        ( new /aws1/cl_bdrgdrchxprattcatcfg( |string| ) )
      )
    )
    io_sensitiveinformation = new /aws1/cl_bdrgdrlchxseninfcfg(
      it_entities = VALUE /aws1/cl_bdrgdrchxseninfentcfg=>tt_gdrailchkssensinfoentcfglst(
        ( new /aws1/cl_bdrgdrchxseninfentcfg( |string| ) )
      )
    )
  )
  it_messages = VALUE /aws1/cl_bdrgdrailchecksmsg=>tt_guardrailchecksmessagelist(
    (
      new /aws1/cl_bdrgdrailchecksmsg(
        it_content = VALUE /aws1/cl_bdrgdrailchkscontblck=>tt_gdrailcheckscontblocklist(
          ( new /aws1/cl_bdrgdrailchkscontblck( |string| ) )
        )
        iv_role = |string|
      )
    )
  )
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lo_guardrailchecksresults = lo_result->get_results( ).
  IF lo_guardrailchecksresults IS NOT INITIAL.
    lo_guardrailcheckscontentf = lo_guardrailchecksresults->get_contentfilter( ).
    IF lo_guardrailcheckscontentf IS NOT INITIAL.
      LOOP AT lo_guardrailcheckscontentf->get_results( ) into lo_row.
        lo_row_1 = lo_row.
        IF lo_row_1 IS NOT INITIAL.
          lv_guardrailcheckscontentf_1 = lo_row_1->get_category( ).
          lv_double = lo_row_1->get_severityscore( ).
        ENDIF.
      ENDLOOP.
    ENDIF.
    lo_guardrailcheckspromptat = lo_guardrailchecksresults->get_promptattack( ).
    IF lo_guardrailcheckspromptat IS NOT INITIAL.
      LOOP AT lo_guardrailcheckspromptat->get_results( ) into lo_row_2.
        lo_row_3 = lo_row_2.
        IF lo_row_3 IS NOT INITIAL.
          lv_guardrailcheckspromptat_1 = lo_row_3->get_category( ).
          lv_double = lo_row_3->get_severityscore( ).
        ENDIF.
      ENDLOOP.
    ENDIF.
    lo_guardrailcheckssensitiv = lo_guardrailchecksresults->get_sensitiveinformation( ).
    IF lo_guardrailcheckssensitiv IS NOT INITIAL.
      LOOP AT lo_guardrailcheckssensitiv->get_results( ) into lo_row_4.
        lo_row_5 = lo_row_4.
        IF lo_row_5 IS NOT INITIAL.
          lv_guardrailcheckssensitiv_1 = lo_row_5->get_type( ).
          lv_double = lo_row_5->get_confidencescore( ).
          lv_integer = lo_row_5->get_beginoffset( ).
          lv_integer = lo_row_5->get_endoffset( ).
          lv_integer = lo_row_5->get_messageindex( ).
          lv_integer = lo_row_5->get_contentindex( ).
        ENDIF.
      ENDLOOP.
      lv_boolean = lo_guardrailcheckssensitiv->get_truncated( ).
    ENDIF.
  ENDIF.
  lo_guardrailchecksusageres = lo_result->get_usage( ).
  IF lo_guardrailchecksusageres IS NOT INITIAL.
    lo_guardrailcheckscontentf_2 = lo_guardrailchecksusageres->get_contentfilter( ).
    IF lo_guardrailcheckscontentf_2 IS NOT INITIAL.
      lv_integer = lo_guardrailcheckscontentf_2->get_textunits( ).
    ENDIF.
    lo_guardrailcheckspromptat_2 = lo_guardrailchecksusageres->get_promptattack( ).
    IF lo_guardrailcheckspromptat_2 IS NOT INITIAL.
      lv_integer = lo_guardrailcheckspromptat_2->get_textunits( ).
    ENDIF.
    lo_guardrailcheckssensitiv_2 = lo_guardrailchecksusageres->get_sensitiveinformation( ).
    IF lo_guardrailcheckssensitiv_2 IS NOT INITIAL.
      lv_integer = lo_guardrailcheckssensitiv_2->get_textunits( ).
    ENDIF.
  ENDIF.
ENDIF.