Skip to content

/AWS1/IF_SGI=>GETSAMPLINGOPERATIONRESULT()

About GetSamplingOperationResult

Retrieves the current status and result of a previously submitted sampling operation. Poll this operation until the status reaches a terminal state (Completed or Failed).

Method Signature

METHODS /AWS1/IF_SGI~GETSAMPLINGOPERATIONRESULT
  IMPORTING
    !IV_TRAININGSESSIONNAME TYPE /AWS1/SGITRAININGSESSIONNAME OPTIONAL
    !IV_OPERATIONID TYPE /AWS1/SGIOPERATIONID OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_sgigetsmploprsltout
  RAISING
    /AWS1/CX_SGIINTERNALSERVEREX
    /AWS1/CX_SGIRESOURCENOTFOUNDEX
    /AWS1/CX_SGITHROTTLINGEX
    /AWS1/CX_SGIVLDTNEXCEPTION
    /AWS1/CX_SGICLIENTEXC
    /AWS1/CX_SGISERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

iv_trainingsessionname TYPE /AWS1/SGITRAININGSESSIONNAME /AWS1/SGITRAININGSESSIONNAME

The name of the training session that owns the sample operation.

iv_operationid TYPE /AWS1/SGIOPERATIONID /AWS1/SGIOPERATIONID

The unique identifier of the sample operation to retrieve, returned by ExecuteSamplingOperation.

RETURNING

oo_output TYPE REF TO /aws1/cl_sgigetsmploprsltout /AWS1/CL_SGIGETSMPLOPRSLTOUT

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->getsamplingoperationresult(
  iv_operationid = |string|
  iv_trainingsessionname = |string|
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lv_requeststatus = lo_result->get_status( ).
  lo_sampleoperationresult = lo_result->get_operationresult( ).
  IF lo_sampleoperationresult IS NOT INITIAL.
    lo_sampleresponse = lo_sampleoperationresult->get_sample( ).
    IF lo_sampleresponse IS NOT INITIAL.
      LOOP AT lo_sampleresponse->get_sequences( ) into lo_row.
        lo_row_1 = lo_row.
        IF lo_row_1 IS NOT INITIAL.
          lv_stopreason = lo_row_1->get_stopreason( ).
          LOOP AT lo_row_1->get_tokens( ) into lo_row_2.
            lo_row_3 = lo_row_2.
            IF lo_row_3 IS NOT INITIAL.
              lv_integer = lo_row_3->get_value( ).
            ENDIF.
          ENDLOOP.
          LOOP AT lo_row_1->get_logprobs( ) into lo_row_4.
            lo_row_5 = lo_row_4.
            IF lo_row_5 IS NOT INITIAL.
              lv_double = lo_row_5->get_value( ).
            ENDIF.
          ENDLOOP.
          lo_sampletokenusage = lo_row_1->get_tokenusage( ).
          IF lo_sampletokenusage IS NOT INITIAL.
            lv_integer = lo_sampletokenusage->get_prefill( ).
            lv_integer = lo_sampletokenusage->get_decode( ).
          ENDIF.
        ENDIF.
      ENDLOOP.
      LOOP AT lo_sampleresponse->get_promptlogprobs( ) into lo_row_4.
        lo_row_5 = lo_row_4.
        IF lo_row_5 IS NOT INITIAL.
          lv_double = lo_row_5->get_value( ).
        ENDIF.
      ENDLOOP.
      LOOP AT lo_sampleresponse->get_topkpromptlogprobs( ) into lt_row_6.
        LOOP AT lt_row_6 into lo_row_7.
          lo_row_8 = lo_row_7.
          IF lo_row_8 IS NOT INITIAL.
            lv_integer = lo_row_8->get_tokenid( ).
            lv_double = lo_row_8->get_logprob( ).
          ENDIF.
        ENDLOOP.
      ENDLOOP.
    ENDIF.
    lo_computelogprobsresult = lo_sampleoperationresult->get_computelogprobs( ).
    IF lo_computelogprobsresult IS NOT INITIAL.
      LOOP AT lo_computelogprobsresult->get_logprobs( ) into lo_row_4.
        lo_row_5 = lo_row_4.
        IF lo_row_5 IS NOT INITIAL.
          lv_double = lo_row_5->get_value( ).
        ENDIF.
      ENDLOOP.
    ENDIF.
    lo_loadweightsforsamplingr = lo_sampleoperationresult->get_loadweightsforsampling( ).
    IF lo_loadweightsforsamplingr IS NOT INITIAL.
    ENDIF.
  ENDIF.
  lv_string = lo_result->get_errordetails( ).
ENDIF.

Get the result of a sampling operation

Retrieves the status and generated sequences for a sampling operation submitted with ExecuteSamplingOperation.

DATA(lo_result) = lo_client->getsamplingoperationresult(
  iv_operationid = |a1b2c3d4-5678-90ab-cdef-1234567890ab|
  iv_trainingsessionname = |my-training-session|
).