aws-sdk-bedrockruntime 1.42.0 → 1.44.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.
@@ -9,6 +9,29 @@
9
9
 
10
10
  module Aws::BedrockRuntime
11
11
  module EventStreams
12
+ class InvokeModelWithBidirectionalStreamInput
13
+
14
+ def initialize
15
+ @event_emitter = Aws::EventEmitter.new
16
+ end
17
+
18
+ # @option params [String, StringIO, File] :bytes
19
+ # The audio content for the bidirectional input.
20
+ #
21
+ def signal_chunk_event(params = {})
22
+ @event_emitter.emit(:chunk, params)
23
+ end
24
+
25
+ def signal_end_stream
26
+ @event_emitter.emit(:end_stream, {})
27
+ end
28
+
29
+ # @api private
30
+ # @return Aws::EventEmitter
31
+ attr_reader :event_emitter
32
+
33
+ end
34
+
12
35
  class ConverseStreamOutput
13
36
 
14
37
  def initialize
@@ -92,6 +115,70 @@ module Aws::BedrockRuntime
92
115
  # @return Aws::EventEmitter
93
116
  attr_reader :event_emitter
94
117
 
118
+ end
119
+ class InvokeModelWithBidirectionalStreamOutput
120
+
121
+ def initialize
122
+ @event_emitter = Aws::EventEmitter.new
123
+ end
124
+
125
+ def on_chunk_event(&block)
126
+ @event_emitter.on(:chunk, block) if block_given?
127
+ end
128
+
129
+ def on_internal_server_exception_event(&block)
130
+ @event_emitter.on(:internal_server_exception, block) if block_given?
131
+ end
132
+
133
+ def on_model_stream_error_exception_event(&block)
134
+ @event_emitter.on(:model_stream_error_exception, block) if block_given?
135
+ end
136
+
137
+ def on_validation_exception_event(&block)
138
+ @event_emitter.on(:validation_exception, block) if block_given?
139
+ end
140
+
141
+ def on_throttling_exception_event(&block)
142
+ @event_emitter.on(:throttling_exception, block) if block_given?
143
+ end
144
+
145
+ def on_model_timeout_exception_event(&block)
146
+ @event_emitter.on(:model_timeout_exception, block) if block_given?
147
+ end
148
+
149
+ def on_service_unavailable_exception_event(&block)
150
+ @event_emitter.on(:service_unavailable_exception, block) if block_given?
151
+ end
152
+
153
+ def on_error_event(&block)
154
+ @event_emitter.on(:error, block) if block_given?
155
+ end
156
+
157
+ def on_initial_response_event(&block)
158
+ @event_emitter.on(:initial_response, block) if block_given?
159
+ end
160
+
161
+ def on_unknown_event(&block)
162
+ @event_emitter.on(:unknown_event, block) if block_given?
163
+ end
164
+
165
+ def on_event(&block)
166
+ on_chunk_event(&block)
167
+ on_internal_server_exception_event(&block)
168
+ on_model_stream_error_exception_event(&block)
169
+ on_validation_exception_event(&block)
170
+ on_throttling_exception_event(&block)
171
+ on_model_timeout_exception_event(&block)
172
+ on_service_unavailable_exception_event(&block)
173
+ on_error_event(&block)
174
+ on_initial_response_event(&block)
175
+ on_unknown_event(&block)
176
+ end
177
+
178
+ # @api private
179
+ # @return Aws::EventEmitter
180
+ attr_reader :event_emitter
181
+
95
182
  end
96
183
  class ResponseStream
97
184
 
@@ -54,13 +54,25 @@ module Aws::BedrockRuntime
54
54
  # The content details used in the request to apply the guardrail.
55
55
  # @return [Array<Types::GuardrailContentBlock>]
56
56
  #
57
+ # @!attribute [rw] output_scope
58
+ # Specifies the scope of the output that you get in the response. Set
59
+ # to `FULL` to return the entire output, including any detected and
60
+ # non-detected entries in the response for enhanced debugging.
61
+ #
62
+ # Note that the full output scope doesn't apply to word filters or
63
+ # regex in sensitive information filters. It does apply to all other
64
+ # filtering policies, including sensitive information with filters
65
+ # that can detect personally identifiable information (PII).
66
+ # @return [String]
67
+ #
57
68
  # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/ApplyGuardrailRequest AWS API Documentation
58
69
  #
59
70
  class ApplyGuardrailRequest < Struct.new(
60
71
  :guardrail_identifier,
61
72
  :guardrail_version,
62
73
  :source,
63
- :content)
74
+ :content,
75
+ :output_scope)
64
76
  SENSITIVE = []
65
77
  include Aws::Structure
66
78
  end
@@ -73,6 +85,10 @@ module Aws::BedrockRuntime
73
85
  # The action taken in the response from the guardrail.
74
86
  # @return [String]
75
87
  #
88
+ # @!attribute [rw] action_reason
89
+ # The reason for the action taken when harmful content is detected.
90
+ # @return [String]
91
+ #
76
92
  # @!attribute [rw] outputs
77
93
  # The output details in the response from the guardrail.
78
94
  # @return [Array<Types::GuardrailOutputContent>]
@@ -90,6 +106,7 @@ module Aws::BedrockRuntime
90
106
  class ApplyGuardrailResponse < Struct.new(
91
107
  :usage,
92
108
  :action,
109
+ :action_reason,
93
110
  :outputs,
94
111
  :assessments,
95
112
  :guardrail_coverage)
@@ -208,6 +225,38 @@ module Aws::BedrockRuntime
208
225
  #
209
226
  class AutoToolChoice < Aws::EmptyStructure; end
210
227
 
228
+ # Payload content for the bidirectional input. The input is an audio
229
+ # stream.
230
+ #
231
+ # @!attribute [rw] bytes
232
+ # The audio content for the bidirectional input.
233
+ # @return [String]
234
+ #
235
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/BidirectionalInputPayloadPart AWS API Documentation
236
+ #
237
+ class BidirectionalInputPayloadPart < Struct.new(
238
+ :bytes,
239
+ :event_type)
240
+ SENSITIVE = [:bytes]
241
+ include Aws::Structure
242
+ end
243
+
244
+ # Output from the bidirectional stream. The output is speech and a text
245
+ # transcription.
246
+ #
247
+ # @!attribute [rw] bytes
248
+ # The speech output of the bidirectional stream.
249
+ # @return [String]
250
+ #
251
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/BidirectionalOutputPayloadPart AWS API Documentation
252
+ #
253
+ class BidirectionalOutputPayloadPart < Struct.new(
254
+ :bytes,
255
+ :event_type)
256
+ SENSITIVE = [:bytes]
257
+ include Aws::Structure
258
+ end
259
+
211
260
  # Defines a section of content to be cached for reuse in subsequent API
212
261
  # calls.
213
262
  #
@@ -1161,13 +1210,19 @@ module Aws::BedrockRuntime
1161
1210
  # The guardrail action.
1162
1211
  # @return [String]
1163
1212
  #
1213
+ # @!attribute [rw] detected
1214
+ # Indicates whether content that breaches the guardrail configuration
1215
+ # is detected.
1216
+ # @return [Boolean]
1217
+ #
1164
1218
  # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/GuardrailContentFilter AWS API Documentation
1165
1219
  #
1166
1220
  class GuardrailContentFilter < Struct.new(
1167
1221
  :type,
1168
1222
  :confidence,
1169
1223
  :filter_strength,
1170
- :action)
1224
+ :action,
1225
+ :detected)
1171
1226
  SENSITIVE = []
1172
1227
  include Aws::Structure
1173
1228
  end
@@ -1205,13 +1260,20 @@ module Aws::BedrockRuntime
1205
1260
  # The action performed by the guardrails contextual grounding filter.
1206
1261
  # @return [String]
1207
1262
  #
1263
+ # @!attribute [rw] detected
1264
+ # Indicates whether content that fails the contextual grounding
1265
+ # evaluation (grounding or relevance score less than the corresponding
1266
+ # threshold) was detected.
1267
+ # @return [Boolean]
1268
+ #
1208
1269
  # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/GuardrailContextualGroundingFilter AWS API Documentation
1209
1270
  #
1210
1271
  class GuardrailContextualGroundingFilter < Struct.new(
1211
1272
  :type,
1212
1273
  :threshold,
1213
1274
  :score,
1214
- :action)
1275
+ :action,
1276
+ :detected)
1215
1277
  SENSITIVE = []
1216
1278
  include Aws::Structure
1217
1279
  end
@@ -1363,11 +1425,17 @@ module Aws::BedrockRuntime
1363
1425
  # The action for the custom word.
1364
1426
  # @return [String]
1365
1427
  #
1428
+ # @!attribute [rw] detected
1429
+ # Indicates whether custom word content that breaches the guardrail
1430
+ # configuration is detected.
1431
+ # @return [Boolean]
1432
+ #
1366
1433
  # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/GuardrailCustomWord AWS API Documentation
1367
1434
  #
1368
1435
  class GuardrailCustomWord < Struct.new(
1369
1436
  :match,
1370
- :action)
1437
+ :action,
1438
+ :detected)
1371
1439
  SENSITIVE = []
1372
1440
  include Aws::Structure
1373
1441
  end
@@ -1475,12 +1543,18 @@ module Aws::BedrockRuntime
1475
1543
  # The action for the managed word.
1476
1544
  # @return [String]
1477
1545
  #
1546
+ # @!attribute [rw] detected
1547
+ # Indicates whether managed word content that breaches the guardrail
1548
+ # configuration is detected.
1549
+ # @return [Boolean]
1550
+ #
1478
1551
  # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/GuardrailManagedWord AWS API Documentation
1479
1552
  #
1480
1553
  class GuardrailManagedWord < Struct.new(
1481
1554
  :match,
1482
1555
  :type,
1483
- :action)
1556
+ :action,
1557
+ :detected)
1484
1558
  SENSITIVE = []
1485
1559
  include Aws::Structure
1486
1560
  end
@@ -1514,12 +1588,18 @@ module Aws::BedrockRuntime
1514
1588
  # The PII entity filter action.
1515
1589
  # @return [String]
1516
1590
  #
1591
+ # @!attribute [rw] detected
1592
+ # Indicates whether personally identifiable information (PII) that
1593
+ # breaches the guardrail configuration is detected.
1594
+ # @return [Boolean]
1595
+ #
1517
1596
  # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/GuardrailPiiEntityFilter AWS API Documentation
1518
1597
  #
1519
1598
  class GuardrailPiiEntityFilter < Struct.new(
1520
1599
  :match,
1521
1600
  :type,
1522
- :action)
1601
+ :action,
1602
+ :detected)
1523
1603
  SENSITIVE = []
1524
1604
  include Aws::Structure
1525
1605
  end
@@ -1542,13 +1622,19 @@ module Aws::BedrockRuntime
1542
1622
  # The region filter action.
1543
1623
  # @return [String]
1544
1624
  #
1625
+ # @!attribute [rw] detected
1626
+ # Indicates whether custom regex entities that breach the guardrail
1627
+ # configuration are detected.
1628
+ # @return [Boolean]
1629
+ #
1545
1630
  # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/GuardrailRegexFilter AWS API Documentation
1546
1631
  #
1547
1632
  class GuardrailRegexFilter < Struct.new(
1548
1633
  :name,
1549
1634
  :match,
1550
1635
  :regex,
1551
- :action)
1636
+ :action,
1637
+ :detected)
1552
1638
  SENSITIVE = []
1553
1639
  include Aws::Structure
1554
1640
  end
@@ -1658,12 +1744,18 @@ module Aws::BedrockRuntime
1658
1744
  # The action the guardrail should take when it intervenes on a topic.
1659
1745
  # @return [String]
1660
1746
  #
1747
+ # @!attribute [rw] detected
1748
+ # Indicates whether topic content that breaches the guardrail
1749
+ # configuration is detected.
1750
+ # @return [Boolean]
1751
+ #
1661
1752
  # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/GuardrailTopic AWS API Documentation
1662
1753
  #
1663
1754
  class GuardrailTopic < Struct.new(
1664
1755
  :name,
1665
1756
  :type,
1666
- :action)
1757
+ :action,
1758
+ :detected)
1667
1759
  SENSITIVE = []
1668
1760
  include Aws::Structure
1669
1761
  end
@@ -1697,12 +1789,18 @@ module Aws::BedrockRuntime
1697
1789
  # the output assessments.
1698
1790
  # @return [Hash<String,Array<Types::GuardrailAssessment>>]
1699
1791
  #
1792
+ # @!attribute [rw] action_reason
1793
+ # Provides the reason for the action taken when harmful content is
1794
+ # detected.
1795
+ # @return [String]
1796
+ #
1700
1797
  # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/GuardrailTraceAssessment AWS API Documentation
1701
1798
  #
1702
1799
  class GuardrailTraceAssessment < Struct.new(
1703
1800
  :model_output,
1704
1801
  :input_assessment,
1705
- :output_assessments)
1802
+ :output_assessments,
1803
+ :action_reason)
1706
1804
  SENSITIVE = []
1707
1805
  include Aws::Structure
1708
1806
  end
@@ -2040,6 +2138,47 @@ module Aws::BedrockRuntime
2040
2138
  include Aws::Structure
2041
2139
  end
2042
2140
 
2141
+ # @!attribute [rw] model_id
2142
+ # The model ID or ARN of the model ID to use. Currently, only
2143
+ # `amazon.nova-sonic-v1:0` is supported.
2144
+ # @return [String]
2145
+ #
2146
+ # @!attribute [rw] body
2147
+ # The prompt and inference parameters in the format specified in the
2148
+ # `BidirectionalInputPayloadPart` in the header. You must provide the
2149
+ # body in JSON format. To see the format and content of the request
2150
+ # and response bodies for different models, refer to [Inference
2151
+ # parameters][1]. For more information, see [Run inference][2] in the
2152
+ # Bedrock User Guide.
2153
+ #
2154
+ #
2155
+ #
2156
+ # [1]: https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html
2157
+ # [2]: https://docs.aws.amazon.com/bedrock/latest/userguide/api-methods-run.html
2158
+ # @return [Types::InvokeModelWithBidirectionalStreamInput]
2159
+ #
2160
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/InvokeModelWithBidirectionalStreamRequest AWS API Documentation
2161
+ #
2162
+ class InvokeModelWithBidirectionalStreamRequest < Struct.new(
2163
+ :model_id,
2164
+ :body)
2165
+ SENSITIVE = []
2166
+ include Aws::Structure
2167
+ end
2168
+
2169
+ # @!attribute [rw] body
2170
+ # Streaming response from the model in the format specified by the
2171
+ # `BidirectionalOutputPayloadPart` header.
2172
+ # @return [Types::InvokeModelWithBidirectionalStreamOutput]
2173
+ #
2174
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/InvokeModelWithBidirectionalStreamResponse AWS API Documentation
2175
+ #
2176
+ class InvokeModelWithBidirectionalStreamResponse < Struct.new(
2177
+ :body)
2178
+ SENSITIVE = []
2179
+ include Aws::Structure
2180
+ end
2181
+
2043
2182
  # @!attribute [rw] body
2044
2183
  # The prompt and inference parameters in the format specified in the
2045
2184
  # `contentType` in the header. You must provide the body in JSON
@@ -3194,6 +3333,48 @@ module Aws::BedrockRuntime
3194
3333
 
3195
3334
  end
3196
3335
 
3336
+ # Payload content, the speech chunk, for the bidirectional input of the
3337
+ # invocation step.
3338
+ #
3339
+ # EventStream is an Enumerator of Events.
3340
+ # #event_types #=> Array, returns all modeled event types in the stream
3341
+ #
3342
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/InvokeModelWithBidirectionalStreamInput AWS API Documentation
3343
+ #
3344
+ class InvokeModelWithBidirectionalStreamInput < Enumerator
3345
+
3346
+ def event_types
3347
+ [
3348
+ :chunk
3349
+ ]
3350
+ end
3351
+
3352
+ end
3353
+
3354
+ # Output from the bidirectional stream that was used for model
3355
+ # invocation.
3356
+ #
3357
+ # EventStream is an Enumerator of Events.
3358
+ # #event_types #=> Array, returns all modeled event types in the stream
3359
+ #
3360
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/InvokeModelWithBidirectionalStreamOutput AWS API Documentation
3361
+ #
3362
+ class InvokeModelWithBidirectionalStreamOutput < Enumerator
3363
+
3364
+ def event_types
3365
+ [
3366
+ :chunk,
3367
+ :internal_server_exception,
3368
+ :model_stream_error_exception,
3369
+ :validation_exception,
3370
+ :throttling_exception,
3371
+ :model_timeout_exception,
3372
+ :service_unavailable_exception
3373
+ ]
3374
+ end
3375
+
3376
+ end
3377
+
3197
3378
  # Definition of content in the response stream.
3198
3379
  #
3199
3380
  # EventStream is an Enumerator of Events.
@@ -54,9 +54,10 @@ module Aws::BedrockRuntime
54
54
  autoload :EndpointParameters, 'aws-sdk-bedrockruntime/endpoint_parameters'
55
55
  autoload :EndpointProvider, 'aws-sdk-bedrockruntime/endpoint_provider'
56
56
  autoload :Endpoints, 'aws-sdk-bedrockruntime/endpoints'
57
+ autoload :AsyncClient, 'aws-sdk-bedrockruntime/async_client'
57
58
  autoload :EventStreams, 'aws-sdk-bedrockruntime/event_streams'
58
59
 
59
- GEM_VERSION = '1.42.0'
60
+ GEM_VERSION = '1.44.0'
60
61
 
61
62
  end
62
63
 
data/sig/client.rbs CHANGED
@@ -84,6 +84,7 @@ module Aws
84
84
  include ::Seahorse::Client::_ResponseSuccess[Types::ApplyGuardrailResponse]
85
85
  def usage: () -> Types::GuardrailUsage
86
86
  def action: () -> ("NONE" | "GUARDRAIL_INTERVENED")
87
+ def action_reason: () -> ::String
87
88
  def outputs: () -> ::Array[Types::GuardrailOutputContent]
88
89
  def assessments: () -> ::Array[Types::GuardrailAssessment]
89
90
  def guardrail_coverage: () -> Types::GuardrailCoverage
@@ -106,7 +107,8 @@ module Aws
106
107
  }
107
108
  }?
108
109
  },
109
- ]
110
+ ],
111
+ ?output_scope: ("INTERVENTIONS" | "FULL")
110
112
  ) -> _ApplyGuardrailResponseSuccess
111
113
  | (Hash[Symbol, untyped] params, ?Hash[Symbol, untyped] options) -> _ApplyGuardrailResponseSuccess
112
114
 
@@ -273,7 +275,7 @@ module Aws
273
275
  ?guardrail_config: {
274
276
  guardrail_identifier: ::String,
275
277
  guardrail_version: ::String,
276
- trace: ("enabled" | "disabled")?
278
+ trace: ("enabled" | "disabled" | "enabled_full")?
277
279
  },
278
280
  ?additional_model_request_fields: {
279
281
  },
@@ -445,7 +447,7 @@ module Aws
445
447
  ?guardrail_config: {
446
448
  guardrail_identifier: ::String,
447
449
  guardrail_version: ::String,
448
- trace: ("enabled" | "disabled")?,
450
+ trace: ("enabled" | "disabled" | "enabled_full")?,
449
451
  stream_processing_mode: ("sync" | "async")?
450
452
  },
451
453
  ?additional_model_request_fields: {
@@ -491,13 +493,24 @@ module Aws
491
493
  ?content_type: ::String,
492
494
  ?accept: ::String,
493
495
  model_id: ::String,
494
- ?trace: ("ENABLED" | "DISABLED"),
496
+ ?trace: ("ENABLED" | "DISABLED" | "ENABLED_FULL"),
495
497
  ?guardrail_identifier: ::String,
496
498
  ?guardrail_version: ::String,
497
499
  ?performance_config_latency: ("standard" | "optimized")
498
500
  ) -> _InvokeModelResponseSuccess
499
501
  | (Hash[Symbol, untyped] params, ?Hash[Symbol, untyped] options) -> _InvokeModelResponseSuccess
500
502
 
503
+ interface _InvokeModelWithBidirectionalStreamResponseSuccess
504
+ include ::Seahorse::Client::_ResponseSuccess[Types::InvokeModelWithBidirectionalStreamResponse]
505
+ def body: () -> Types::InvokeModelWithBidirectionalStreamOutput
506
+ end
507
+ # https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/BedrockRuntime/Client.html#invoke_model_with_bidirectional_stream-instance_method
508
+ def invoke_model_with_bidirectional_stream: (
509
+ model_id: ::String,
510
+ input_event_stream_hander: untyped
511
+ ) ?{ (*untyped) -> void } -> _InvokeModelWithBidirectionalStreamResponseSuccess
512
+ | (Hash[Symbol, untyped] params, ?Hash[Symbol, untyped] options) ?{ (*untyped) -> void } -> _InvokeModelWithBidirectionalStreamResponseSuccess
513
+
501
514
  interface _InvokeModelWithResponseStreamResponseSuccess
502
515
  include ::Seahorse::Client::_ResponseSuccess[Types::InvokeModelWithResponseStreamResponse]
503
516
  def body: () -> Types::ResponseStream
@@ -510,7 +523,7 @@ module Aws
510
523
  ?content_type: ::String,
511
524
  ?accept: ::String,
512
525
  model_id: ::String,
513
- ?trace: ("ENABLED" | "DISABLED"),
526
+ ?trace: ("ENABLED" | "DISABLED" | "ENABLED_FULL"),
514
527
  ?guardrail_identifier: ::String,
515
528
  ?guardrail_version: ::String,
516
529
  ?performance_config_latency: ("standard" | "optimized")