sample_training_session_with_response_stream
¶
sample_training_session_with_response_stream(
training_session_name: TrainingSessionName,
*,
config_overrides: Optional[SageMakerTrainingSessionRuntimeClientConfig] = None,
content_type: Optional[str] = None,
accept: Optional[str] = None,
model_package_arn: Optional[str] = None,
body: Optional[InferenceBody] = None,
) -> Generator[SampleTrainingSessionWithResponseStreamOutput]
Streams inference responses from the model associated with the specified training session. Use this operation for real-time token-by-token generation. The service passes the request body to the model without modification.
Parameters:
-
training_session_name(TrainingSessionName) –The name of the training session whose model to invoke.
-
content_type(Optional[str], default:None) –The MIME type of the input data in the request body.
-
accept(Optional[str], default:None) –The desired MIME type of the inference body in the response.
-
model_package_arn(Optional[str], default:None) –The ARN of the model package whose checkpoint to invoke.
-
body(Optional[InferenceBody], default:None) –The raw inference request body.
Raises:
-
ConflictException–The training session is in a state that cannot accept new operations. The session must be in
RunningorBlockedstate to accept requests. -
InternalServerException–An internal service error occurred. Retry the request using exponential backoff.
-
ResourceNotFoundException–The specified training session or operation does not exist, or the operation does not belong to the specified training session.
-
ThrottlingException–The request was throttled. Retry the request after a brief wait using exponential backoff.
-
ValidationException–The request is not valid. Check the request syntax and parameters. Examples include invalid sequence numbers, malformed client tokens, missing required fields, or invalid operation configuration.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
Stream samples from a training session Sends a chat completion request to the session's current weights and receives the response as a stream of payload chunks.
>>> client.sample_training_session_with_response_stream(training_session_name='my-training-session', content_type='application/json', accept='application/json', body='eyJtZXNzYWdlcyI6W3sicm9sZSI6InVzZXIiLCJjb250ZW50IjoiV2hhdCBpcyB0aGUgY2FwaXRhbCBvZiBGcmFuY2U/In1dLCJtYXhfdG9rZW5zIjoxMjgsInN0cmVhbSI6dHJ1ZX0=')
Source code in docs_src/capo_sagemakertrainingsessionruntime/_services/sage_maker_training_session_runtime.py
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 | |