sample method

Future<SampleResponse> sample({
  1. required Uint8List body,
  2. required String jobArn,
  3. required String trajectoryId,
})

Sends an inference request to the model during a job execution. The request and response bodies are forwarded to and from the model without modification. Each turn (prompt and response) is captured for later use.

May throw AccessDeniedException. May throw InternalServiceError. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

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

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

Parameter trajectoryId : The trajectory ID for grouping turns into a single rollout. Each turn (prompt and response) is captured for later use.

Implementation

Future<SampleResponse> sample({
  required Uint8List body,
  required String jobArn,
  required String trajectoryId,
}) async {
  final headers = <String, String>{
    'X-Amzn-SageMaker-Job-Arn': jobArn.toString(),
    'X-Amzn-SageMaker-Trajectory-Id': trajectoryId.toString(),
  };
  final response = await _protocol.sendRaw(
    payload: body,
    method: 'POST',
    requestUri: '/sample',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return SampleResponse(
    body: await response.stream.toBytes(),
    contentType:
        _s.extractHeaderStringValue(response.headers, 'Content-Type'),
  );
}