aws-sdk-bedrockruntime 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +8 -0
- data/LICENSE.txt +202 -0
- data/VERSION +1 -0
- data/lib/aws-sdk-bedrockruntime/client.rb +717 -0
- data/lib/aws-sdk-bedrockruntime/client_api.rb +166 -0
- data/lib/aws-sdk-bedrockruntime/customizations.rb +0 -0
- data/lib/aws-sdk-bedrockruntime/endpoint_parameters.rb +66 -0
- data/lib/aws-sdk-bedrockruntime/endpoint_provider.rb +54 -0
- data/lib/aws-sdk-bedrockruntime/endpoints.rb +44 -0
- data/lib/aws-sdk-bedrockruntime/errors.rb +218 -0
- data/lib/aws-sdk-bedrockruntime/event_streams.rb +69 -0
- data/lib/aws-sdk-bedrockruntime/plugins/endpoints.rb +72 -0
- data/lib/aws-sdk-bedrockruntime/resource.rb +26 -0
- data/lib/aws-sdk-bedrockruntime/types.rb +321 -0
- data/lib/aws-sdk-bedrockruntime.rb +58 -0
- metadata +95 -0
@@ -0,0 +1,717 @@
|
|
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
|
+
require 'seahorse/client/plugins/content_length.rb'
|
11
|
+
require 'aws-sdk-core/plugins/credentials_configuration.rb'
|
12
|
+
require 'aws-sdk-core/plugins/logging.rb'
|
13
|
+
require 'aws-sdk-core/plugins/param_converter.rb'
|
14
|
+
require 'aws-sdk-core/plugins/param_validator.rb'
|
15
|
+
require 'aws-sdk-core/plugins/user_agent.rb'
|
16
|
+
require 'aws-sdk-core/plugins/helpful_socket_errors.rb'
|
17
|
+
require 'aws-sdk-core/plugins/retry_errors.rb'
|
18
|
+
require 'aws-sdk-core/plugins/global_configuration.rb'
|
19
|
+
require 'aws-sdk-core/plugins/regional_endpoint.rb'
|
20
|
+
require 'aws-sdk-core/plugins/endpoint_discovery.rb'
|
21
|
+
require 'aws-sdk-core/plugins/endpoint_pattern.rb'
|
22
|
+
require 'aws-sdk-core/plugins/response_paging.rb'
|
23
|
+
require 'aws-sdk-core/plugins/stub_responses.rb'
|
24
|
+
require 'aws-sdk-core/plugins/idempotency_token.rb'
|
25
|
+
require 'aws-sdk-core/plugins/jsonvalue_converter.rb'
|
26
|
+
require 'aws-sdk-core/plugins/client_metrics_plugin.rb'
|
27
|
+
require 'aws-sdk-core/plugins/client_metrics_send_plugin.rb'
|
28
|
+
require 'aws-sdk-core/plugins/transfer_encoding.rb'
|
29
|
+
require 'aws-sdk-core/plugins/http_checksum.rb'
|
30
|
+
require 'aws-sdk-core/plugins/checksum_algorithm.rb'
|
31
|
+
require 'aws-sdk-core/plugins/request_compression.rb'
|
32
|
+
require 'aws-sdk-core/plugins/defaults_mode.rb'
|
33
|
+
require 'aws-sdk-core/plugins/recursion_detection.rb'
|
34
|
+
require 'aws-sdk-core/plugins/sign.rb'
|
35
|
+
require 'aws-sdk-core/plugins/protocols/rest_json.rb'
|
36
|
+
require 'aws-sdk-core/plugins/event_stream_configuration.rb'
|
37
|
+
|
38
|
+
Aws::Plugins::GlobalConfiguration.add_identifier(:bedrockruntime)
|
39
|
+
|
40
|
+
module Aws::BedrockRuntime
|
41
|
+
# An API client for BedrockRuntime. To construct a client, you need to configure a `:region` and `:credentials`.
|
42
|
+
#
|
43
|
+
# client = Aws::BedrockRuntime::Client.new(
|
44
|
+
# region: region_name,
|
45
|
+
# credentials: credentials,
|
46
|
+
# # ...
|
47
|
+
# )
|
48
|
+
#
|
49
|
+
# For details on configuring region and credentials see
|
50
|
+
# the [developer guide](/sdk-for-ruby/v3/developer-guide/setup-config.html).
|
51
|
+
#
|
52
|
+
# See {#initialize} for a full list of supported configuration options.
|
53
|
+
class Client < Seahorse::Client::Base
|
54
|
+
|
55
|
+
include Aws::ClientStubs
|
56
|
+
|
57
|
+
@identifier = :bedrockruntime
|
58
|
+
|
59
|
+
set_api(ClientApi::API)
|
60
|
+
|
61
|
+
add_plugin(Seahorse::Client::Plugins::ContentLength)
|
62
|
+
add_plugin(Aws::Plugins::CredentialsConfiguration)
|
63
|
+
add_plugin(Aws::Plugins::Logging)
|
64
|
+
add_plugin(Aws::Plugins::ParamConverter)
|
65
|
+
add_plugin(Aws::Plugins::ParamValidator)
|
66
|
+
add_plugin(Aws::Plugins::UserAgent)
|
67
|
+
add_plugin(Aws::Plugins::HelpfulSocketErrors)
|
68
|
+
add_plugin(Aws::Plugins::RetryErrors)
|
69
|
+
add_plugin(Aws::Plugins::GlobalConfiguration)
|
70
|
+
add_plugin(Aws::Plugins::RegionalEndpoint)
|
71
|
+
add_plugin(Aws::Plugins::EndpointDiscovery)
|
72
|
+
add_plugin(Aws::Plugins::EndpointPattern)
|
73
|
+
add_plugin(Aws::Plugins::ResponsePaging)
|
74
|
+
add_plugin(Aws::Plugins::StubResponses)
|
75
|
+
add_plugin(Aws::Plugins::IdempotencyToken)
|
76
|
+
add_plugin(Aws::Plugins::JsonvalueConverter)
|
77
|
+
add_plugin(Aws::Plugins::ClientMetricsPlugin)
|
78
|
+
add_plugin(Aws::Plugins::ClientMetricsSendPlugin)
|
79
|
+
add_plugin(Aws::Plugins::TransferEncoding)
|
80
|
+
add_plugin(Aws::Plugins::HttpChecksum)
|
81
|
+
add_plugin(Aws::Plugins::ChecksumAlgorithm)
|
82
|
+
add_plugin(Aws::Plugins::RequestCompression)
|
83
|
+
add_plugin(Aws::Plugins::DefaultsMode)
|
84
|
+
add_plugin(Aws::Plugins::RecursionDetection)
|
85
|
+
add_plugin(Aws::Plugins::Sign)
|
86
|
+
add_plugin(Aws::Plugins::Protocols::RestJson)
|
87
|
+
add_plugin(Aws::Plugins::EventStreamConfiguration)
|
88
|
+
add_plugin(Aws::BedrockRuntime::Plugins::Endpoints)
|
89
|
+
|
90
|
+
# @overload initialize(options)
|
91
|
+
# @param [Hash] options
|
92
|
+
# @option options [required, Aws::CredentialProvider] :credentials
|
93
|
+
# Your AWS credentials. This can be an instance of any one of the
|
94
|
+
# following classes:
|
95
|
+
#
|
96
|
+
# * `Aws::Credentials` - Used for configuring static, non-refreshing
|
97
|
+
# credentials.
|
98
|
+
#
|
99
|
+
# * `Aws::SharedCredentials` - Used for loading static credentials from a
|
100
|
+
# shared file, such as `~/.aws/config`.
|
101
|
+
#
|
102
|
+
# * `Aws::AssumeRoleCredentials` - Used when you need to assume a role.
|
103
|
+
#
|
104
|
+
# * `Aws::AssumeRoleWebIdentityCredentials` - Used when you need to
|
105
|
+
# assume a role after providing credentials via the web.
|
106
|
+
#
|
107
|
+
# * `Aws::SSOCredentials` - Used for loading credentials from AWS SSO using an
|
108
|
+
# access token generated from `aws login`.
|
109
|
+
#
|
110
|
+
# * `Aws::ProcessCredentials` - Used for loading credentials from a
|
111
|
+
# process that outputs to stdout.
|
112
|
+
#
|
113
|
+
# * `Aws::InstanceProfileCredentials` - Used for loading credentials
|
114
|
+
# from an EC2 IMDS on an EC2 instance.
|
115
|
+
#
|
116
|
+
# * `Aws::ECSCredentials` - Used for loading credentials from
|
117
|
+
# instances running in ECS.
|
118
|
+
#
|
119
|
+
# * `Aws::CognitoIdentityCredentials` - Used for loading credentials
|
120
|
+
# from the Cognito Identity service.
|
121
|
+
#
|
122
|
+
# When `:credentials` are not configured directly, the following
|
123
|
+
# locations will be searched for credentials:
|
124
|
+
#
|
125
|
+
# * `Aws.config[:credentials]`
|
126
|
+
# * The `:access_key_id`, `:secret_access_key`, and `:session_token` options.
|
127
|
+
# * ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']
|
128
|
+
# * `~/.aws/credentials`
|
129
|
+
# * `~/.aws/config`
|
130
|
+
# * EC2/ECS IMDS instance profile - When used by default, the timeouts
|
131
|
+
# are very aggressive. Construct and pass an instance of
|
132
|
+
# `Aws::InstanceProfileCredentails` or `Aws::ECSCredentials` to
|
133
|
+
# enable retries and extended timeouts. Instance profile credential
|
134
|
+
# fetching can be disabled by setting ENV['AWS_EC2_METADATA_DISABLED']
|
135
|
+
# to true.
|
136
|
+
#
|
137
|
+
# @option options [required, String] :region
|
138
|
+
# The AWS region to connect to. The configured `:region` is
|
139
|
+
# used to determine the service `:endpoint`. When not passed,
|
140
|
+
# a default `:region` is searched for in the following locations:
|
141
|
+
#
|
142
|
+
# * `Aws.config[:region]`
|
143
|
+
# * `ENV['AWS_REGION']`
|
144
|
+
# * `ENV['AMAZON_REGION']`
|
145
|
+
# * `ENV['AWS_DEFAULT_REGION']`
|
146
|
+
# * `~/.aws/credentials`
|
147
|
+
# * `~/.aws/config`
|
148
|
+
#
|
149
|
+
# @option options [String] :access_key_id
|
150
|
+
#
|
151
|
+
# @option options [Boolean] :active_endpoint_cache (false)
|
152
|
+
# When set to `true`, a thread polling for endpoints will be running in
|
153
|
+
# the background every 60 secs (default). Defaults to `false`.
|
154
|
+
#
|
155
|
+
# @option options [Boolean] :adaptive_retry_wait_to_fill (true)
|
156
|
+
# Used only in `adaptive` retry mode. When true, the request will sleep
|
157
|
+
# until there is sufficent client side capacity to retry the request.
|
158
|
+
# When false, the request will raise a `RetryCapacityNotAvailableError` and will
|
159
|
+
# not retry instead of sleeping.
|
160
|
+
#
|
161
|
+
# @option options [Boolean] :client_side_monitoring (false)
|
162
|
+
# When `true`, client-side metrics will be collected for all API requests from
|
163
|
+
# this client.
|
164
|
+
#
|
165
|
+
# @option options [String] :client_side_monitoring_client_id ("")
|
166
|
+
# Allows you to provide an identifier for this client which will be attached to
|
167
|
+
# all generated client side metrics. Defaults to an empty string.
|
168
|
+
#
|
169
|
+
# @option options [String] :client_side_monitoring_host ("127.0.0.1")
|
170
|
+
# Allows you to specify the DNS hostname or IPv4 or IPv6 address that the client
|
171
|
+
# side monitoring agent is running on, where client metrics will be published via UDP.
|
172
|
+
#
|
173
|
+
# @option options [Integer] :client_side_monitoring_port (31000)
|
174
|
+
# Required for publishing client metrics. The port that the client side monitoring
|
175
|
+
# agent is running on, where client metrics will be published via UDP.
|
176
|
+
#
|
177
|
+
# @option options [Aws::ClientSideMonitoring::Publisher] :client_side_monitoring_publisher (Aws::ClientSideMonitoring::Publisher)
|
178
|
+
# Allows you to provide a custom client-side monitoring publisher class. By default,
|
179
|
+
# will use the Client Side Monitoring Agent Publisher.
|
180
|
+
#
|
181
|
+
# @option options [Boolean] :convert_params (true)
|
182
|
+
# When `true`, an attempt is made to coerce request parameters into
|
183
|
+
# the required types.
|
184
|
+
#
|
185
|
+
# @option options [Boolean] :correct_clock_skew (true)
|
186
|
+
# Used only in `standard` and adaptive retry modes. Specifies whether to apply
|
187
|
+
# a clock skew correction and retry requests with skewed client clocks.
|
188
|
+
#
|
189
|
+
# @option options [String] :defaults_mode ("legacy")
|
190
|
+
# See {Aws::DefaultsModeConfiguration} for a list of the
|
191
|
+
# accepted modes and the configuration defaults that are included.
|
192
|
+
#
|
193
|
+
# @option options [Boolean] :disable_host_prefix_injection (false)
|
194
|
+
# Set to true to disable SDK automatically adding host prefix
|
195
|
+
# to default service endpoint when available.
|
196
|
+
#
|
197
|
+
# @option options [Boolean] :disable_request_compression (false)
|
198
|
+
# When set to 'true' the request body will not be compressed
|
199
|
+
# for supported operations.
|
200
|
+
#
|
201
|
+
# @option options [String] :endpoint
|
202
|
+
# The client endpoint is normally constructed from the `:region`
|
203
|
+
# option. You should only configure an `:endpoint` when connecting
|
204
|
+
# to test or custom endpoints. This should be a valid HTTP(S) URI.
|
205
|
+
#
|
206
|
+
# @option options [Integer] :endpoint_cache_max_entries (1000)
|
207
|
+
# Used for the maximum size limit of the LRU cache storing endpoints data
|
208
|
+
# for endpoint discovery enabled operations. Defaults to 1000.
|
209
|
+
#
|
210
|
+
# @option options [Integer] :endpoint_cache_max_threads (10)
|
211
|
+
# Used for the maximum threads in use for polling endpoints to be cached, defaults to 10.
|
212
|
+
#
|
213
|
+
# @option options [Integer] :endpoint_cache_poll_interval (60)
|
214
|
+
# When :endpoint_discovery and :active_endpoint_cache is enabled,
|
215
|
+
# Use this option to config the time interval in seconds for making
|
216
|
+
# requests fetching endpoints information. Defaults to 60 sec.
|
217
|
+
#
|
218
|
+
# @option options [Boolean] :endpoint_discovery (false)
|
219
|
+
# When set to `true`, endpoint discovery will be enabled for operations when available.
|
220
|
+
#
|
221
|
+
# @option options [Proc] :event_stream_handler
|
222
|
+
# 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.
|
223
|
+
#
|
224
|
+
# @option options [Boolean] :ignore_configured_endpoint_urls
|
225
|
+
# Setting to true disables use of endpoint URLs provided via environment
|
226
|
+
# variables and the shared configuration file.
|
227
|
+
#
|
228
|
+
# @option options [Proc] :input_event_stream_handler
|
229
|
+
# When an EventStream or Proc object is provided, it can be used for sending events for the event stream.
|
230
|
+
#
|
231
|
+
# @option options [Aws::Log::Formatter] :log_formatter (Aws::Log::Formatter.default)
|
232
|
+
# The log formatter.
|
233
|
+
#
|
234
|
+
# @option options [Symbol] :log_level (:info)
|
235
|
+
# The log level to send messages to the `:logger` at.
|
236
|
+
#
|
237
|
+
# @option options [Logger] :logger
|
238
|
+
# The Logger instance to send log messages to. If this option
|
239
|
+
# is not set, logging will be disabled.
|
240
|
+
#
|
241
|
+
# @option options [Integer] :max_attempts (3)
|
242
|
+
# An integer representing the maximum number attempts that will be made for
|
243
|
+
# a single request, including the initial attempt. For example,
|
244
|
+
# setting this value to 5 will result in a request being retried up to
|
245
|
+
# 4 times. Used in `standard` and `adaptive` retry modes.
|
246
|
+
#
|
247
|
+
# @option options [Proc] :output_event_stream_handler
|
248
|
+
# 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.
|
249
|
+
#
|
250
|
+
# @option options [String] :profile ("default")
|
251
|
+
# Used when loading credentials from the shared credentials file
|
252
|
+
# at HOME/.aws/credentials. When not specified, 'default' is used.
|
253
|
+
#
|
254
|
+
# @option options [Integer] :request_min_compression_size_bytes (10240)
|
255
|
+
# The minimum size in bytes that triggers compression for request
|
256
|
+
# bodies. The value must be non-negative integer value between 0
|
257
|
+
# and 10485780 bytes inclusive.
|
258
|
+
#
|
259
|
+
# @option options [Proc] :retry_backoff
|
260
|
+
# A proc or lambda used for backoff. Defaults to 2**retries * retry_base_delay.
|
261
|
+
# This option is only used in the `legacy` retry mode.
|
262
|
+
#
|
263
|
+
# @option options [Float] :retry_base_delay (0.3)
|
264
|
+
# The base delay in seconds used by the default backoff function. This option
|
265
|
+
# is only used in the `legacy` retry mode.
|
266
|
+
#
|
267
|
+
# @option options [Symbol] :retry_jitter (:none)
|
268
|
+
# A delay randomiser function used by the default backoff function.
|
269
|
+
# Some predefined functions can be referenced by name - :none, :equal, :full,
|
270
|
+
# otherwise a Proc that takes and returns a number. This option is only used
|
271
|
+
# in the `legacy` retry mode.
|
272
|
+
#
|
273
|
+
# @see https://www.awsarchitectureblog.com/2015/03/backoff.html
|
274
|
+
#
|
275
|
+
# @option options [Integer] :retry_limit (3)
|
276
|
+
# The maximum number of times to retry failed requests. Only
|
277
|
+
# ~ 500 level server errors and certain ~ 400 level client errors
|
278
|
+
# are retried. Generally, these are throttling errors, data
|
279
|
+
# checksum errors, networking errors, timeout errors, auth errors,
|
280
|
+
# endpoint discovery, and errors from expired credentials.
|
281
|
+
# This option is only used in the `legacy` retry mode.
|
282
|
+
#
|
283
|
+
# @option options [Integer] :retry_max_delay (0)
|
284
|
+
# The maximum number of seconds to delay between retries (0 for no limit)
|
285
|
+
# used by the default backoff function. This option is only used in the
|
286
|
+
# `legacy` retry mode.
|
287
|
+
#
|
288
|
+
# @option options [String] :retry_mode ("legacy")
|
289
|
+
# Specifies which retry algorithm to use. Values are:
|
290
|
+
#
|
291
|
+
# * `legacy` - The pre-existing retry behavior. This is default value if
|
292
|
+
# no retry mode is provided.
|
293
|
+
#
|
294
|
+
# * `standard` - A standardized set of retry rules across the AWS SDKs.
|
295
|
+
# This includes support for retry quotas, which limit the number of
|
296
|
+
# unsuccessful retries a client can make.
|
297
|
+
#
|
298
|
+
# * `adaptive` - An experimental retry mode that includes all the
|
299
|
+
# functionality of `standard` mode along with automatic client side
|
300
|
+
# throttling. This is a provisional mode that may change behavior
|
301
|
+
# in the future.
|
302
|
+
#
|
303
|
+
#
|
304
|
+
# @option options [String] :sdk_ua_app_id
|
305
|
+
# A unique and opaque application ID that is appended to the
|
306
|
+
# User-Agent header as app/<sdk_ua_app_id>. It should have a
|
307
|
+
# maximum length of 50.
|
308
|
+
#
|
309
|
+
# @option options [String] :secret_access_key
|
310
|
+
#
|
311
|
+
# @option options [String] :session_token
|
312
|
+
#
|
313
|
+
# @option options [Boolean] :stub_responses (false)
|
314
|
+
# Causes the client to return stubbed responses. By default
|
315
|
+
# fake responses are generated and returned. You can specify
|
316
|
+
# the response data to return or errors to raise by calling
|
317
|
+
# {ClientStubs#stub_responses}. See {ClientStubs} for more information.
|
318
|
+
#
|
319
|
+
# ** Please note ** When response stubbing is enabled, no HTTP
|
320
|
+
# requests are made, and retries are disabled.
|
321
|
+
#
|
322
|
+
# @option options [Aws::TokenProvider] :token_provider
|
323
|
+
# A Bearer Token Provider. This can be an instance of any one of the
|
324
|
+
# following classes:
|
325
|
+
#
|
326
|
+
# * `Aws::StaticTokenProvider` - Used for configuring static, non-refreshing
|
327
|
+
# tokens.
|
328
|
+
#
|
329
|
+
# * `Aws::SSOTokenProvider` - Used for loading tokens from AWS SSO using an
|
330
|
+
# access token generated from `aws login`.
|
331
|
+
#
|
332
|
+
# When `:token_provider` is not configured directly, the `Aws::TokenProviderChain`
|
333
|
+
# will be used to search for tokens configured for your profile in shared configuration files.
|
334
|
+
#
|
335
|
+
# @option options [Boolean] :use_dualstack_endpoint
|
336
|
+
# When set to `true`, dualstack enabled endpoints (with `.aws` TLD)
|
337
|
+
# will be used if available.
|
338
|
+
#
|
339
|
+
# @option options [Boolean] :use_fips_endpoint
|
340
|
+
# When set to `true`, fips compatible endpoints will be used if available.
|
341
|
+
# When a `fips` region is used, the region is normalized and this config
|
342
|
+
# is set to `true`.
|
343
|
+
#
|
344
|
+
# @option options [Boolean] :validate_params (true)
|
345
|
+
# When `true`, request parameters are validated before
|
346
|
+
# sending the request.
|
347
|
+
#
|
348
|
+
# @option options [Aws::BedrockRuntime::EndpointProvider] :endpoint_provider
|
349
|
+
# The endpoint provider used to resolve endpoints. Any object that responds to `#resolve_endpoint(parameters)` where `parameters` is a Struct similar to `Aws::BedrockRuntime::EndpointParameters`
|
350
|
+
#
|
351
|
+
# @option options [URI::HTTP,String] :http_proxy A proxy to send
|
352
|
+
# requests through. Formatted like 'http://proxy.com:123'.
|
353
|
+
#
|
354
|
+
# @option options [Float] :http_open_timeout (15) The number of
|
355
|
+
# seconds to wait when opening a HTTP session before raising a
|
356
|
+
# `Timeout::Error`.
|
357
|
+
#
|
358
|
+
# @option options [Float] :http_read_timeout (60) The default
|
359
|
+
# number of seconds to wait for response data. This value can
|
360
|
+
# safely be set per-request on the session.
|
361
|
+
#
|
362
|
+
# @option options [Float] :http_idle_timeout (5) The number of
|
363
|
+
# seconds a connection is allowed to sit idle before it is
|
364
|
+
# considered stale. Stale connections are closed and removed
|
365
|
+
# from the pool before making a request.
|
366
|
+
#
|
367
|
+
# @option options [Float] :http_continue_timeout (1) The number of
|
368
|
+
# seconds to wait for a 100-continue response before sending the
|
369
|
+
# request body. This option has no effect unless the request has
|
370
|
+
# "Expect" header set to "100-continue". Defaults to `nil` which
|
371
|
+
# disables this behaviour. This value can safely be set per
|
372
|
+
# request on the session.
|
373
|
+
#
|
374
|
+
# @option options [Float] :ssl_timeout (nil) Sets the SSL timeout
|
375
|
+
# in seconds.
|
376
|
+
#
|
377
|
+
# @option options [Boolean] :http_wire_trace (false) When `true`,
|
378
|
+
# HTTP debug output will be sent to the `:logger`.
|
379
|
+
#
|
380
|
+
# @option options [Boolean] :ssl_verify_peer (true) When `true`,
|
381
|
+
# SSL peer certificates are verified when establishing a
|
382
|
+
# connection.
|
383
|
+
#
|
384
|
+
# @option options [String] :ssl_ca_bundle Full path to the SSL
|
385
|
+
# certificate authority bundle file that should be used when
|
386
|
+
# verifying peer certificates. If you do not pass
|
387
|
+
# `:ssl_ca_bundle` or `:ssl_ca_directory` the the system default
|
388
|
+
# will be used if available.
|
389
|
+
#
|
390
|
+
# @option options [String] :ssl_ca_directory Full path of the
|
391
|
+
# directory that contains the unbundled SSL certificate
|
392
|
+
# authority files for verifying peer certificates. If you do
|
393
|
+
# not pass `:ssl_ca_bundle` or `:ssl_ca_directory` the the
|
394
|
+
# system default will be used if available.
|
395
|
+
#
|
396
|
+
def initialize(*args)
|
397
|
+
super
|
398
|
+
end
|
399
|
+
|
400
|
+
# @!group API Operations
|
401
|
+
|
402
|
+
# Invokes the specified Bedrock model to run inference using the input
|
403
|
+
# provided in the request body. You use InvokeModel to run inference for
|
404
|
+
# text models, image models, and embedding models.
|
405
|
+
#
|
406
|
+
# For more information about invoking models, see Using the API in the
|
407
|
+
# [Bedrock User Guide][1].
|
408
|
+
#
|
409
|
+
# For example requests, see Examples (after the Errors section).
|
410
|
+
#
|
411
|
+
#
|
412
|
+
#
|
413
|
+
# [1]: https://d2eo22ngex1n9g.cloudfront.net/Documentation/BedrockUserGuide.pdf
|
414
|
+
#
|
415
|
+
# @option params [String] :accept
|
416
|
+
# The desired MIME type of the inference body in the response. The
|
417
|
+
# default value is `application/json`.
|
418
|
+
#
|
419
|
+
# @option params [required, String, StringIO, File] :body
|
420
|
+
# Input data in the format specified in the content-type request header.
|
421
|
+
# To see the format and content of this field for different models,
|
422
|
+
# refer to [Inference parameters][1].
|
423
|
+
#
|
424
|
+
#
|
425
|
+
#
|
426
|
+
# [1]: https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html
|
427
|
+
#
|
428
|
+
# @option params [String] :content_type
|
429
|
+
# The MIME type of the input data in the request. The default value is
|
430
|
+
# `application/json`.
|
431
|
+
#
|
432
|
+
# @option params [required, String] :model_id
|
433
|
+
# Identifier of the model.
|
434
|
+
#
|
435
|
+
# @return [Types::InvokeModelResponse] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
|
436
|
+
#
|
437
|
+
# * {Types::InvokeModelResponse#body #body} => String
|
438
|
+
# * {Types::InvokeModelResponse#content_type #content_type} => String
|
439
|
+
#
|
440
|
+
# @example Request syntax with placeholder values
|
441
|
+
#
|
442
|
+
# resp = client.invoke_model({
|
443
|
+
# accept: "MimeType",
|
444
|
+
# body: "data", # required
|
445
|
+
# content_type: "MimeType",
|
446
|
+
# model_id: "InvokeModelIdentifier", # required
|
447
|
+
# })
|
448
|
+
#
|
449
|
+
# @example Response structure
|
450
|
+
#
|
451
|
+
# resp.body #=> String
|
452
|
+
# resp.content_type #=> String
|
453
|
+
#
|
454
|
+
# @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/InvokeModel AWS API Documentation
|
455
|
+
#
|
456
|
+
# @overload invoke_model(params = {})
|
457
|
+
# @param [Hash] params ({})
|
458
|
+
def invoke_model(params = {}, options = {})
|
459
|
+
req = build_request(:invoke_model, params)
|
460
|
+
req.send_request(options)
|
461
|
+
end
|
462
|
+
|
463
|
+
# Invoke the specified Bedrock model to run inference using the input
|
464
|
+
# provided. Return the response in a stream.
|
465
|
+
#
|
466
|
+
# For more information about invoking models, see Using the API in the
|
467
|
+
# [Bedrock User Guide][1].
|
468
|
+
#
|
469
|
+
# For an example request and response, see Examples (after the Errors
|
470
|
+
# section).
|
471
|
+
#
|
472
|
+
#
|
473
|
+
#
|
474
|
+
# [1]: https://d2eo22ngex1n9g.cloudfront.net/Documentation/BedrockUserGuide.pdf
|
475
|
+
#
|
476
|
+
# @option params [String] :accept
|
477
|
+
# The desired MIME type of the inference body in the response. The
|
478
|
+
# default value is `application/json`.
|
479
|
+
#
|
480
|
+
# @option params [required, String, StringIO, File] :body
|
481
|
+
# Inference input in the format specified by the content-type. To see
|
482
|
+
# the format and content of this field for different models, refer to
|
483
|
+
# [Inference parameters][1].
|
484
|
+
#
|
485
|
+
#
|
486
|
+
#
|
487
|
+
# [1]: https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html
|
488
|
+
#
|
489
|
+
# @option params [String] :content_type
|
490
|
+
# The MIME type of the input data in the request. The default value is
|
491
|
+
# `application/json`.
|
492
|
+
#
|
493
|
+
# @option params [required, String] :model_id
|
494
|
+
# Id of the model to invoke using the streaming request.
|
495
|
+
#
|
496
|
+
# @return [Types::InvokeModelWithResponseStreamResponse] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
|
497
|
+
#
|
498
|
+
# * {Types::InvokeModelWithResponseStreamResponse#body #body} => Types::ResponseStream
|
499
|
+
# * {Types::InvokeModelWithResponseStreamResponse#content_type #content_type} => String
|
500
|
+
#
|
501
|
+
# @example EventStream Operation Example
|
502
|
+
#
|
503
|
+
# You can process event once it arrives immediately, or wait until
|
504
|
+
# full response complete and iterate through eventstream enumerator.
|
505
|
+
#
|
506
|
+
# To interact with event immediately, you need to register #invoke_model_with_response_stream
|
507
|
+
# with callbacks, callbacks can be register for specifc events or for all events,
|
508
|
+
# callback for errors in the event stream is also available for register.
|
509
|
+
#
|
510
|
+
# Callbacks can be passed in by `:event_stream_handler` option or within block
|
511
|
+
# statement attached to #invoke_model_with_response_stream call directly. Hybrid pattern of both
|
512
|
+
# is also supported.
|
513
|
+
#
|
514
|
+
# `:event_stream_handler` option takes in either Proc object or
|
515
|
+
# Aws::BedrockRuntime::EventStreams::ResponseStream object.
|
516
|
+
#
|
517
|
+
# Usage pattern a): callbacks with a block attached to #invoke_model_with_response_stream
|
518
|
+
# Example for registering callbacks for all event types and error event
|
519
|
+
#
|
520
|
+
# client.invoke_model_with_response_stream( # params input# ) do |stream|
|
521
|
+
# stream.on_error_event do |event|
|
522
|
+
# # catch unmodeled error event in the stream
|
523
|
+
# raise event
|
524
|
+
# # => Aws::Errors::EventError
|
525
|
+
# # event.event_type => :error
|
526
|
+
# # event.error_code => String
|
527
|
+
# # event.error_message => String
|
528
|
+
# end
|
529
|
+
#
|
530
|
+
# stream.on_event do |event|
|
531
|
+
# # process all events arrive
|
532
|
+
# puts event.event_type
|
533
|
+
# ...
|
534
|
+
# end
|
535
|
+
#
|
536
|
+
# end
|
537
|
+
#
|
538
|
+
# Usage pattern b): pass in `:event_stream_handler` for #invoke_model_with_response_stream
|
539
|
+
#
|
540
|
+
# 1) create a Aws::BedrockRuntime::EventStreams::ResponseStream object
|
541
|
+
# Example for registering callbacks with specific events
|
542
|
+
#
|
543
|
+
# handler = Aws::BedrockRuntime::EventStreams::ResponseStream.new
|
544
|
+
# handler.on_chunk_event do |event|
|
545
|
+
# event # => Aws::BedrockRuntime::Types::chunk
|
546
|
+
# end
|
547
|
+
# handler.on_internal_server_exception_event do |event|
|
548
|
+
# event # => Aws::BedrockRuntime::Types::internalServerException
|
549
|
+
# end
|
550
|
+
# handler.on_model_stream_error_exception_event do |event|
|
551
|
+
# event # => Aws::BedrockRuntime::Types::modelStreamErrorException
|
552
|
+
# end
|
553
|
+
# handler.on_throttling_exception_event do |event|
|
554
|
+
# event # => Aws::BedrockRuntime::Types::throttlingException
|
555
|
+
# end
|
556
|
+
# handler.on_validation_exception_event do |event|
|
557
|
+
# event # => Aws::BedrockRuntime::Types::validationException
|
558
|
+
# end
|
559
|
+
#
|
560
|
+
# client.invoke_model_with_response_stream( # params input #, event_stream_handler: handler)
|
561
|
+
#
|
562
|
+
# 2) use a Ruby Proc object
|
563
|
+
# Example for registering callbacks with specific events
|
564
|
+
#
|
565
|
+
# handler = Proc.new do |stream|
|
566
|
+
# stream.on_chunk_event do |event|
|
567
|
+
# event # => Aws::BedrockRuntime::Types::chunk
|
568
|
+
# end
|
569
|
+
# stream.on_internal_server_exception_event do |event|
|
570
|
+
# event # => Aws::BedrockRuntime::Types::internalServerException
|
571
|
+
# end
|
572
|
+
# stream.on_model_stream_error_exception_event do |event|
|
573
|
+
# event # => Aws::BedrockRuntime::Types::modelStreamErrorException
|
574
|
+
# end
|
575
|
+
# stream.on_throttling_exception_event do |event|
|
576
|
+
# event # => Aws::BedrockRuntime::Types::throttlingException
|
577
|
+
# end
|
578
|
+
# stream.on_validation_exception_event do |event|
|
579
|
+
# event # => Aws::BedrockRuntime::Types::validationException
|
580
|
+
# end
|
581
|
+
# end
|
582
|
+
#
|
583
|
+
# client.invoke_model_with_response_stream( # params input #, event_stream_handler: handler)
|
584
|
+
#
|
585
|
+
# Usage pattern c): hybird pattern of a) and b)
|
586
|
+
#
|
587
|
+
# handler = Aws::BedrockRuntime::EventStreams::ResponseStream.new
|
588
|
+
# handler.on_chunk_event do |event|
|
589
|
+
# event # => Aws::BedrockRuntime::Types::chunk
|
590
|
+
# end
|
591
|
+
# handler.on_internal_server_exception_event do |event|
|
592
|
+
# event # => Aws::BedrockRuntime::Types::internalServerException
|
593
|
+
# end
|
594
|
+
# handler.on_model_stream_error_exception_event do |event|
|
595
|
+
# event # => Aws::BedrockRuntime::Types::modelStreamErrorException
|
596
|
+
# end
|
597
|
+
# handler.on_throttling_exception_event do |event|
|
598
|
+
# event # => Aws::BedrockRuntime::Types::throttlingException
|
599
|
+
# end
|
600
|
+
# handler.on_validation_exception_event do |event|
|
601
|
+
# event # => Aws::BedrockRuntime::Types::validationException
|
602
|
+
# end
|
603
|
+
#
|
604
|
+
# client.invoke_model_with_response_stream( # params input #, event_stream_handler: handler) do |stream|
|
605
|
+
# stream.on_error_event do |event|
|
606
|
+
# # catch unmodeled error event in the stream
|
607
|
+
# raise event
|
608
|
+
# # => Aws::Errors::EventError
|
609
|
+
# # event.event_type => :error
|
610
|
+
# # event.error_code => String
|
611
|
+
# # event.error_message => String
|
612
|
+
# end
|
613
|
+
# end
|
614
|
+
#
|
615
|
+
# Besides above usage patterns for process events when they arrive immediately, you can also
|
616
|
+
# iterate through events after response complete.
|
617
|
+
#
|
618
|
+
# Events are available at resp.body # => Enumerator
|
619
|
+
# For parameter input example, please refer to following request syntax
|
620
|
+
#
|
621
|
+
# @example Request syntax with placeholder values
|
622
|
+
#
|
623
|
+
# resp = client.invoke_model_with_response_stream({
|
624
|
+
# accept: "MimeType",
|
625
|
+
# body: "data", # required
|
626
|
+
# content_type: "MimeType",
|
627
|
+
# model_id: "InvokeModelIdentifier", # required
|
628
|
+
# })
|
629
|
+
#
|
630
|
+
# @example Response structure
|
631
|
+
#
|
632
|
+
# All events are available at resp.body:
|
633
|
+
# resp.body #=> Enumerator
|
634
|
+
# resp.body.event_types #=> [:chunk, :internal_server_exception, :model_stream_error_exception, :throttling_exception, :validation_exception]
|
635
|
+
#
|
636
|
+
# For :chunk event available at #on_chunk_event callback and response eventstream enumerator:
|
637
|
+
# event.bytes #=> String
|
638
|
+
#
|
639
|
+
# For :internal_server_exception event available at #on_internal_server_exception_event callback and response eventstream enumerator:
|
640
|
+
# event.message #=> String
|
641
|
+
#
|
642
|
+
# For :model_stream_error_exception event available at #on_model_stream_error_exception_event callback and response eventstream enumerator:
|
643
|
+
# event.message #=> String
|
644
|
+
# event.original_message #=> String
|
645
|
+
# event.original_status_code #=> Integer
|
646
|
+
#
|
647
|
+
# For :throttling_exception event available at #on_throttling_exception_event callback and response eventstream enumerator:
|
648
|
+
# event.message #=> String
|
649
|
+
#
|
650
|
+
# For :validation_exception event available at #on_validation_exception_event callback and response eventstream enumerator:
|
651
|
+
# event.message #=> String
|
652
|
+
#
|
653
|
+
# resp.content_type #=> String
|
654
|
+
#
|
655
|
+
# @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/InvokeModelWithResponseStream AWS API Documentation
|
656
|
+
#
|
657
|
+
# @overload invoke_model_with_response_stream(params = {})
|
658
|
+
# @param [Hash] params ({})
|
659
|
+
def invoke_model_with_response_stream(params = {}, options = {}, &block)
|
660
|
+
params = params.dup
|
661
|
+
event_stream_handler = case handler = params.delete(:event_stream_handler)
|
662
|
+
when EventStreams::ResponseStream then handler
|
663
|
+
when Proc then EventStreams::ResponseStream.new.tap(&handler)
|
664
|
+
when nil then EventStreams::ResponseStream.new
|
665
|
+
else
|
666
|
+
msg = "expected :event_stream_handler to be a block or "\
|
667
|
+
"instance of Aws::BedrockRuntime::EventStreams::ResponseStream"\
|
668
|
+
", got `#{handler.inspect}` instead"
|
669
|
+
raise ArgumentError, msg
|
670
|
+
end
|
671
|
+
|
672
|
+
yield(event_stream_handler) if block_given?
|
673
|
+
|
674
|
+
req = build_request(:invoke_model_with_response_stream, params)
|
675
|
+
|
676
|
+
req.context[:event_stream_handler] = event_stream_handler
|
677
|
+
req.handlers.add(Aws::Binary::DecodeHandler, priority: 95)
|
678
|
+
|
679
|
+
req.send_request(options, &block)
|
680
|
+
end
|
681
|
+
|
682
|
+
# @!endgroup
|
683
|
+
|
684
|
+
# @param params ({})
|
685
|
+
# @api private
|
686
|
+
def build_request(operation_name, params = {})
|
687
|
+
handlers = @handlers.for(operation_name)
|
688
|
+
context = Seahorse::Client::RequestContext.new(
|
689
|
+
operation_name: operation_name,
|
690
|
+
operation: config.api.operation(operation_name),
|
691
|
+
client: self,
|
692
|
+
params: params,
|
693
|
+
config: config)
|
694
|
+
context[:gem_name] = 'aws-sdk-bedrockruntime'
|
695
|
+
context[:gem_version] = '1.0.0'
|
696
|
+
Seahorse::Client::Request.new(handlers, context)
|
697
|
+
end
|
698
|
+
|
699
|
+
# @api private
|
700
|
+
# @deprecated
|
701
|
+
def waiter_names
|
702
|
+
[]
|
703
|
+
end
|
704
|
+
|
705
|
+
class << self
|
706
|
+
|
707
|
+
# @api private
|
708
|
+
attr_reader :identifier
|
709
|
+
|
710
|
+
# @api private
|
711
|
+
def errors_module
|
712
|
+
Errors
|
713
|
+
end
|
714
|
+
|
715
|
+
end
|
716
|
+
end
|
717
|
+
end
|