Skip to content

/AWS1/IF_SGJ=>SAMPLEWITHRESPONSESTREAM()

About SampleWithResponseStream

Sends a streaming inference request to the model during a job execution. Returns the response as a stream of payload chunks. Each turn is captured for later use.

Method Signature

METHODS /AWS1/IF_SGJ~SAMPLEWITHRESPONSESTREAM
  IMPORTING
    !IV_JOBARN TYPE /AWS1/SGJJOBARN OPTIONAL
    !IV_TRAJECTORYID TYPE /AWS1/SGJTRAJECTORYID OPTIONAL
    !IV_BODY TYPE /AWS1/SGJINFERENCEREQUESTBODY OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_sgjsamplwthrspstrmrsp
  RAISING
    /AWS1/CX_SGJACCESSDENIEDEX
    /AWS1/CX_SGJINTSERVICEERROR
    /AWS1/CX_SGJRESOURCENOTFOUNDEX
    /AWS1/CX_SGJSERVICEQUOTAEXCDEX
    /AWS1/CX_SGJTHROTTLINGEX
    /AWS1/CX_SGJVLDTNEXCEPTION
    /AWS1/CX_SGJCLIENTEXC
    /AWS1/CX_SGJSERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

iv_jobarn TYPE /AWS1/SGJJOBARN /AWS1/SGJJOBARN

The job ARN that identifies which model session to route the inference request to.

iv_trajectoryid TYPE /AWS1/SGJTRAJECTORYID /AWS1/SGJTRAJECTORYID

The trajectory ID for grouping turns into a single rollout. Each turn is captured for later use.

iv_body TYPE /AWS1/SGJINFERENCEREQUESTBODY /AWS1/SGJINFERENCEREQUESTBODY

The raw inference request body in OpenAI-compatible JSON format.

RETURNING

oo_output TYPE REF TO /aws1/cl_sgjsamplwthrspstrmrsp /AWS1/CL_SGJSAMPLWTHRSPSTRMRSP

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->samplewithresponsestream(
  iv_body = '5347567362473873563239796247513D'
  iv_jobarn = |string|
  iv_trajectoryid = |string|
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lv_string = lo_result->get_contenttype( ).
  lv_responsestream = lo_result->get_body( ).
ENDIF.

Invoke SampleWithResponseStream

Sends a streaming inference request and receives the response as a stream of payload chunks.

DATA(lo_result) = lo_client->samplewithresponsestream(
  iv_body = '65794A746232526C62434936496D31354C5731765A475673496977696257567A6332466E5A584D694F6C7437496E4A76624755694F694A316332567949697769593239756447567564434936496B686C62477876496E316466513D3D'
  iv_jobarn = |arn:aws:sagemaker:us-east-1:123456789012:job/AgentRFT/my-training-job|
  iv_trajectoryid = |trajectory-001|
).