aws-sdk-bedrockruntime 1.43.0 → 1.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-bedrockruntime/async_client.rb +626 -0
- data/lib/aws-sdk-bedrockruntime/client.rb +41 -1
- data/lib/aws-sdk-bedrockruntime/client_api.rb +64 -4
- data/lib/aws-sdk-bedrockruntime/event_streams.rb +87 -0
- data/lib/aws-sdk-bedrockruntime/types.rb +147 -2
- data/lib/aws-sdk-bedrockruntime.rb +2 -1
- data/sig/client.rbs +51 -8
- data/sig/types.rbs +37 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a28ecebc4aefbade585fa64ee44ca3d6a445d7eee403f96e29f23631e852731
|
4
|
+
data.tar.gz: 1d6501a1e3b85623e0adab595c50d520fb55abb0c99007be4e59a84a1524a473
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: deeeb6488b6f3788319d883ed9ebf112bb0e5934ccee9603e673350de70aec30225f12045d4f772870c71ea4c22c22bfe051d650e12ea15f031e2f2751656388
|
7
|
+
data.tar.gz: a5007dcde7957b74af5f80e730de711b17bfba3224e5a47c4f111529e2cbce6a66da2ad7242486712d772e408fd574932ba13a4924fbc4f46e049448fcc1e0ef
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
Unreleased Changes
|
2
2
|
------------------
|
3
3
|
|
4
|
+
1.45.0 (2025-04-25)
|
5
|
+
------------------
|
6
|
+
|
7
|
+
* Feature - You can now reference images and documents stored in Amazon S3 when using InvokeModel and Converse APIs with Amazon Nova Lite and Nova Pro. This enables direct integration of S3-stored multimedia assets in your model requests without manual downloading or base64 encoding.
|
8
|
+
|
9
|
+
1.44.0 (2025-04-08)
|
10
|
+
------------------
|
11
|
+
|
12
|
+
* Feature - This release introduces our latest bedrock runtime API, InvokeModelWithBidirectionalStream. The API supports both input and output streams and is supported by only HTTP2.0.
|
13
|
+
|
4
14
|
1.43.0 (2025-04-07)
|
5
15
|
------------------
|
6
16
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.45.0
|
@@ -0,0 +1,626 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# WARNING ABOUT GENERATED CODE
|
4
|
+
#
|
5
|
+
# This file is generated. See the contributing guide for more information:
|
6
|
+
# https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
|
7
|
+
#
|
8
|
+
# WARNING ABOUT GENERATED CODE
|
9
|
+
|
10
|
+
begin
|
11
|
+
require 'http/2'
|
12
|
+
rescue LoadError; end
|
13
|
+
require 'aws-sdk-core/plugins/credentials_configuration.rb'
|
14
|
+
require 'aws-sdk-core/plugins/logging.rb'
|
15
|
+
require 'aws-sdk-core/plugins/param_converter.rb'
|
16
|
+
require 'aws-sdk-core/plugins/param_validator.rb'
|
17
|
+
require 'aws-sdk-core/plugins/user_agent.rb'
|
18
|
+
require 'aws-sdk-core/plugins/helpful_socket_errors.rb'
|
19
|
+
require 'aws-sdk-core/plugins/retry_errors.rb'
|
20
|
+
require 'aws-sdk-core/plugins/global_configuration.rb'
|
21
|
+
require 'aws-sdk-core/plugins/regional_endpoint.rb'
|
22
|
+
require 'aws-sdk-core/plugins/stub_responses.rb'
|
23
|
+
require 'aws-sdk-core/plugins/idempotency_token.rb'
|
24
|
+
require 'aws-sdk-core/plugins/invocation_id.rb'
|
25
|
+
require 'aws-sdk-core/plugins/jsonvalue_converter.rb'
|
26
|
+
require 'aws-sdk-core/plugins/http_checksum.rb'
|
27
|
+
require 'aws-sdk-core/plugins/checksum_algorithm.rb'
|
28
|
+
require 'aws-sdk-core/plugins/request_compression.rb'
|
29
|
+
require 'aws-sdk-core/plugins/defaults_mode.rb'
|
30
|
+
require 'aws-sdk-core/plugins/recursion_detection.rb'
|
31
|
+
require 'aws-sdk-core/plugins/telemetry.rb'
|
32
|
+
require 'aws-sdk-core/plugins/sign.rb'
|
33
|
+
require 'aws-sdk-core/plugins/protocols/rest_json.rb'
|
34
|
+
require 'aws-sdk-core/plugins/event_stream_configuration.rb'
|
35
|
+
|
36
|
+
Aws::Plugins::GlobalConfiguration.add_identifier(:bedrockruntime)
|
37
|
+
|
38
|
+
module Aws::BedrockRuntime
|
39
|
+
class AsyncClient < Seahorse::Client::AsyncBase
|
40
|
+
|
41
|
+
include Aws::AsyncClientStubs
|
42
|
+
|
43
|
+
@identifier = :bedrockruntime
|
44
|
+
|
45
|
+
set_api(ClientApi::API)
|
46
|
+
|
47
|
+
add_plugin(Aws::Plugins::CredentialsConfiguration)
|
48
|
+
add_plugin(Aws::Plugins::Logging)
|
49
|
+
add_plugin(Aws::Plugins::ParamConverter)
|
50
|
+
add_plugin(Aws::Plugins::ParamValidator)
|
51
|
+
add_plugin(Aws::Plugins::UserAgent)
|
52
|
+
add_plugin(Aws::Plugins::HelpfulSocketErrors)
|
53
|
+
add_plugin(Aws::Plugins::RetryErrors)
|
54
|
+
add_plugin(Aws::Plugins::GlobalConfiguration)
|
55
|
+
add_plugin(Aws::Plugins::RegionalEndpoint)
|
56
|
+
add_plugin(Aws::Plugins::StubResponses)
|
57
|
+
add_plugin(Aws::Plugins::IdempotencyToken)
|
58
|
+
add_plugin(Aws::Plugins::InvocationId)
|
59
|
+
add_plugin(Aws::Plugins::JsonvalueConverter)
|
60
|
+
add_plugin(Aws::Plugins::HttpChecksum)
|
61
|
+
add_plugin(Aws::Plugins::ChecksumAlgorithm)
|
62
|
+
add_plugin(Aws::Plugins::RequestCompression)
|
63
|
+
add_plugin(Aws::Plugins::DefaultsMode)
|
64
|
+
add_plugin(Aws::Plugins::RecursionDetection)
|
65
|
+
add_plugin(Aws::Plugins::Telemetry)
|
66
|
+
add_plugin(Aws::Plugins::Sign)
|
67
|
+
add_plugin(Aws::Plugins::Protocols::RestJson)
|
68
|
+
add_plugin(Aws::Plugins::EventStreamConfiguration)
|
69
|
+
add_plugin(Aws::BedrockRuntime::Plugins::Endpoints)
|
70
|
+
|
71
|
+
# @option options [required, Aws::CredentialProvider] :credentials
|
72
|
+
# Your AWS credentials. This can be an instance of any one of the
|
73
|
+
# following classes:
|
74
|
+
#
|
75
|
+
# * `Aws::Credentials` - Used for configuring static, non-refreshing
|
76
|
+
# credentials.
|
77
|
+
#
|
78
|
+
# * `Aws::SharedCredentials` - Used for loading static credentials from a
|
79
|
+
# shared file, such as `~/.aws/config`.
|
80
|
+
#
|
81
|
+
# * `Aws::AssumeRoleCredentials` - Used when you need to assume a role.
|
82
|
+
#
|
83
|
+
# * `Aws::AssumeRoleWebIdentityCredentials` - Used when you need to
|
84
|
+
# assume a role after providing credentials via the web.
|
85
|
+
#
|
86
|
+
# * `Aws::SSOCredentials` - Used for loading credentials from AWS SSO using an
|
87
|
+
# access token generated from `aws login`.
|
88
|
+
#
|
89
|
+
# * `Aws::ProcessCredentials` - Used for loading credentials from a
|
90
|
+
# process that outputs to stdout.
|
91
|
+
#
|
92
|
+
# * `Aws::InstanceProfileCredentials` - Used for loading credentials
|
93
|
+
# from an EC2 IMDS on an EC2 instance.
|
94
|
+
#
|
95
|
+
# * `Aws::ECSCredentials` - Used for loading credentials from
|
96
|
+
# instances running in ECS.
|
97
|
+
#
|
98
|
+
# * `Aws::CognitoIdentityCredentials` - Used for loading credentials
|
99
|
+
# from the Cognito Identity service.
|
100
|
+
#
|
101
|
+
# When `:credentials` are not configured directly, the following
|
102
|
+
# locations will be searched for credentials:
|
103
|
+
#
|
104
|
+
# * `Aws.config[:credentials]`
|
105
|
+
# * The `:access_key_id`, `:secret_access_key`, `:session_token`, and
|
106
|
+
# `:account_id` options.
|
107
|
+
# * ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY'],
|
108
|
+
# ENV['AWS_SESSION_TOKEN'], and ENV['AWS_ACCOUNT_ID']
|
109
|
+
# * `~/.aws/credentials`
|
110
|
+
# * `~/.aws/config`
|
111
|
+
# * EC2/ECS IMDS instance profile - When used by default, the timeouts
|
112
|
+
# are very aggressive. Construct and pass an instance of
|
113
|
+
# `Aws::InstanceProfileCredentials` or `Aws::ECSCredentials` to
|
114
|
+
# enable retries and extended timeouts. Instance profile credential
|
115
|
+
# fetching can be disabled by setting ENV['AWS_EC2_METADATA_DISABLED']
|
116
|
+
# to true.
|
117
|
+
#
|
118
|
+
# @option options [required, String] :region
|
119
|
+
# The AWS region to connect to. The configured `:region` is
|
120
|
+
# used to determine the service `:endpoint`. When not passed,
|
121
|
+
# a default `:region` is searched for in the following locations:
|
122
|
+
#
|
123
|
+
# * `Aws.config[:region]`
|
124
|
+
# * `ENV['AWS_REGION']`
|
125
|
+
# * `ENV['AMAZON_REGION']`
|
126
|
+
# * `ENV['AWS_DEFAULT_REGION']`
|
127
|
+
# * `~/.aws/credentials`
|
128
|
+
# * `~/.aws/config`
|
129
|
+
#
|
130
|
+
# @option options [String] :access_key_id
|
131
|
+
#
|
132
|
+
# @option options [String] :account_id
|
133
|
+
#
|
134
|
+
# @option options [Boolean] :adaptive_retry_wait_to_fill (true)
|
135
|
+
# Used only in `adaptive` retry mode. When true, the request will sleep
|
136
|
+
# until there is sufficent client side capacity to retry the request.
|
137
|
+
# When false, the request will raise a `RetryCapacityNotAvailableError` and will
|
138
|
+
# not retry instead of sleeping.
|
139
|
+
#
|
140
|
+
# @option options [Boolean] :convert_params (true)
|
141
|
+
# When `true`, an attempt is made to coerce request parameters into
|
142
|
+
# the required types.
|
143
|
+
#
|
144
|
+
# @option options [Boolean] :correct_clock_skew (true)
|
145
|
+
# Used only in `standard` and adaptive retry modes. Specifies whether to apply
|
146
|
+
# a clock skew correction and retry requests with skewed client clocks.
|
147
|
+
#
|
148
|
+
# @option options [String] :defaults_mode ("legacy")
|
149
|
+
# See {Aws::DefaultsModeConfiguration} for a list of the
|
150
|
+
# accepted modes and the configuration defaults that are included.
|
151
|
+
#
|
152
|
+
# @option options [Boolean] :disable_request_compression (false)
|
153
|
+
# When set to 'true' the request body will not be compressed
|
154
|
+
# for supported operations.
|
155
|
+
#
|
156
|
+
# @option options [String, URI::HTTPS, URI::HTTP] :endpoint
|
157
|
+
# Normally you should not configure the `:endpoint` option
|
158
|
+
# directly. This is normally constructed from the `:region`
|
159
|
+
# option. Configuring `:endpoint` is normally reserved for
|
160
|
+
# connecting to test or custom endpoints. The endpoint should
|
161
|
+
# be a URI formatted like:
|
162
|
+
#
|
163
|
+
# 'http://example.com'
|
164
|
+
# 'https://example.com'
|
165
|
+
# 'http://example.com:123'
|
166
|
+
#
|
167
|
+
# @option options [Proc] :event_stream_handler
|
168
|
+
# When an EventStream or Proc object is provided, it will be used as callback for each chunk of event stream response received along the way.
|
169
|
+
#
|
170
|
+
# @option options [Boolean] :ignore_configured_endpoint_urls
|
171
|
+
# Setting to true disables use of endpoint URLs provided via environment
|
172
|
+
# variables and the shared configuration file.
|
173
|
+
#
|
174
|
+
# @option options [Proc] :input_event_stream_handler
|
175
|
+
# When an EventStream or Proc object is provided, it can be used for sending events for the event stream.
|
176
|
+
#
|
177
|
+
# @option options [Aws::Log::Formatter] :log_formatter (Aws::Log::Formatter.default)
|
178
|
+
# The log formatter.
|
179
|
+
#
|
180
|
+
# @option options [Symbol] :log_level (:info)
|
181
|
+
# The log level to send messages to the `:logger` at.
|
182
|
+
#
|
183
|
+
# @option options [Logger] :logger
|
184
|
+
# The Logger instance to send log messages to. If this option
|
185
|
+
# is not set, logging will be disabled.
|
186
|
+
#
|
187
|
+
# @option options [Integer] :max_attempts (3)
|
188
|
+
# An integer representing the maximum number attempts that will be made for
|
189
|
+
# a single request, including the initial attempt. For example,
|
190
|
+
# setting this value to 5 will result in a request being retried up to
|
191
|
+
# 4 times. Used in `standard` and `adaptive` retry modes.
|
192
|
+
#
|
193
|
+
# @option options [Proc] :output_event_stream_handler
|
194
|
+
# When an EventStream or Proc object is provided, it will be used as callback for each chunk of event stream response received along the way.
|
195
|
+
#
|
196
|
+
# @option options [String] :profile ("default")
|
197
|
+
# Used when loading credentials from the shared credentials file
|
198
|
+
# at HOME/.aws/credentials. When not specified, 'default' is used.
|
199
|
+
#
|
200
|
+
# @option options [String] :request_checksum_calculation ("when_supported")
|
201
|
+
# Determines when a checksum will be calculated for request payloads. Values are:
|
202
|
+
#
|
203
|
+
# * `when_supported` - (default) When set, a checksum will be
|
204
|
+
# calculated for all request payloads of operations modeled with the
|
205
|
+
# `httpChecksum` trait where `requestChecksumRequired` is `true` and/or a
|
206
|
+
# `requestAlgorithmMember` is modeled.
|
207
|
+
# * `when_required` - When set, a checksum will only be calculated for
|
208
|
+
# request payloads of operations modeled with the `httpChecksum` trait where
|
209
|
+
# `requestChecksumRequired` is `true` or where a `requestAlgorithmMember`
|
210
|
+
# is modeled and supplied.
|
211
|
+
#
|
212
|
+
# @option options [Integer] :request_min_compression_size_bytes (10240)
|
213
|
+
# The minimum size in bytes that triggers compression for request
|
214
|
+
# bodies. The value must be non-negative integer value between 0
|
215
|
+
# and 10485780 bytes inclusive.
|
216
|
+
#
|
217
|
+
# @option options [String] :response_checksum_validation ("when_supported")
|
218
|
+
# Determines when checksum validation will be performed on response payloads. Values are:
|
219
|
+
#
|
220
|
+
# * `when_supported` - (default) When set, checksum validation is performed on all
|
221
|
+
# response payloads of operations modeled with the `httpChecksum` trait where
|
222
|
+
# `responseAlgorithms` is modeled, except when no modeled checksum algorithms
|
223
|
+
# are supported.
|
224
|
+
# * `when_required` - When set, checksum validation is not performed on
|
225
|
+
# response payloads of operations unless the checksum algorithm is supported and
|
226
|
+
# the `requestValidationModeMember` member is set to `ENABLED`.
|
227
|
+
#
|
228
|
+
# @option options [Proc] :retry_backoff
|
229
|
+
# A proc or lambda used for backoff. Defaults to 2**retries * retry_base_delay.
|
230
|
+
# This option is only used in the `legacy` retry mode.
|
231
|
+
#
|
232
|
+
# @option options [Float] :retry_base_delay (0.3)
|
233
|
+
# The base delay in seconds used by the default backoff function. This option
|
234
|
+
# is only used in the `legacy` retry mode.
|
235
|
+
#
|
236
|
+
# @option options [Symbol] :retry_jitter (:none)
|
237
|
+
# A delay randomiser function used by the default backoff function.
|
238
|
+
# Some predefined functions can be referenced by name - :none, :equal, :full,
|
239
|
+
# otherwise a Proc that takes and returns a number. This option is only used
|
240
|
+
# in the `legacy` retry mode.
|
241
|
+
#
|
242
|
+
# @see https://www.awsarchitectureblog.com/2015/03/backoff.html
|
243
|
+
#
|
244
|
+
# @option options [Integer] :retry_limit (3)
|
245
|
+
# The maximum number of times to retry failed requests. Only
|
246
|
+
# ~ 500 level server errors and certain ~ 400 level client errors
|
247
|
+
# are retried. Generally, these are throttling errors, data
|
248
|
+
# checksum errors, networking errors, timeout errors, auth errors,
|
249
|
+
# endpoint discovery, and errors from expired credentials.
|
250
|
+
# This option is only used in the `legacy` retry mode.
|
251
|
+
#
|
252
|
+
# @option options [Integer] :retry_max_delay (0)
|
253
|
+
# The maximum number of seconds to delay between retries (0 for no limit)
|
254
|
+
# used by the default backoff function. This option is only used in the
|
255
|
+
# `legacy` retry mode.
|
256
|
+
#
|
257
|
+
# @option options [String] :retry_mode ("legacy")
|
258
|
+
# Specifies which retry algorithm to use. Values are:
|
259
|
+
#
|
260
|
+
# * `legacy` - The pre-existing retry behavior. This is default value if
|
261
|
+
# no retry mode is provided.
|
262
|
+
#
|
263
|
+
# * `standard` - A standardized set of retry rules across the AWS SDKs.
|
264
|
+
# This includes support for retry quotas, which limit the number of
|
265
|
+
# unsuccessful retries a client can make.
|
266
|
+
#
|
267
|
+
# * `adaptive` - An experimental retry mode that includes all the
|
268
|
+
# functionality of `standard` mode along with automatic client side
|
269
|
+
# throttling. This is a provisional mode that may change behavior
|
270
|
+
# in the future.
|
271
|
+
#
|
272
|
+
# @option options [String] :sdk_ua_app_id
|
273
|
+
# A unique and opaque application ID that is appended to the
|
274
|
+
# User-Agent header as app/sdk_ua_app_id. It should have a
|
275
|
+
# maximum length of 50. This variable is sourced from environment
|
276
|
+
# variable AWS_SDK_UA_APP_ID or the shared config profile attribute sdk_ua_app_id.
|
277
|
+
#
|
278
|
+
# @option options [String] :secret_access_key
|
279
|
+
#
|
280
|
+
# @option options [String] :session_token
|
281
|
+
#
|
282
|
+
# @option options [Array] :sigv4a_signing_region_set
|
283
|
+
# A list of regions that should be signed with SigV4a signing. When
|
284
|
+
# not passed, a default `:sigv4a_signing_region_set` is searched for
|
285
|
+
# in the following locations:
|
286
|
+
#
|
287
|
+
# * `Aws.config[:sigv4a_signing_region_set]`
|
288
|
+
# * `ENV['AWS_SIGV4A_SIGNING_REGION_SET']`
|
289
|
+
# * `~/.aws/config`
|
290
|
+
#
|
291
|
+
# @option options [Boolean] :stub_responses (false)
|
292
|
+
# Causes the client to return stubbed responses. By default
|
293
|
+
# fake responses are generated and returned. You can specify
|
294
|
+
# the response data to return or errors to raise by calling
|
295
|
+
# {ClientStubs#stub_responses}. See {ClientStubs} for more information.
|
296
|
+
#
|
297
|
+
# ** Please note ** When response stubbing is enabled, no HTTP
|
298
|
+
# requests are made, and retries are disabled.
|
299
|
+
#
|
300
|
+
# @option options [Aws::Telemetry::TelemetryProviderBase] :telemetry_provider (Aws::Telemetry::NoOpTelemetryProvider)
|
301
|
+
# Allows you to provide a telemetry provider, which is used to
|
302
|
+
# emit telemetry data. By default, uses `NoOpTelemetryProvider` which
|
303
|
+
# will not record or emit any telemetry data. The SDK supports the
|
304
|
+
# following telemetry providers:
|
305
|
+
#
|
306
|
+
# * OpenTelemetry (OTel) - To use the OTel provider, install and require the
|
307
|
+
# `opentelemetry-sdk` gem and then, pass in an instance of a
|
308
|
+
# `Aws::Telemetry::OTelProvider` for telemetry provider.
|
309
|
+
#
|
310
|
+
# @option options [Aws::TokenProvider] :token_provider
|
311
|
+
# A Bearer Token Provider. This can be an instance of any one of the
|
312
|
+
# following classes:
|
313
|
+
#
|
314
|
+
# * `Aws::StaticTokenProvider` - Used for configuring static, non-refreshing
|
315
|
+
# tokens.
|
316
|
+
#
|
317
|
+
# * `Aws::SSOTokenProvider` - Used for loading tokens from AWS SSO using an
|
318
|
+
# access token generated from `aws login`.
|
319
|
+
#
|
320
|
+
# When `:token_provider` is not configured directly, the `Aws::TokenProviderChain`
|
321
|
+
# will be used to search for tokens configured for your profile in shared configuration files.
|
322
|
+
#
|
323
|
+
# @option options [Boolean] :use_dualstack_endpoint
|
324
|
+
# When set to `true`, dualstack enabled endpoints (with `.aws` TLD)
|
325
|
+
# will be used if available.
|
326
|
+
#
|
327
|
+
# @option options [Boolean] :use_fips_endpoint
|
328
|
+
# When set to `true`, fips compatible endpoints will be used if available.
|
329
|
+
# When a `fips` region is used, the region is normalized and this config
|
330
|
+
# is set to `true`.
|
331
|
+
#
|
332
|
+
# @option options [Boolean] :validate_params (true)
|
333
|
+
# When `true`, request parameters are validated before
|
334
|
+
# sending the request.
|
335
|
+
#
|
336
|
+
# @option options [Aws::BedrockRuntime::EndpointProvider] :endpoint_provider
|
337
|
+
# The endpoint provider used to resolve endpoints. Any object that responds to
|
338
|
+
# `#resolve_endpoint(parameters)` where `parameters` is a Struct similar to
|
339
|
+
# `Aws::BedrockRuntime::EndpointParameters`.
|
340
|
+
#
|
341
|
+
# @option options [Integer] :connection_read_timeout (60)
|
342
|
+
# Connection read timeout in seconds, defaults to 60 sec.
|
343
|
+
#
|
344
|
+
# @option options [Integer] :connection_timeout (60)
|
345
|
+
# Connection timeout in seconds, defaults to 60 sec.
|
346
|
+
#
|
347
|
+
# @option options [Boolean] :enable_alpn (true)
|
348
|
+
# Set to `false` to disable ALPN in HTTP2 over TLS. ALPN requires Openssl version >= 1.0.2.
|
349
|
+
# Note: RFC7540 requires HTTP2 to use ALPN over TLS but some
|
350
|
+
# services may not fully support ALPN and require setting this to `false`.
|
351
|
+
#
|
352
|
+
# @option options [Boolean] :http_wire_trace (false)
|
353
|
+
# When `true`, HTTP2 debug output will be sent to the `:logger`.
|
354
|
+
#
|
355
|
+
# @option options [Integer] :max_concurrent_streams (100)
|
356
|
+
# Maximum concurrent streams used in HTTP2 connection, defaults to 100. Note that server may send back
|
357
|
+
# :settings_max_concurrent_streams value which will take priority when initializing new streams.
|
358
|
+
#
|
359
|
+
# @option options [Boolean] :raise_response_errors (true)
|
360
|
+
# Defaults to `true`, raises errors if exist when #wait or #join! is called upon async response.
|
361
|
+
#
|
362
|
+
# @option options [Integer] :read_chunk_size (1024)
|
363
|
+
#
|
364
|
+
# @option options [String] :ssl_ca_bundle
|
365
|
+
# Full path to the SSL certificate authority bundle file that should be used when
|
366
|
+
# verifying peer certificates. If you do not pass `:ssl_ca_directory` or `:ssl_ca_bundle`
|
367
|
+
# the system default will be used if available.
|
368
|
+
#
|
369
|
+
# @option options [String] :ssl_ca_directory
|
370
|
+
# Full path of the directory that contains the unbundled SSL certificate authority
|
371
|
+
# files for verifying peer certificates. If you do not pass `:ssl_ca_bundle` or
|
372
|
+
# `:ssl_ca_directory` the system default will be used if available.
|
373
|
+
#
|
374
|
+
# @option options [String] :ssl_ca_store
|
375
|
+
#
|
376
|
+
# @option options [Boolean] :ssl_verify_peer (true)
|
377
|
+
# When `true`, SSL peer certificates are verified when establishing a connection.
|
378
|
+
#
|
379
|
+
def initialize(*args)
|
380
|
+
unless Kernel.const_defined?("HTTP2")
|
381
|
+
raise "Must include http/2 gem to use AsyncClient instances."
|
382
|
+
end
|
383
|
+
super
|
384
|
+
end
|
385
|
+
|
386
|
+
# @!group API Operations
|
387
|
+
|
388
|
+
# Invoke the specified Amazon Bedrock model to run inference using the
|
389
|
+
# bidirectional stream. The response is returned in a stream that
|
390
|
+
# remains open for 8 minutes. A single session can contain multiple
|
391
|
+
# prompts and responses from the model. The prompts to the model are
|
392
|
+
# provided as audio files and the model's responses are spoken back to
|
393
|
+
# the user and transcribed.
|
394
|
+
#
|
395
|
+
# It is possible for users to interrupt the model's response with a new
|
396
|
+
# prompt, which will halt the response speech. The model will retain
|
397
|
+
# contextual awareness of the conversation while pivoting to respond to
|
398
|
+
# the new prompt.
|
399
|
+
#
|
400
|
+
# @option params [required, String] :model_id
|
401
|
+
# The model ID or ARN of the model ID to use. Currently, only
|
402
|
+
# `amazon.nova-sonic-v1:0` is supported.
|
403
|
+
#
|
404
|
+
# @return [Types::InvokeModelWithBidirectionalStreamResponse] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
|
405
|
+
#
|
406
|
+
# * {Types::InvokeModelWithBidirectionalStreamResponse#body #body} => Types::InvokeModelWithBidirectionalStreamOutput
|
407
|
+
#
|
408
|
+
# @example Bi-directional EventStream Operation Example
|
409
|
+
#
|
410
|
+
# You can signal input events after the initial request is established. Events
|
411
|
+
# will be sent to the stream immediately once the stream connection is
|
412
|
+
# established successfully.
|
413
|
+
#
|
414
|
+
# To signal events, you can call the #signal methods from an Aws::BedrockRuntime::EventStreams::InvokeModelWithBidirectionalStreamInput
|
415
|
+
# object. You must signal events before calling #wait or #join! on the async response.
|
416
|
+
#
|
417
|
+
# input_stream = Aws::BedrockRuntime::EventStreams::InvokeModelWithBidirectionalStreamInput.new
|
418
|
+
#
|
419
|
+
# async_resp = client.invoke_model_with_bidirectional_stream(
|
420
|
+
# # params input
|
421
|
+
# input_event_stream_handler: input_stream) do |out_stream|
|
422
|
+
#
|
423
|
+
# # register callbacks for events
|
424
|
+
# out_stream.on_chunk_event do |event|
|
425
|
+
# event # => Aws::BedrockRuntime::Types::chunk
|
426
|
+
# end
|
427
|
+
# out_stream.on_internal_server_exception_event do |event|
|
428
|
+
# event # => Aws::BedrockRuntime::Types::internalServerException
|
429
|
+
# end
|
430
|
+
# out_stream.on_model_stream_error_exception_event do |event|
|
431
|
+
# event # => Aws::BedrockRuntime::Types::modelStreamErrorException
|
432
|
+
# end
|
433
|
+
# out_stream.on_validation_exception_event do |event|
|
434
|
+
# event # => Aws::BedrockRuntime::Types::validationException
|
435
|
+
# end
|
436
|
+
# out_stream.on_throttling_exception_event do |event|
|
437
|
+
# event # => Aws::BedrockRuntime::Types::throttlingException
|
438
|
+
# end
|
439
|
+
# out_stream.on_model_timeout_exception_event do |event|
|
440
|
+
# event # => Aws::BedrockRuntime::Types::modelTimeoutException
|
441
|
+
# end
|
442
|
+
# out_stream.on_service_unavailable_exception_event do |event|
|
443
|
+
# event # => Aws::BedrockRuntime::Types::serviceUnavailableException
|
444
|
+
# end
|
445
|
+
#
|
446
|
+
# end
|
447
|
+
# # => Aws::Seahorse::Client::AsyncResponse
|
448
|
+
#
|
449
|
+
# # signal events
|
450
|
+
# input_stream.signal_chunk_event( ... )
|
451
|
+
#
|
452
|
+
# # make sure to signal :end_stream at the end
|
453
|
+
# input_stream.signal_end_stream
|
454
|
+
#
|
455
|
+
# # wait until stream is closed before finalizing the sync response
|
456
|
+
# resp = async_resp.wait
|
457
|
+
# # Or close the stream and finalize sync response immediately
|
458
|
+
# # resp = async_resp.join!
|
459
|
+
#
|
460
|
+
# You can also provide an Aws::BedrockRuntime::EventStreams::InvokeModelWithBidirectionalStreamOutput object to register callbacks
|
461
|
+
# before initializing the request instead of processing from the request block.
|
462
|
+
#
|
463
|
+
# output_stream = Aws::BedrockRuntime::EventStreams::InvokeModelWithBidirectionalStreamOutput.new
|
464
|
+
# # register callbacks for output events
|
465
|
+
# output_stream.on_chunk_event do |event|
|
466
|
+
# event # => Aws::BedrockRuntime::Types::chunk
|
467
|
+
# end
|
468
|
+
# output_stream.on_internal_server_exception_event do |event|
|
469
|
+
# event # => Aws::BedrockRuntime::Types::internalServerException
|
470
|
+
# end
|
471
|
+
# output_stream.on_model_stream_error_exception_event do |event|
|
472
|
+
# event # => Aws::BedrockRuntime::Types::modelStreamErrorException
|
473
|
+
# end
|
474
|
+
# output_stream.on_validation_exception_event do |event|
|
475
|
+
# event # => Aws::BedrockRuntime::Types::validationException
|
476
|
+
# end
|
477
|
+
# output_stream.on_throttling_exception_event do |event|
|
478
|
+
# event # => Aws::BedrockRuntime::Types::throttlingException
|
479
|
+
# end
|
480
|
+
# output_stream.on_model_timeout_exception_event do |event|
|
481
|
+
# event # => Aws::BedrockRuntime::Types::modelTimeoutException
|
482
|
+
# end
|
483
|
+
# output_stream.on_service_unavailable_exception_event do |event|
|
484
|
+
# event # => Aws::BedrockRuntime::Types::serviceUnavailableException
|
485
|
+
# end
|
486
|
+
# output_stream.on_error_event do |event|
|
487
|
+
# # catch unmodeled error event in the stream
|
488
|
+
# raise event
|
489
|
+
# # => Aws::Errors::EventError
|
490
|
+
# # event.event_type => :error
|
491
|
+
# # event.error_code => String
|
492
|
+
# # event.error_message => String
|
493
|
+
# end
|
494
|
+
#
|
495
|
+
# async_resp = client.invoke_model_with_bidirectional_stream (
|
496
|
+
# # params input
|
497
|
+
# input_event_stream_handler: input_stream
|
498
|
+
# output_event_stream_handler: output_stream
|
499
|
+
# )
|
500
|
+
#
|
501
|
+
# resp = async_resp.join!
|
502
|
+
#
|
503
|
+
# You can also iterate through events after the response is complete.
|
504
|
+
#
|
505
|
+
# Events are available at resp.body # => Enumerator
|
506
|
+
#
|
507
|
+
# @example Request syntax with placeholder values
|
508
|
+
#
|
509
|
+
# async_resp = async_client.invoke_model_with_bidirectional_stream({
|
510
|
+
# model_id: "InvokeModelIdentifier", # required
|
511
|
+
# input_event_stream_hander: EventStreams::InvokeModelWithBidirectionalStreamInput.new,
|
512
|
+
# })
|
513
|
+
# # => Seahorse::Client::AsyncResponse
|
514
|
+
# async_resp.wait
|
515
|
+
# # => Seahorse::Client::Response
|
516
|
+
# # Or use async_resp.join!
|
517
|
+
#
|
518
|
+
# @example Response structure
|
519
|
+
#
|
520
|
+
# All events are available at resp.body:
|
521
|
+
# resp.body #=> Enumerator
|
522
|
+
# resp.body.event_types #=> [:chunk, :internal_server_exception, :model_stream_error_exception, :validation_exception, :throttling_exception, :model_timeout_exception, :service_unavailable_exception]
|
523
|
+
#
|
524
|
+
# For :chunk event available at #on_chunk_event callback and response eventstream enumerator:
|
525
|
+
# event.bytes #=> String
|
526
|
+
#
|
527
|
+
# For :internal_server_exception event available at #on_internal_server_exception_event callback and response eventstream enumerator:
|
528
|
+
# event.message #=> String
|
529
|
+
#
|
530
|
+
# For :model_stream_error_exception event available at #on_model_stream_error_exception_event callback and response eventstream enumerator:
|
531
|
+
# event.message #=> String
|
532
|
+
# event.original_status_code #=> Integer
|
533
|
+
# event.original_message #=> String
|
534
|
+
#
|
535
|
+
# For :validation_exception event available at #on_validation_exception_event callback and response eventstream enumerator:
|
536
|
+
# event.message #=> String
|
537
|
+
#
|
538
|
+
# For :throttling_exception event available at #on_throttling_exception_event callback and response eventstream enumerator:
|
539
|
+
# event.message #=> String
|
540
|
+
#
|
541
|
+
# For :model_timeout_exception event available at #on_model_timeout_exception_event callback and response eventstream enumerator:
|
542
|
+
# event.message #=> String
|
543
|
+
#
|
544
|
+
# For :service_unavailable_exception event available at #on_service_unavailable_exception_event callback and response eventstream enumerator:
|
545
|
+
# event.message #=> String
|
546
|
+
#
|
547
|
+
# @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/InvokeModelWithBidirectionalStream AWS API Documentation
|
548
|
+
#
|
549
|
+
# @overload invoke_model_with_bidirectional_stream(params = {})
|
550
|
+
# @param [Hash] params ({})
|
551
|
+
def invoke_model_with_bidirectional_stream(params = {}, options = {}, &block)
|
552
|
+
params = params.dup
|
553
|
+
input_event_stream_handler = _event_stream_handler(
|
554
|
+
:input,
|
555
|
+
params.delete(:input_event_stream_handler),
|
556
|
+
EventStreams::InvokeModelWithBidirectionalStreamInput
|
557
|
+
)
|
558
|
+
output_event_stream_handler = _event_stream_handler(
|
559
|
+
:output,
|
560
|
+
params.delete(:output_event_stream_handler) || params.delete(:event_stream_handler),
|
561
|
+
EventStreams::InvokeModelWithBidirectionalStreamOutput
|
562
|
+
)
|
563
|
+
|
564
|
+
yield(output_event_stream_handler) if block_given?
|
565
|
+
|
566
|
+
req = build_request(:invoke_model_with_bidirectional_stream, params)
|
567
|
+
|
568
|
+
req.context[:input_event_stream_handler] = input_event_stream_handler
|
569
|
+
req.handlers.add(Aws::Binary::EncodeHandler, priority: 55)
|
570
|
+
req.context[:output_event_stream_handler] = output_event_stream_handler
|
571
|
+
req.handlers.add(Aws::Binary::DecodeHandler, priority: 55)
|
572
|
+
|
573
|
+
req.send_request(options, &block)
|
574
|
+
end
|
575
|
+
|
576
|
+
# @!endgroup
|
577
|
+
|
578
|
+
# @param params ({})
|
579
|
+
# @api private
|
580
|
+
def build_request(operation_name, params = {})
|
581
|
+
handlers = @handlers.for(operation_name)
|
582
|
+
tracer = config.telemetry_provider.tracer_provider.tracer(
|
583
|
+
Aws::Telemetry.module_to_tracer_name('Aws::BedrockRuntime')
|
584
|
+
)
|
585
|
+
context = Seahorse::Client::RequestContext.new(
|
586
|
+
operation_name: operation_name,
|
587
|
+
operation: config.api.operation(operation_name),
|
588
|
+
client: self,
|
589
|
+
params: params,
|
590
|
+
http_response: Seahorse::Client::Http::AsyncResponse.new,
|
591
|
+
config: config,
|
592
|
+
tracer: tracer
|
593
|
+
)
|
594
|
+
context[:gem_name] = 'aws-sdk-bedrockruntime'
|
595
|
+
context[:gem_version] = '1.45.0'
|
596
|
+
Seahorse::Client::Request.new(handlers, context)
|
597
|
+
end
|
598
|
+
|
599
|
+
private
|
600
|
+
|
601
|
+
def _event_stream_handler(type, handler, event_stream_class)
|
602
|
+
case handler
|
603
|
+
when event_stream_class then handler
|
604
|
+
when Proc then event_stream_class.new.tap(&handler)
|
605
|
+
when nil then event_stream_class.new
|
606
|
+
else
|
607
|
+
msg = "expected #{type}_event_stream_handler to be a block or "\
|
608
|
+
"instance of Aws::BedrockRuntime::#{event_stream_class}"\
|
609
|
+
", got `#{handler.inspect}` instead"
|
610
|
+
raise ArgumentError, msg
|
611
|
+
end
|
612
|
+
end
|
613
|
+
|
614
|
+
class << self
|
615
|
+
|
616
|
+
# @api private
|
617
|
+
attr_reader :identifier
|
618
|
+
|
619
|
+
# @api private
|
620
|
+
def errors_module
|
621
|
+
Errors
|
622
|
+
end
|
623
|
+
|
624
|
+
end
|
625
|
+
end
|
626
|
+
end
|