sample_with_response_stream
¶
sample_with_response_stream(
job_arn: JobArn,
trajectory_id: TrajectoryId,
body: InferenceRequestBody,
*,
config_overrides: Optional[SagemakerJobRuntimeClientConfig] = None,
) -> Generator[SampleWithResponseStreamResponse]
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.
Parameters:
-
job_arn(JobArn) –The job ARN that identifies which model session to route the inference request to.
-
trajectory_id(TrajectoryId) –The trajectory ID for grouping turns into a single rollout. Each turn is captured for later use.
-
body(InferenceRequestBody) –The raw inference request body in OpenAI-compatible JSON format.
Raises:
-
AccessDeniedException–You do not have permission to perform this operation.
-
InternalServiceError–An internal service error occurred. Retry the request.
-
ResourceNotFoundException–The specified resource was not found.
-
ServiceQuotaExceededException–You have exceeded a service quota.
-
ThrottlingException–The request was throttled. Retry the request after a brief wait.
-
ValidationException–The request is not valid. Check the request syntax and parameters
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
Invoke SampleWithResponseStream Sends a streaming inference request and receives the response as a stream of payload chunks.
>>> client.sample_with_response_stream(job_arn='arn:aws:sagemaker:us-east-1:123456789012:job/AgentRFT/my-training-job', trajectory_id='trajectory-001', body='eyJtb2RlbCI6Im15LW1vZGVsIiwibWVzc2FnZXMiOlt7InJvbGUiOiJ1c2VyIiwiY29udGVudCI6IkhlbGxvIn1dfQ==')
Source code in docs_src/capo_sagemakerjobruntime/_services/sagemaker_job_runtime.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | |