Class: Aws::SageMakerRuntimeHTTP2::AsyncClient
- Inherits:
-
Seahorse::Client::AsyncBase
- Object
- Seahorse::Client::Base
- Seahorse::Client::AsyncBase
- Aws::SageMakerRuntimeHTTP2::AsyncClient
- Includes:
- AsyncClientStubs
- Defined in:
- gems/aws-sdk-sagemakerruntimehttp2/lib/aws-sdk-sagemakerruntimehttp2/async_client.rb
Overview
An API async client for SageMakerRuntimeHTTP2. To construct an async client, you need to configure a :region and :credentials.
async_client = Aws::SageMakerRuntimeHTTP2::AsyncClient.new(
region: region_name,
credentials: credentials,
# ...
)
For details on configuring region and credentials see the developer guide.
See #initialize for a full list of supported configuration options.
Instance Attribute Summary
Attributes inherited from Seahorse::Client::AsyncBase
Attributes inherited from Seahorse::Client::Base
API Operations collapse
-
#invoke_endpoint_with_bidirectional_stream(params = {}) ⇒ Types::InvokeEndpointWithBidirectionalStreamOutput
Invokes a model endpoint with bidirectional streaming capabilities.
Instance Method Summary collapse
-
#initialize(options) ⇒ AsyncClient
constructor
A new instance of AsyncClient.
Methods included from AsyncClientStubs
Methods included from ClientStubs
#api_requests, #stub_data, #stub_responses
Methods inherited from Seahorse::Client::AsyncBase
#close_connection, #connection_errors, #new_connection, #operation_names
Methods inherited from Seahorse::Client::Base
add_plugin, api, clear_plugins, define, new, #operation_names, plugins, remove_plugin, set_api, set_plugins
Methods included from Seahorse::Client::HandlerBuilder
#handle, #handle_request, #handle_response
Constructor Details
#initialize(options) ⇒ AsyncClient
Returns a new instance of AsyncClient.
405 406 407 408 409 410 |
# File 'gems/aws-sdk-sagemakerruntimehttp2/lib/aws-sdk-sagemakerruntimehttp2/async_client.rb', line 405 def initialize(*args) unless Kernel.const_defined?("HTTP2") raise "Must include http/2 gem to use AsyncClient instances." end super end |
Instance Method Details
#invoke_endpoint_with_bidirectional_stream(params = {}) ⇒ Types::InvokeEndpointWithBidirectionalStreamOutput
Invokes a model endpoint with bidirectional streaming capabilities. This operation establishes a persistent connection that allows you to send multiple requests and receive streaming responses from the model in real-time.
Bidirectional streaming is useful for interactive applications such as chatbots, real-time translation, or any scenario where you need to maintain a conversation-like interaction with the model. The connection remains open, allowing you to send additional input and receive responses without establishing a new connection for each request.
For an overview of Amazon SageMaker AI, see How It Works.
Amazon SageMaker AI strips all POST headers except those supported by the API. Amazon SageMaker AI might add additional headers. You should not rely on the behavior of headers outside those enumerated in the request syntax.
Calls to InvokeEndpointWithBidirectionalStream are authenticated by
using Amazon Web Services Signature Version 4. For information, see
Authenticating Requests (Amazon Web Services Signature Version 4)
in the Amazon S3 API Reference.
The bidirectional stream maintains the connection until either the client closes it or the model indicates completion. Each request and response in the stream is sent as an event with optional headers for data type and completion state.
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 |
# File 'gems/aws-sdk-sagemakerruntimehttp2/lib/aws-sdk-sagemakerruntimehttp2/async_client.rb', line 587 def invoke_endpoint_with_bidirectional_stream(params = {}, = {}, &block) params = params.dup input_event_stream_handler = _event_stream_handler( :input, params.delete(:input_event_stream_handler), EventStreams::RequestStreamEvent ) output_event_stream_handler = _event_stream_handler( :output, params.delete(:output_event_stream_handler) || params.delete(:event_stream_handler), EventStreams::ResponseStreamEvent ) yield(output_event_stream_handler) if block_given? req = build_request(:invoke_endpoint_with_bidirectional_stream, params) req.context[:input_event_stream_handler] = input_event_stream_handler req.handlers.add(Aws::Binary::EncodeHandler, priority: 55) req.context[:output_event_stream_handler] = output_event_stream_handler req.handlers.add(Aws::Binary::DecodeHandler, priority: 55) req.send_request(, &block) end |