aws-sdk-bedrockruntime 1.45.0 → 1.46.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 +5 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-bedrockruntime/async_client.rb +134 -114
- data/lib/aws-sdk-bedrockruntime/client.rb +327 -315
- data/lib/aws-sdk-bedrockruntime.rb +1 -1
- data/sig/async_client.rbs +82 -0
- data/sig/client.rbs +0 -11
- 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: 51de9c1b5243a2585f78fd3f28fc41338438106c59ddbb9e9091f0417c91fa1e
|
4
|
+
data.tar.gz: 7269aee7d2cf3aab910e6ba757c9d5fa6befc4436d33a4c10354864398a80b55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2f8bd8bad452e8eb9b46ac12a13fd54d19e524ff50908cd614eb7362355bab475f4429a1c6a9cd696a057b09be1224ab6f030dadd79831f0ec464679749bf07
|
7
|
+
data.tar.gz: df2b78ccf0956f31dffd0cb689605569763f7c2525c430723385698209a2234ee0ab25b596697e16b04096ebd9c5ccd0dfcac028caf59f6fa28913cebf3e7e19
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
Unreleased Changes
|
2
2
|
------------------
|
3
3
|
|
4
|
+
1.46.0 (2025-04-28)
|
5
|
+
------------------
|
6
|
+
|
7
|
+
* Feature - This release adds native h2 support for the bedrock runtime API, the support is only limited to SDKs that support h2 requests natively.
|
8
|
+
|
4
9
|
1.45.0 (2025-04-25)
|
5
10
|
------------------
|
6
11
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.46.0
|
@@ -10,32 +10,44 @@
|
|
10
10
|
begin
|
11
11
|
require 'http/2'
|
12
12
|
rescue LoadError; end
|
13
|
-
require 'aws-sdk-core/plugins/credentials_configuration
|
14
|
-
require 'aws-sdk-core/plugins/logging
|
15
|
-
require 'aws-sdk-core/plugins/param_converter
|
16
|
-
require 'aws-sdk-core/plugins/param_validator
|
17
|
-
require 'aws-sdk-core/plugins/user_agent
|
18
|
-
require 'aws-sdk-core/plugins/helpful_socket_errors
|
19
|
-
require 'aws-sdk-core/plugins/retry_errors
|
20
|
-
require 'aws-sdk-core/plugins/global_configuration
|
21
|
-
require 'aws-sdk-core/plugins/regional_endpoint
|
22
|
-
require 'aws-sdk-core/plugins/stub_responses
|
23
|
-
require 'aws-sdk-core/plugins/idempotency_token
|
24
|
-
require 'aws-sdk-core/plugins/invocation_id
|
25
|
-
require 'aws-sdk-core/plugins/jsonvalue_converter
|
26
|
-
require 'aws-sdk-core/plugins/http_checksum
|
27
|
-
require 'aws-sdk-core/plugins/checksum_algorithm
|
28
|
-
require 'aws-sdk-core/plugins/request_compression
|
29
|
-
require 'aws-sdk-core/plugins/defaults_mode
|
30
|
-
require 'aws-sdk-core/plugins/recursion_detection
|
31
|
-
require 'aws-sdk-core/plugins/telemetry
|
32
|
-
require 'aws-sdk-core/plugins/sign
|
33
|
-
require 'aws-sdk-core/plugins/protocols/rest_json
|
34
|
-
require 'aws-sdk-core/plugins/event_stream_configuration
|
13
|
+
require 'aws-sdk-core/plugins/credentials_configuration'
|
14
|
+
require 'aws-sdk-core/plugins/logging'
|
15
|
+
require 'aws-sdk-core/plugins/param_converter'
|
16
|
+
require 'aws-sdk-core/plugins/param_validator'
|
17
|
+
require 'aws-sdk-core/plugins/user_agent'
|
18
|
+
require 'aws-sdk-core/plugins/helpful_socket_errors'
|
19
|
+
require 'aws-sdk-core/plugins/retry_errors'
|
20
|
+
require 'aws-sdk-core/plugins/global_configuration'
|
21
|
+
require 'aws-sdk-core/plugins/regional_endpoint'
|
22
|
+
require 'aws-sdk-core/plugins/stub_responses'
|
23
|
+
require 'aws-sdk-core/plugins/idempotency_token'
|
24
|
+
require 'aws-sdk-core/plugins/invocation_id'
|
25
|
+
require 'aws-sdk-core/plugins/jsonvalue_converter'
|
26
|
+
require 'aws-sdk-core/plugins/http_checksum'
|
27
|
+
require 'aws-sdk-core/plugins/checksum_algorithm'
|
28
|
+
require 'aws-sdk-core/plugins/request_compression'
|
29
|
+
require 'aws-sdk-core/plugins/defaults_mode'
|
30
|
+
require 'aws-sdk-core/plugins/recursion_detection'
|
31
|
+
require 'aws-sdk-core/plugins/telemetry'
|
32
|
+
require 'aws-sdk-core/plugins/sign'
|
33
|
+
require 'aws-sdk-core/plugins/protocols/rest_json'
|
34
|
+
require 'aws-sdk-core/plugins/event_stream_configuration'
|
35
35
|
|
36
36
|
Aws::Plugins::GlobalConfiguration.add_identifier(:bedrockruntime)
|
37
37
|
|
38
38
|
module Aws::BedrockRuntime
|
39
|
+
# An API async client for BedrockRuntime. To construct an async client, you need to configure a `:region` and `:credentials`.
|
40
|
+
#
|
41
|
+
# async_client = Aws::BedrockRuntime::AsyncClient.new(
|
42
|
+
# region: region_name,
|
43
|
+
# credentials: credentials,
|
44
|
+
# # ...
|
45
|
+
# )
|
46
|
+
#
|
47
|
+
# For details on configuring region and credentials see
|
48
|
+
# the [developer guide](/sdk-for-ruby/v3/developer-guide/setup-config.html).
|
49
|
+
#
|
50
|
+
# See {#initialize} for a full list of supported configuration options.
|
39
51
|
class AsyncClient < Seahorse::Client::AsyncBase
|
40
52
|
|
41
53
|
include Aws::AsyncClientStubs
|
@@ -68,6 +80,13 @@ module Aws::BedrockRuntime
|
|
68
80
|
add_plugin(Aws::Plugins::EventStreamConfiguration)
|
69
81
|
add_plugin(Aws::BedrockRuntime::Plugins::Endpoints)
|
70
82
|
|
83
|
+
# @overload initialize(options)
|
84
|
+
# @param [Hash] options
|
85
|
+
#
|
86
|
+
# @option options [Array<Seahorse::Client::Plugin>] :plugins ([]])
|
87
|
+
# A list of plugins to apply to the client. Each plugin is either a
|
88
|
+
# class name or an instance of a plugin class.
|
89
|
+
#
|
71
90
|
# @option options [required, Aws::CredentialProvider] :credentials
|
72
91
|
# Your AWS credentials. This can be an instance of any one of the
|
73
92
|
# following classes:
|
@@ -406,103 +425,104 @@ module Aws::BedrockRuntime
|
|
406
425
|
# * {Types::InvokeModelWithBidirectionalStreamResponse#body #body} => Types::InvokeModelWithBidirectionalStreamOutput
|
407
426
|
#
|
408
427
|
# @example Bi-directional EventStream Operation Example
|
409
|
-
#
|
410
|
-
#
|
411
|
-
#
|
412
|
-
#
|
413
|
-
#
|
414
|
-
#
|
415
|
-
#
|
416
|
-
#
|
417
|
-
#
|
418
|
-
#
|
419
|
-
#
|
420
|
-
#
|
421
|
-
#
|
422
|
-
#
|
423
|
-
#
|
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|
|
428
|
+
# # You can signal input events after the initial request is established. Events
|
429
|
+
# # will be sent to the stream immediately once the stream connection is
|
430
|
+
# # established successfully.
|
431
|
+
#
|
432
|
+
# # To signal events, you can call the #signal methods from an
|
433
|
+
# # Aws::BedrockRuntime::EventStreams::InvokeModelWithBidirectionalStreamInput object.
|
434
|
+
# # You must signal events before calling #wait or #join! on the async response.
|
435
|
+
# input_stream = Aws::BedrockRuntime::EventStreams::InvokeModelWithBidirectionalStreamInput.new
|
436
|
+
#
|
437
|
+
# async_resp = client.invoke_model_with_bidirectional_stream(
|
438
|
+
# # params input
|
439
|
+
# input_event_stream_handler: input_stream
|
440
|
+
# ) do |out_stream|
|
441
|
+
# # register callbacks for events
|
442
|
+
# out_stream.on_chunk_event do |event|
|
466
443
|
# event # => Aws::BedrockRuntime::Types::chunk
|
467
444
|
# end
|
468
|
-
#
|
445
|
+
# out_stream.on_internal_server_exception_event do |event|
|
469
446
|
# event # => Aws::BedrockRuntime::Types::internalServerException
|
470
447
|
# end
|
471
|
-
#
|
448
|
+
# out_stream.on_model_stream_error_exception_event do |event|
|
472
449
|
# event # => Aws::BedrockRuntime::Types::modelStreamErrorException
|
473
450
|
# end
|
474
|
-
#
|
451
|
+
# out_stream.on_validation_exception_event do |event|
|
475
452
|
# event # => Aws::BedrockRuntime::Types::validationException
|
476
453
|
# end
|
477
|
-
#
|
454
|
+
# out_stream.on_throttling_exception_event do |event|
|
478
455
|
# event # => Aws::BedrockRuntime::Types::throttlingException
|
479
456
|
# end
|
480
|
-
#
|
457
|
+
# out_stream.on_model_timeout_exception_event do |event|
|
481
458
|
# event # => Aws::BedrockRuntime::Types::modelTimeoutException
|
482
459
|
# end
|
483
|
-
#
|
460
|
+
# out_stream.on_service_unavailable_exception_event do |event|
|
484
461
|
# event # => Aws::BedrockRuntime::Types::serviceUnavailableException
|
485
462
|
# end
|
486
|
-
#
|
487
|
-
#
|
488
|
-
#
|
489
|
-
#
|
490
|
-
#
|
491
|
-
#
|
492
|
-
#
|
493
|
-
#
|
494
|
-
#
|
495
|
-
#
|
496
|
-
#
|
497
|
-
#
|
498
|
-
#
|
499
|
-
#
|
500
|
-
#
|
501
|
-
#
|
502
|
-
#
|
503
|
-
# You can also
|
504
|
-
#
|
505
|
-
#
|
463
|
+
# end
|
464
|
+
# # => Aws::Seahorse::Client::AsyncResponse
|
465
|
+
#
|
466
|
+
# # signal events
|
467
|
+
# input_stream.signal_chunk_event(
|
468
|
+
# # ...
|
469
|
+
# )
|
470
|
+
#
|
471
|
+
# # make sure to signal :end_stream at the end
|
472
|
+
# input_stream.signal_end_stream
|
473
|
+
#
|
474
|
+
# # wait until stream is closed before finalizing the sync response
|
475
|
+
# resp = async_resp.wait
|
476
|
+
#
|
477
|
+
# # Or close the stream and finalize sync response immediately
|
478
|
+
# resp = async_resp.join!
|
479
|
+
#
|
480
|
+
# # You can also provide an Aws::BedrockRuntime::EventStreams::InvokeModelWithBidirectionalStreamOutput object
|
481
|
+
# # to register callbacks before initializing the request instead of processing
|
482
|
+
# # from the request block.
|
483
|
+
# output_stream = Aws::BedrockRuntime::EventStreams::InvokeModelWithBidirectionalStreamOutput.new
|
484
|
+
#
|
485
|
+
# # register callbacks for output events
|
486
|
+
# output_stream.on_chunk_event do |event|
|
487
|
+
# event # => Aws::BedrockRuntime::Types::chunk
|
488
|
+
# end
|
489
|
+
# output_stream.on_internal_server_exception_event do |event|
|
490
|
+
# event # => Aws::BedrockRuntime::Types::internalServerException
|
491
|
+
# end
|
492
|
+
# output_stream.on_model_stream_error_exception_event do |event|
|
493
|
+
# event # => Aws::BedrockRuntime::Types::modelStreamErrorException
|
494
|
+
# end
|
495
|
+
# output_stream.on_validation_exception_event do |event|
|
496
|
+
# event # => Aws::BedrockRuntime::Types::validationException
|
497
|
+
# end
|
498
|
+
# output_stream.on_throttling_exception_event do |event|
|
499
|
+
# event # => Aws::BedrockRuntime::Types::throttlingException
|
500
|
+
# end
|
501
|
+
# output_stream.on_model_timeout_exception_event do |event|
|
502
|
+
# event # => Aws::BedrockRuntime::Types::modelTimeoutException
|
503
|
+
# end
|
504
|
+
# output_stream.on_service_unavailable_exception_event do |event|
|
505
|
+
# event # => Aws::BedrockRuntime::Types::serviceUnavailableException
|
506
|
+
# end
|
507
|
+
# output_stream.on_error_event do |event|
|
508
|
+
# # catch unmodeled error event in the stream
|
509
|
+
# raise event
|
510
|
+
# # => Aws::Errors::EventError
|
511
|
+
# # event.event_type => :error
|
512
|
+
# # event.error_code => String
|
513
|
+
# # event.error_message => String
|
514
|
+
# end
|
515
|
+
#
|
516
|
+
# async_resp = client.invoke_model_with_bidirectional_stream(
|
517
|
+
# # params input
|
518
|
+
# input_event_stream_handler: input_stream,
|
519
|
+
# output_event_stream_handler: output_stream
|
520
|
+
# )
|
521
|
+
# resp = async_resp.join!
|
522
|
+
#
|
523
|
+
# # You can also iterate through events after the response is complete.
|
524
|
+
# # Events are available at
|
525
|
+
# resp.body # => Enumerator
|
506
526
|
#
|
507
527
|
# @example Request syntax with placeholder values
|
508
528
|
#
|
@@ -517,31 +537,31 @@ module Aws::BedrockRuntime
|
|
517
537
|
#
|
518
538
|
# @example Response structure
|
519
539
|
#
|
520
|
-
# All events are available at resp.body:
|
540
|
+
# # All events are available at resp.body:
|
521
541
|
# resp.body #=> Enumerator
|
522
542
|
# resp.body.event_types #=> [:chunk, :internal_server_exception, :model_stream_error_exception, :validation_exception, :throttling_exception, :model_timeout_exception, :service_unavailable_exception]
|
523
543
|
#
|
524
|
-
# For :chunk event available at #on_chunk_event callback and response eventstream enumerator:
|
544
|
+
# # For :chunk event available at #on_chunk_event callback and response eventstream enumerator:
|
525
545
|
# event.bytes #=> String
|
526
546
|
#
|
527
|
-
# For :internal_server_exception event available at #on_internal_server_exception_event callback and response eventstream enumerator:
|
547
|
+
# # For :internal_server_exception event available at #on_internal_server_exception_event callback and response eventstream enumerator:
|
528
548
|
# event.message #=> String
|
529
549
|
#
|
530
|
-
# For :model_stream_error_exception event available at #on_model_stream_error_exception_event callback and response eventstream enumerator:
|
550
|
+
# # For :model_stream_error_exception event available at #on_model_stream_error_exception_event callback and response eventstream enumerator:
|
531
551
|
# event.message #=> String
|
532
552
|
# event.original_status_code #=> Integer
|
533
553
|
# event.original_message #=> String
|
534
554
|
#
|
535
|
-
# For :validation_exception event available at #on_validation_exception_event callback and response eventstream enumerator:
|
555
|
+
# # For :validation_exception event available at #on_validation_exception_event callback and response eventstream enumerator:
|
536
556
|
# event.message #=> String
|
537
557
|
#
|
538
|
-
# For :throttling_exception event available at #on_throttling_exception_event callback and response eventstream enumerator:
|
558
|
+
# # For :throttling_exception event available at #on_throttling_exception_event callback and response eventstream enumerator:
|
539
559
|
# event.message #=> String
|
540
560
|
#
|
541
|
-
# For :model_timeout_exception event available at #on_model_timeout_exception_event callback and response eventstream enumerator:
|
561
|
+
# # For :model_timeout_exception event available at #on_model_timeout_exception_event callback and response eventstream enumerator:
|
542
562
|
# event.message #=> String
|
543
563
|
#
|
544
|
-
# For :service_unavailable_exception event available at #on_service_unavailable_exception_event callback and response eventstream enumerator:
|
564
|
+
# # For :service_unavailable_exception event available at #on_service_unavailable_exception_event callback and response eventstream enumerator:
|
545
565
|
# event.message #=> String
|
546
566
|
#
|
547
567
|
# @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/InvokeModelWithBidirectionalStream AWS API Documentation
|
@@ -592,7 +612,7 @@ module Aws::BedrockRuntime
|
|
592
612
|
tracer: tracer
|
593
613
|
)
|
594
614
|
context[:gem_name] = 'aws-sdk-bedrockruntime'
|
595
|
-
context[:gem_version] = '1.
|
615
|
+
context[:gem_version] = '1.46.0'
|
596
616
|
Seahorse::Client::Request.new(handlers, context)
|
597
617
|
end
|
598
618
|
|
@@ -1350,176 +1350,182 @@ module Aws::BedrockRuntime
|
|
1350
1350
|
#
|
1351
1351
|
# @example EventStream Operation Example
|
1352
1352
|
#
|
1353
|
-
# You can process the event once it arrives immediately, or wait until the
|
1354
|
-
# full response is complete and iterate through the eventstream enumerator.
|
1355
|
-
#
|
1356
|
-
# To interact with event immediately, you need to register
|
1357
|
-
# with callbacks. Callbacks can be registered for specific events or for all
|
1358
|
-
# events, including error events.
|
1359
|
-
#
|
1360
|
-
# Callbacks can be passed into the `:event_stream_handler` option or within a
|
1361
|
-
# block statement attached to the #converse_stream call directly. Hybrid
|
1362
|
-
# pattern of both is also supported.
|
1363
|
-
#
|
1364
|
-
# `:event_stream_handler` option takes in either a Proc object or
|
1365
|
-
# Aws::BedrockRuntime::EventStreams::ConverseStreamOutput object.
|
1366
|
-
#
|
1367
|
-
# Usage pattern a): Callbacks with a block attached to #converse_stream
|
1368
|
-
#
|
1369
|
-
#
|
1370
|
-
#
|
1371
|
-
#
|
1372
|
-
#
|
1373
|
-
#
|
1374
|
-
#
|
1375
|
-
#
|
1376
|
-
#
|
1377
|
-
#
|
1378
|
-
#
|
1379
|
-
#
|
1380
|
-
# stream.on_event do |event|
|
1381
|
-
# # process all events arrive
|
1382
|
-
# puts event.event_type
|
1383
|
-
# ...
|
1384
|
-
# end
|
1385
|
-
#
|
1353
|
+
# # You can process the event once it arrives immediately, or wait until the
|
1354
|
+
# # full response is complete and iterate through the eventstream enumerator.
|
1355
|
+
#
|
1356
|
+
# # To interact with event immediately, you need to register converse_stream
|
1357
|
+
# # with callbacks. Callbacks can be registered for specific events or for all
|
1358
|
+
# # events, including error events.
|
1359
|
+
#
|
1360
|
+
# # Callbacks can be passed into the `:event_stream_handler` option or within a
|
1361
|
+
# # block statement attached to the #converse_stream call directly. Hybrid
|
1362
|
+
# # pattern of both is also supported.
|
1363
|
+
#
|
1364
|
+
# # `:event_stream_handler` option takes in either a Proc object or
|
1365
|
+
# # Aws::BedrockRuntime::EventStreams::ConverseStreamOutput object.
|
1366
|
+
#
|
1367
|
+
# # Usage pattern a): Callbacks with a block attached to #converse_stream
|
1368
|
+
# # Example for registering callbacks for all event types and an error event
|
1369
|
+
# client.converse_stream(
|
1370
|
+
# # params input
|
1371
|
+
# ) do |stream|
|
1372
|
+
# stream.on_error_event do |event|
|
1373
|
+
# # catch unmodeled error event in the stream
|
1374
|
+
# raise event
|
1375
|
+
# # => Aws::Errors::EventError
|
1376
|
+
# # event.event_type => :error
|
1377
|
+
# # event.error_code => String
|
1378
|
+
# # event.error_message => String
|
1386
1379
|
# end
|
1387
1380
|
#
|
1388
|
-
#
|
1389
|
-
#
|
1390
|
-
#
|
1391
|
-
#
|
1392
|
-
#
|
1393
|
-
# handler = Aws::BedrockRuntime::EventStreams::ConverseStreamOutput.new
|
1394
|
-
# handler.on_message_start_event do |event|
|
1395
|
-
# event # => Aws::BedrockRuntime::Types::messageStart
|
1396
|
-
# end
|
1397
|
-
# handler.on_content_block_start_event do |event|
|
1398
|
-
# event # => Aws::BedrockRuntime::Types::contentBlockStart
|
1399
|
-
# end
|
1400
|
-
# handler.on_content_block_delta_event do |event|
|
1401
|
-
# event # => Aws::BedrockRuntime::Types::contentBlockDelta
|
1402
|
-
# end
|
1403
|
-
# handler.on_content_block_stop_event do |event|
|
1404
|
-
# event # => Aws::BedrockRuntime::Types::contentBlockStop
|
1405
|
-
# end
|
1406
|
-
# handler.on_message_stop_event do |event|
|
1407
|
-
# event # => Aws::BedrockRuntime::Types::messageStop
|
1408
|
-
# end
|
1409
|
-
# handler.on_metadata_event do |event|
|
1410
|
-
# event # => Aws::BedrockRuntime::Types::metadata
|
1411
|
-
# end
|
1412
|
-
# handler.on_internal_server_exception_event do |event|
|
1413
|
-
# event # => Aws::BedrockRuntime::Types::internalServerException
|
1414
|
-
# end
|
1415
|
-
# handler.on_model_stream_error_exception_event do |event|
|
1416
|
-
# event # => Aws::BedrockRuntime::Types::modelStreamErrorException
|
1417
|
-
# end
|
1418
|
-
# handler.on_validation_exception_event do |event|
|
1419
|
-
# event # => Aws::BedrockRuntime::Types::validationException
|
1420
|
-
# end
|
1421
|
-
# handler.on_throttling_exception_event do |event|
|
1422
|
-
# event # => Aws::BedrockRuntime::Types::throttlingException
|
1423
|
-
# end
|
1424
|
-
# handler.on_service_unavailable_exception_event do |event|
|
1425
|
-
# event # => Aws::BedrockRuntime::Types::serviceUnavailableException
|
1426
|
-
# end
|
1427
|
-
#
|
1428
|
-
# client.converse_stream( # params input #, event_stream_handler: handler)
|
1429
|
-
#
|
1430
|
-
# 2) Use a Ruby Proc object
|
1431
|
-
# Example for registering callbacks with specific events
|
1432
|
-
#
|
1433
|
-
# handler = Proc.new do |stream|
|
1434
|
-
# stream.on_message_start_event do |event|
|
1435
|
-
# event # => Aws::BedrockRuntime::Types::messageStart
|
1436
|
-
# end
|
1437
|
-
# stream.on_content_block_start_event do |event|
|
1438
|
-
# event # => Aws::BedrockRuntime::Types::contentBlockStart
|
1439
|
-
# end
|
1440
|
-
# stream.on_content_block_delta_event do |event|
|
1441
|
-
# event # => Aws::BedrockRuntime::Types::contentBlockDelta
|
1442
|
-
# end
|
1443
|
-
# stream.on_content_block_stop_event do |event|
|
1444
|
-
# event # => Aws::BedrockRuntime::Types::contentBlockStop
|
1445
|
-
# end
|
1446
|
-
# stream.on_message_stop_event do |event|
|
1447
|
-
# event # => Aws::BedrockRuntime::Types::messageStop
|
1448
|
-
# end
|
1449
|
-
# stream.on_metadata_event do |event|
|
1450
|
-
# event # => Aws::BedrockRuntime::Types::metadata
|
1451
|
-
# end
|
1452
|
-
# stream.on_internal_server_exception_event do |event|
|
1453
|
-
# event # => Aws::BedrockRuntime::Types::internalServerException
|
1454
|
-
# end
|
1455
|
-
# stream.on_model_stream_error_exception_event do |event|
|
1456
|
-
# event # => Aws::BedrockRuntime::Types::modelStreamErrorException
|
1457
|
-
# end
|
1458
|
-
# stream.on_validation_exception_event do |event|
|
1459
|
-
# event # => Aws::BedrockRuntime::Types::validationException
|
1460
|
-
# end
|
1461
|
-
# stream.on_throttling_exception_event do |event|
|
1462
|
-
# event # => Aws::BedrockRuntime::Types::throttlingException
|
1463
|
-
# end
|
1464
|
-
# stream.on_service_unavailable_exception_event do |event|
|
1465
|
-
# event # => Aws::BedrockRuntime::Types::serviceUnavailableException
|
1466
|
-
# end
|
1381
|
+
# stream.on_event do |event|
|
1382
|
+
# # process all events arrive
|
1383
|
+
# puts event.event_type
|
1384
|
+
# # ...
|
1467
1385
|
# end
|
1468
|
-
#
|
1469
|
-
#
|
1470
|
-
#
|
1471
|
-
#
|
1472
|
-
#
|
1473
|
-
#
|
1474
|
-
#
|
1475
|
-
#
|
1476
|
-
#
|
1477
|
-
#
|
1478
|
-
#
|
1479
|
-
#
|
1480
|
-
#
|
1481
|
-
#
|
1482
|
-
#
|
1483
|
-
#
|
1484
|
-
#
|
1485
|
-
#
|
1486
|
-
#
|
1487
|
-
#
|
1488
|
-
#
|
1489
|
-
#
|
1490
|
-
#
|
1491
|
-
#
|
1492
|
-
#
|
1493
|
-
#
|
1494
|
-
#
|
1495
|
-
#
|
1496
|
-
#
|
1497
|
-
#
|
1498
|
-
#
|
1499
|
-
#
|
1500
|
-
#
|
1501
|
-
#
|
1502
|
-
#
|
1503
|
-
#
|
1504
|
-
#
|
1505
|
-
#
|
1506
|
-
#
|
1507
|
-
#
|
1508
|
-
#
|
1509
|
-
#
|
1510
|
-
#
|
1511
|
-
#
|
1512
|
-
#
|
1513
|
-
#
|
1514
|
-
#
|
1515
|
-
#
|
1516
|
-
#
|
1386
|
+
# end
|
1387
|
+
#
|
1388
|
+
# # Usage pattern b): Pass in `:event_stream_handler` for #converse_stream
|
1389
|
+
# # 1) Create a Aws::BedrockRuntime::EventStreams::ConverseStreamOutput object
|
1390
|
+
# # Example for registering callbacks with specific events
|
1391
|
+
#
|
1392
|
+
# handler = Aws::BedrockRuntime::EventStreams::ConverseStreamOutput.new
|
1393
|
+
# handler.on_message_start_event do |event|
|
1394
|
+
# event # => Aws::BedrockRuntime::Types::messageStart
|
1395
|
+
# end
|
1396
|
+
# handler.on_content_block_start_event do |event|
|
1397
|
+
# event # => Aws::BedrockRuntime::Types::contentBlockStart
|
1398
|
+
# end
|
1399
|
+
# handler.on_content_block_delta_event do |event|
|
1400
|
+
# event # => Aws::BedrockRuntime::Types::contentBlockDelta
|
1401
|
+
# end
|
1402
|
+
# handler.on_content_block_stop_event do |event|
|
1403
|
+
# event # => Aws::BedrockRuntime::Types::contentBlockStop
|
1404
|
+
# end
|
1405
|
+
# handler.on_message_stop_event do |event|
|
1406
|
+
# event # => Aws::BedrockRuntime::Types::messageStop
|
1407
|
+
# end
|
1408
|
+
# handler.on_metadata_event do |event|
|
1409
|
+
# event # => Aws::BedrockRuntime::Types::metadata
|
1410
|
+
# end
|
1411
|
+
# handler.on_internal_server_exception_event do |event|
|
1412
|
+
# event # => Aws::BedrockRuntime::Types::internalServerException
|
1413
|
+
# end
|
1414
|
+
# handler.on_model_stream_error_exception_event do |event|
|
1415
|
+
# event # => Aws::BedrockRuntime::Types::modelStreamErrorException
|
1416
|
+
# end
|
1417
|
+
# handler.on_validation_exception_event do |event|
|
1418
|
+
# event # => Aws::BedrockRuntime::Types::validationException
|
1419
|
+
# end
|
1420
|
+
# handler.on_throttling_exception_event do |event|
|
1421
|
+
# event # => Aws::BedrockRuntime::Types::throttlingException
|
1422
|
+
# end
|
1423
|
+
# handler.on_service_unavailable_exception_event do |event|
|
1424
|
+
# event # => Aws::BedrockRuntime::Types::serviceUnavailableException
|
1425
|
+
# end
|
1426
|
+
#
|
1427
|
+
# client.converse_stream(
|
1428
|
+
# # params inputs
|
1429
|
+
# event_stream_handler: handler
|
1430
|
+
# )
|
1431
|
+
#
|
1432
|
+
# # 2) Use a Ruby Proc object
|
1433
|
+
# # Example for registering callbacks with specific events
|
1434
|
+
# handler = Proc.new do |stream|
|
1435
|
+
# stream.on_message_start_event do |event|
|
1436
|
+
# event # => Aws::BedrockRuntime::Types::messageStart
|
1517
1437
|
# end
|
1438
|
+
# stream.on_content_block_start_event do |event|
|
1439
|
+
# event # => Aws::BedrockRuntime::Types::contentBlockStart
|
1440
|
+
# end
|
1441
|
+
# stream.on_content_block_delta_event do |event|
|
1442
|
+
# event # => Aws::BedrockRuntime::Types::contentBlockDelta
|
1443
|
+
# end
|
1444
|
+
# stream.on_content_block_stop_event do |event|
|
1445
|
+
# event # => Aws::BedrockRuntime::Types::contentBlockStop
|
1446
|
+
# end
|
1447
|
+
# stream.on_message_stop_event do |event|
|
1448
|
+
# event # => Aws::BedrockRuntime::Types::messageStop
|
1449
|
+
# end
|
1450
|
+
# stream.on_metadata_event do |event|
|
1451
|
+
# event # => Aws::BedrockRuntime::Types::metadata
|
1452
|
+
# end
|
1453
|
+
# stream.on_internal_server_exception_event do |event|
|
1454
|
+
# event # => Aws::BedrockRuntime::Types::internalServerException
|
1455
|
+
# end
|
1456
|
+
# stream.on_model_stream_error_exception_event do |event|
|
1457
|
+
# event # => Aws::BedrockRuntime::Types::modelStreamErrorException
|
1458
|
+
# end
|
1459
|
+
# stream.on_validation_exception_event do |event|
|
1460
|
+
# event # => Aws::BedrockRuntime::Types::validationException
|
1461
|
+
# end
|
1462
|
+
# stream.on_throttling_exception_event do |event|
|
1463
|
+
# event # => Aws::BedrockRuntime::Types::throttlingException
|
1464
|
+
# end
|
1465
|
+
# stream.on_service_unavailable_exception_event do |event|
|
1466
|
+
# event # => Aws::BedrockRuntime::Types::serviceUnavailableException
|
1467
|
+
# end
|
1468
|
+
# end
|
1469
|
+
#
|
1470
|
+
# client.converse_stream(
|
1471
|
+
# # params inputs
|
1472
|
+
# event_stream_handler: handler
|
1473
|
+
# )
|
1474
|
+
#
|
1475
|
+
# # Usage pattern c): Hybrid pattern of a) and b)
|
1476
|
+
# handler = Aws::BedrockRuntime::EventStreams::ConverseStreamOutput.new
|
1477
|
+
# handler.on_message_start_event do |event|
|
1478
|
+
# event # => Aws::BedrockRuntime::Types::messageStart
|
1479
|
+
# end
|
1480
|
+
# handler.on_content_block_start_event do |event|
|
1481
|
+
# event # => Aws::BedrockRuntime::Types::contentBlockStart
|
1482
|
+
# end
|
1483
|
+
# handler.on_content_block_delta_event do |event|
|
1484
|
+
# event # => Aws::BedrockRuntime::Types::contentBlockDelta
|
1485
|
+
# end
|
1486
|
+
# handler.on_content_block_stop_event do |event|
|
1487
|
+
# event # => Aws::BedrockRuntime::Types::contentBlockStop
|
1488
|
+
# end
|
1489
|
+
# handler.on_message_stop_event do |event|
|
1490
|
+
# event # => Aws::BedrockRuntime::Types::messageStop
|
1491
|
+
# end
|
1492
|
+
# handler.on_metadata_event do |event|
|
1493
|
+
# event # => Aws::BedrockRuntime::Types::metadata
|
1494
|
+
# end
|
1495
|
+
# handler.on_internal_server_exception_event do |event|
|
1496
|
+
# event # => Aws::BedrockRuntime::Types::internalServerException
|
1497
|
+
# end
|
1498
|
+
# handler.on_model_stream_error_exception_event do |event|
|
1499
|
+
# event # => Aws::BedrockRuntime::Types::modelStreamErrorException
|
1500
|
+
# end
|
1501
|
+
# handler.on_validation_exception_event do |event|
|
1502
|
+
# event # => Aws::BedrockRuntime::Types::validationException
|
1503
|
+
# end
|
1504
|
+
# handler.on_throttling_exception_event do |event|
|
1505
|
+
# event # => Aws::BedrockRuntime::Types::throttlingException
|
1506
|
+
# end
|
1507
|
+
# handler.on_service_unavailable_exception_event do |event|
|
1508
|
+
# event # => Aws::BedrockRuntime::Types::serviceUnavailableException
|
1509
|
+
# end
|
1510
|
+
#
|
1511
|
+
# client.converse_stream(
|
1512
|
+
# # params input
|
1513
|
+
# event_stream_handler: handler
|
1514
|
+
# ) do |stream|
|
1515
|
+
# stream.on_error_event do |event|
|
1516
|
+
# # catch unmodeled error event in the stream
|
1517
|
+
# raise event
|
1518
|
+
# # => Aws::Errors::EventError
|
1519
|
+
# # event.event_type => :error
|
1520
|
+
# # event.error_code => String
|
1521
|
+
# # event.error_message => String
|
1522
|
+
# end
|
1523
|
+
# end
|
1518
1524
|
#
|
1519
|
-
# You can also iterate through events after the response complete.
|
1520
|
-
#
|
1521
|
-
#
|
1522
|
-
# For parameter input example, please refer to following request syntax
|
1525
|
+
# # You can also iterate through events after the response complete.
|
1526
|
+
# # Events are available at
|
1527
|
+
# resp.stream # => Enumerator
|
1528
|
+
# # For parameter input example, please refer to following request syntax.
|
1523
1529
|
#
|
1524
1530
|
# @example Request syntax with placeholder values
|
1525
1531
|
#
|
@@ -1712,19 +1718,19 @@ module Aws::BedrockRuntime
|
|
1712
1718
|
#
|
1713
1719
|
# @example Response structure
|
1714
1720
|
#
|
1715
|
-
# All events are available at resp.stream:
|
1721
|
+
# # All events are available at resp.stream:
|
1716
1722
|
# resp.stream #=> Enumerator
|
1717
1723
|
# resp.stream.event_types #=> [:message_start, :content_block_start, :content_block_delta, :content_block_stop, :message_stop, :metadata, :internal_server_exception, :model_stream_error_exception, :validation_exception, :throttling_exception, :service_unavailable_exception]
|
1718
1724
|
#
|
1719
|
-
# For :message_start event available at #on_message_start_event callback and response eventstream enumerator:
|
1725
|
+
# # For :message_start event available at #on_message_start_event callback and response eventstream enumerator:
|
1720
1726
|
# event.role #=> String, one of "user", "assistant"
|
1721
1727
|
#
|
1722
|
-
# For :content_block_start event available at #on_content_block_start_event callback and response eventstream enumerator:
|
1728
|
+
# # For :content_block_start event available at #on_content_block_start_event callback and response eventstream enumerator:
|
1723
1729
|
# event.start.tool_use.tool_use_id #=> String
|
1724
1730
|
# event.start.tool_use.name #=> String
|
1725
1731
|
# event.content_block_index #=> Integer
|
1726
1732
|
#
|
1727
|
-
# For :content_block_delta event available at #on_content_block_delta_event callback and response eventstream enumerator:
|
1733
|
+
# # For :content_block_delta event available at #on_content_block_delta_event callback and response eventstream enumerator:
|
1728
1734
|
# event.delta.text #=> String
|
1729
1735
|
# event.delta.tool_use.input #=> String
|
1730
1736
|
# event.delta.reasoning_content.text #=> String
|
@@ -1732,13 +1738,13 @@ module Aws::BedrockRuntime
|
|
1732
1738
|
# event.delta.reasoning_content.signature #=> String
|
1733
1739
|
# event.content_block_index #=> Integer
|
1734
1740
|
#
|
1735
|
-
# For :content_block_stop event available at #on_content_block_stop_event callback and response eventstream enumerator:
|
1741
|
+
# # For :content_block_stop event available at #on_content_block_stop_event callback and response eventstream enumerator:
|
1736
1742
|
# event.content_block_index #=> Integer
|
1737
1743
|
#
|
1738
|
-
# For :message_stop event available at #on_message_stop_event callback and response eventstream enumerator:
|
1744
|
+
# # For :message_stop event available at #on_message_stop_event callback and response eventstream enumerator:
|
1739
1745
|
# event.stop_reason #=> String, one of "end_turn", "tool_use", "max_tokens", "stop_sequence", "guardrail_intervened", "content_filtered"
|
1740
1746
|
#
|
1741
|
-
# For :metadata event available at #on_metadata_event callback and response eventstream enumerator:
|
1747
|
+
# # For :metadata event available at #on_metadata_event callback and response eventstream enumerator:
|
1742
1748
|
# event.usage.input_tokens #=> Integer
|
1743
1749
|
# event.usage.output_tokens #=> Integer
|
1744
1750
|
# event.usage.total_tokens #=> Integer
|
@@ -1852,21 +1858,21 @@ module Aws::BedrockRuntime
|
|
1852
1858
|
# event.trace.prompt_router.invoked_model_id #=> String
|
1853
1859
|
# event.performance_config.latency #=> String, one of "standard", "optimized"
|
1854
1860
|
#
|
1855
|
-
# For :internal_server_exception event available at #on_internal_server_exception_event callback and response eventstream enumerator:
|
1861
|
+
# # For :internal_server_exception event available at #on_internal_server_exception_event callback and response eventstream enumerator:
|
1856
1862
|
# event.message #=> String
|
1857
1863
|
#
|
1858
|
-
# For :model_stream_error_exception event available at #on_model_stream_error_exception_event callback and response eventstream enumerator:
|
1864
|
+
# # For :model_stream_error_exception event available at #on_model_stream_error_exception_event callback and response eventstream enumerator:
|
1859
1865
|
# event.message #=> String
|
1860
1866
|
# event.original_status_code #=> Integer
|
1861
1867
|
# event.original_message #=> String
|
1862
1868
|
#
|
1863
|
-
# For :validation_exception event available at #on_validation_exception_event callback and response eventstream enumerator:
|
1869
|
+
# # For :validation_exception event available at #on_validation_exception_event callback and response eventstream enumerator:
|
1864
1870
|
# event.message #=> String
|
1865
1871
|
#
|
1866
|
-
# For :throttling_exception event available at #on_throttling_exception_event callback and response eventstream enumerator:
|
1872
|
+
# # For :throttling_exception event available at #on_throttling_exception_event callback and response eventstream enumerator:
|
1867
1873
|
# event.message #=> String
|
1868
1874
|
#
|
1869
|
-
# For :service_unavailable_exception event available at #on_service_unavailable_exception_event callback and response eventstream enumerator:
|
1875
|
+
# # For :service_unavailable_exception event available at #on_service_unavailable_exception_event callback and response eventstream enumerator:
|
1870
1876
|
# event.message #=> String
|
1871
1877
|
#
|
1872
1878
|
# @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/ConverseStream AWS API Documentation
|
@@ -2215,140 +2221,146 @@ module Aws::BedrockRuntime
|
|
2215
2221
|
#
|
2216
2222
|
# @example EventStream Operation Example
|
2217
2223
|
#
|
2218
|
-
# You can process the event once it arrives immediately, or wait until the
|
2219
|
-
# full response is complete and iterate through the eventstream enumerator.
|
2220
|
-
#
|
2221
|
-
# To interact with event immediately, you need to register
|
2222
|
-
# with callbacks. Callbacks can be registered for specific events or for all
|
2223
|
-
# events, including error events.
|
2224
|
-
#
|
2225
|
-
# Callbacks can be passed into the `:event_stream_handler` option or within a
|
2226
|
-
# block statement attached to the #invoke_model_with_response_stream call directly. Hybrid
|
2227
|
-
# pattern of both is also supported.
|
2228
|
-
#
|
2229
|
-
# `:event_stream_handler` option takes in either a Proc object or
|
2230
|
-
# Aws::BedrockRuntime::EventStreams::ResponseStream object.
|
2231
|
-
#
|
2232
|
-
# Usage pattern a): Callbacks with a block attached to #invoke_model_with_response_stream
|
2233
|
-
#
|
2234
|
-
#
|
2235
|
-
#
|
2236
|
-
#
|
2237
|
-
#
|
2238
|
-
#
|
2239
|
-
#
|
2240
|
-
#
|
2241
|
-
#
|
2242
|
-
#
|
2243
|
-
#
|
2244
|
-
#
|
2245
|
-
# stream.on_event do |event|
|
2246
|
-
# # process all events arrive
|
2247
|
-
# puts event.event_type
|
2248
|
-
# ...
|
2249
|
-
# end
|
2250
|
-
#
|
2224
|
+
# # You can process the event once it arrives immediately, or wait until the
|
2225
|
+
# # full response is complete and iterate through the eventstream enumerator.
|
2226
|
+
#
|
2227
|
+
# # To interact with event immediately, you need to register invoke_model_with_response_stream
|
2228
|
+
# # with callbacks. Callbacks can be registered for specific events or for all
|
2229
|
+
# # events, including error events.
|
2230
|
+
#
|
2231
|
+
# # Callbacks can be passed into the `:event_stream_handler` option or within a
|
2232
|
+
# # block statement attached to the #invoke_model_with_response_stream call directly. Hybrid
|
2233
|
+
# # pattern of both is also supported.
|
2234
|
+
#
|
2235
|
+
# # `:event_stream_handler` option takes in either a Proc object or
|
2236
|
+
# # Aws::BedrockRuntime::EventStreams::ResponseStream object.
|
2237
|
+
#
|
2238
|
+
# # Usage pattern a): Callbacks with a block attached to #invoke_model_with_response_stream
|
2239
|
+
# # Example for registering callbacks for all event types and an error event
|
2240
|
+
# client.invoke_model_with_response_stream(
|
2241
|
+
# # params input
|
2242
|
+
# ) do |stream|
|
2243
|
+
# stream.on_error_event do |event|
|
2244
|
+
# # catch unmodeled error event in the stream
|
2245
|
+
# raise event
|
2246
|
+
# # => Aws::Errors::EventError
|
2247
|
+
# # event.event_type => :error
|
2248
|
+
# # event.error_code => String
|
2249
|
+
# # event.error_message => String
|
2251
2250
|
# end
|
2252
2251
|
#
|
2253
|
-
#
|
2254
|
-
#
|
2255
|
-
#
|
2256
|
-
#
|
2257
|
-
#
|
2258
|
-
# handler = Aws::BedrockRuntime::EventStreams::ResponseStream.new
|
2259
|
-
# handler.on_chunk_event do |event|
|
2260
|
-
# event # => Aws::BedrockRuntime::Types::chunk
|
2261
|
-
# end
|
2262
|
-
# handler.on_internal_server_exception_event do |event|
|
2263
|
-
# event # => Aws::BedrockRuntime::Types::internalServerException
|
2264
|
-
# end
|
2265
|
-
# handler.on_model_stream_error_exception_event do |event|
|
2266
|
-
# event # => Aws::BedrockRuntime::Types::modelStreamErrorException
|
2267
|
-
# end
|
2268
|
-
# handler.on_validation_exception_event do |event|
|
2269
|
-
# event # => Aws::BedrockRuntime::Types::validationException
|
2270
|
-
# end
|
2271
|
-
# handler.on_throttling_exception_event do |event|
|
2272
|
-
# event # => Aws::BedrockRuntime::Types::throttlingException
|
2273
|
-
# end
|
2274
|
-
# handler.on_model_timeout_exception_event do |event|
|
2275
|
-
# event # => Aws::BedrockRuntime::Types::modelTimeoutException
|
2276
|
-
# end
|
2277
|
-
# handler.on_service_unavailable_exception_event do |event|
|
2278
|
-
# event # => Aws::BedrockRuntime::Types::serviceUnavailableException
|
2279
|
-
# end
|
2280
|
-
#
|
2281
|
-
# client.invoke_model_with_response_stream( # params input #, event_stream_handler: handler)
|
2282
|
-
#
|
2283
|
-
# 2) Use a Ruby Proc object
|
2284
|
-
# Example for registering callbacks with specific events
|
2285
|
-
#
|
2286
|
-
# handler = Proc.new do |stream|
|
2287
|
-
# stream.on_chunk_event do |event|
|
2288
|
-
# event # => Aws::BedrockRuntime::Types::chunk
|
2289
|
-
# end
|
2290
|
-
# stream.on_internal_server_exception_event do |event|
|
2291
|
-
# event # => Aws::BedrockRuntime::Types::internalServerException
|
2292
|
-
# end
|
2293
|
-
# stream.on_model_stream_error_exception_event do |event|
|
2294
|
-
# event # => Aws::BedrockRuntime::Types::modelStreamErrorException
|
2295
|
-
# end
|
2296
|
-
# stream.on_validation_exception_event do |event|
|
2297
|
-
# event # => Aws::BedrockRuntime::Types::validationException
|
2298
|
-
# end
|
2299
|
-
# stream.on_throttling_exception_event do |event|
|
2300
|
-
# event # => Aws::BedrockRuntime::Types::throttlingException
|
2301
|
-
# end
|
2302
|
-
# stream.on_model_timeout_exception_event do |event|
|
2303
|
-
# event # => Aws::BedrockRuntime::Types::modelTimeoutException
|
2304
|
-
# end
|
2305
|
-
# stream.on_service_unavailable_exception_event do |event|
|
2306
|
-
# event # => Aws::BedrockRuntime::Types::serviceUnavailableException
|
2307
|
-
# end
|
2252
|
+
# stream.on_event do |event|
|
2253
|
+
# # process all events arrive
|
2254
|
+
# puts event.event_type
|
2255
|
+
# # ...
|
2308
2256
|
# end
|
2309
|
-
#
|
2310
|
-
#
|
2311
|
-
#
|
2312
|
-
#
|
2313
|
-
#
|
2314
|
-
#
|
2315
|
-
#
|
2316
|
-
#
|
2317
|
-
#
|
2318
|
-
#
|
2319
|
-
#
|
2320
|
-
#
|
2321
|
-
#
|
2322
|
-
#
|
2323
|
-
#
|
2324
|
-
#
|
2325
|
-
#
|
2326
|
-
#
|
2327
|
-
#
|
2328
|
-
#
|
2329
|
-
#
|
2330
|
-
#
|
2331
|
-
#
|
2332
|
-
#
|
2333
|
-
#
|
2334
|
-
#
|
2335
|
-
#
|
2336
|
-
#
|
2337
|
-
#
|
2338
|
-
#
|
2339
|
-
#
|
2340
|
-
#
|
2341
|
-
#
|
2342
|
-
#
|
2343
|
-
#
|
2344
|
-
#
|
2345
|
-
#
|
2257
|
+
# end
|
2258
|
+
#
|
2259
|
+
# # Usage pattern b): Pass in `:event_stream_handler` for #invoke_model_with_response_stream
|
2260
|
+
# # 1) Create a Aws::BedrockRuntime::EventStreams::ResponseStream object
|
2261
|
+
# # Example for registering callbacks with specific events
|
2262
|
+
#
|
2263
|
+
# handler = Aws::BedrockRuntime::EventStreams::ResponseStream.new
|
2264
|
+
# handler.on_chunk_event do |event|
|
2265
|
+
# event # => Aws::BedrockRuntime::Types::chunk
|
2266
|
+
# end
|
2267
|
+
# handler.on_internal_server_exception_event do |event|
|
2268
|
+
# event # => Aws::BedrockRuntime::Types::internalServerException
|
2269
|
+
# end
|
2270
|
+
# handler.on_model_stream_error_exception_event do |event|
|
2271
|
+
# event # => Aws::BedrockRuntime::Types::modelStreamErrorException
|
2272
|
+
# end
|
2273
|
+
# handler.on_validation_exception_event do |event|
|
2274
|
+
# event # => Aws::BedrockRuntime::Types::validationException
|
2275
|
+
# end
|
2276
|
+
# handler.on_throttling_exception_event do |event|
|
2277
|
+
# event # => Aws::BedrockRuntime::Types::throttlingException
|
2278
|
+
# end
|
2279
|
+
# handler.on_model_timeout_exception_event do |event|
|
2280
|
+
# event # => Aws::BedrockRuntime::Types::modelTimeoutException
|
2281
|
+
# end
|
2282
|
+
# handler.on_service_unavailable_exception_event do |event|
|
2283
|
+
# event # => Aws::BedrockRuntime::Types::serviceUnavailableException
|
2284
|
+
# end
|
2285
|
+
#
|
2286
|
+
# client.invoke_model_with_response_stream(
|
2287
|
+
# # params inputs
|
2288
|
+
# event_stream_handler: handler
|
2289
|
+
# )
|
2290
|
+
#
|
2291
|
+
# # 2) Use a Ruby Proc object
|
2292
|
+
# # Example for registering callbacks with specific events
|
2293
|
+
# handler = Proc.new do |stream|
|
2294
|
+
# stream.on_chunk_event do |event|
|
2295
|
+
# event # => Aws::BedrockRuntime::Types::chunk
|
2346
2296
|
# end
|
2297
|
+
# stream.on_internal_server_exception_event do |event|
|
2298
|
+
# event # => Aws::BedrockRuntime::Types::internalServerException
|
2299
|
+
# end
|
2300
|
+
# stream.on_model_stream_error_exception_event do |event|
|
2301
|
+
# event # => Aws::BedrockRuntime::Types::modelStreamErrorException
|
2302
|
+
# end
|
2303
|
+
# stream.on_validation_exception_event do |event|
|
2304
|
+
# event # => Aws::BedrockRuntime::Types::validationException
|
2305
|
+
# end
|
2306
|
+
# stream.on_throttling_exception_event do |event|
|
2307
|
+
# event # => Aws::BedrockRuntime::Types::throttlingException
|
2308
|
+
# end
|
2309
|
+
# stream.on_model_timeout_exception_event do |event|
|
2310
|
+
# event # => Aws::BedrockRuntime::Types::modelTimeoutException
|
2311
|
+
# end
|
2312
|
+
# stream.on_service_unavailable_exception_event do |event|
|
2313
|
+
# event # => Aws::BedrockRuntime::Types::serviceUnavailableException
|
2314
|
+
# end
|
2315
|
+
# end
|
2316
|
+
#
|
2317
|
+
# client.invoke_model_with_response_stream(
|
2318
|
+
# # params inputs
|
2319
|
+
# event_stream_handler: handler
|
2320
|
+
# )
|
2321
|
+
#
|
2322
|
+
# # Usage pattern c): Hybrid pattern of a) and b)
|
2323
|
+
# handler = Aws::BedrockRuntime::EventStreams::ResponseStream.new
|
2324
|
+
# handler.on_chunk_event do |event|
|
2325
|
+
# event # => Aws::BedrockRuntime::Types::chunk
|
2326
|
+
# end
|
2327
|
+
# handler.on_internal_server_exception_event do |event|
|
2328
|
+
# event # => Aws::BedrockRuntime::Types::internalServerException
|
2329
|
+
# end
|
2330
|
+
# handler.on_model_stream_error_exception_event do |event|
|
2331
|
+
# event # => Aws::BedrockRuntime::Types::modelStreamErrorException
|
2332
|
+
# end
|
2333
|
+
# handler.on_validation_exception_event do |event|
|
2334
|
+
# event # => Aws::BedrockRuntime::Types::validationException
|
2335
|
+
# end
|
2336
|
+
# handler.on_throttling_exception_event do |event|
|
2337
|
+
# event # => Aws::BedrockRuntime::Types::throttlingException
|
2338
|
+
# end
|
2339
|
+
# handler.on_model_timeout_exception_event do |event|
|
2340
|
+
# event # => Aws::BedrockRuntime::Types::modelTimeoutException
|
2341
|
+
# end
|
2342
|
+
# handler.on_service_unavailable_exception_event do |event|
|
2343
|
+
# event # => Aws::BedrockRuntime::Types::serviceUnavailableException
|
2344
|
+
# end
|
2345
|
+
#
|
2346
|
+
# client.invoke_model_with_response_stream(
|
2347
|
+
# # params input
|
2348
|
+
# event_stream_handler: handler
|
2349
|
+
# ) do |stream|
|
2350
|
+
# stream.on_error_event do |event|
|
2351
|
+
# # catch unmodeled error event in the stream
|
2352
|
+
# raise event
|
2353
|
+
# # => Aws::Errors::EventError
|
2354
|
+
# # event.event_type => :error
|
2355
|
+
# # event.error_code => String
|
2356
|
+
# # event.error_message => String
|
2357
|
+
# end
|
2358
|
+
# end
|
2347
2359
|
#
|
2348
|
-
# You can also iterate through events after the response complete.
|
2349
|
-
#
|
2350
|
-
#
|
2351
|
-
# For parameter input example, please refer to following request syntax
|
2360
|
+
# # You can also iterate through events after the response complete.
|
2361
|
+
# # Events are available at
|
2362
|
+
# resp.body # => Enumerator
|
2363
|
+
# # For parameter input example, please refer to following request syntax.
|
2352
2364
|
#
|
2353
2365
|
# @example Request syntax with placeholder values
|
2354
2366
|
#
|
@@ -2365,31 +2377,31 @@ module Aws::BedrockRuntime
|
|
2365
2377
|
#
|
2366
2378
|
# @example Response structure
|
2367
2379
|
#
|
2368
|
-
# All events are available at resp.body:
|
2380
|
+
# # All events are available at resp.body:
|
2369
2381
|
# resp.body #=> Enumerator
|
2370
2382
|
# resp.body.event_types #=> [:chunk, :internal_server_exception, :model_stream_error_exception, :validation_exception, :throttling_exception, :model_timeout_exception, :service_unavailable_exception]
|
2371
2383
|
#
|
2372
|
-
# For :chunk event available at #on_chunk_event callback and response eventstream enumerator:
|
2384
|
+
# # For :chunk event available at #on_chunk_event callback and response eventstream enumerator:
|
2373
2385
|
# event.bytes #=> String
|
2374
2386
|
#
|
2375
|
-
# For :internal_server_exception event available at #on_internal_server_exception_event callback and response eventstream enumerator:
|
2387
|
+
# # For :internal_server_exception event available at #on_internal_server_exception_event callback and response eventstream enumerator:
|
2376
2388
|
# event.message #=> String
|
2377
2389
|
#
|
2378
|
-
# For :model_stream_error_exception event available at #on_model_stream_error_exception_event callback and response eventstream enumerator:
|
2390
|
+
# # For :model_stream_error_exception event available at #on_model_stream_error_exception_event callback and response eventstream enumerator:
|
2379
2391
|
# event.message #=> String
|
2380
2392
|
# event.original_status_code #=> Integer
|
2381
2393
|
# event.original_message #=> String
|
2382
2394
|
#
|
2383
|
-
# For :validation_exception event available at #on_validation_exception_event callback and response eventstream enumerator:
|
2395
|
+
# # For :validation_exception event available at #on_validation_exception_event callback and response eventstream enumerator:
|
2384
2396
|
# event.message #=> String
|
2385
2397
|
#
|
2386
|
-
# For :throttling_exception event available at #on_throttling_exception_event callback and response eventstream enumerator:
|
2398
|
+
# # For :throttling_exception event available at #on_throttling_exception_event callback and response eventstream enumerator:
|
2387
2399
|
# event.message #=> String
|
2388
2400
|
#
|
2389
|
-
# For :model_timeout_exception event available at #on_model_timeout_exception_event callback and response eventstream enumerator:
|
2401
|
+
# # For :model_timeout_exception event available at #on_model_timeout_exception_event callback and response eventstream enumerator:
|
2390
2402
|
# event.message #=> String
|
2391
2403
|
#
|
2392
|
-
# For :service_unavailable_exception event available at #on_service_unavailable_exception_event callback and response eventstream enumerator:
|
2404
|
+
# # For :service_unavailable_exception event available at #on_service_unavailable_exception_event callback and response eventstream enumerator:
|
2393
2405
|
# event.message #=> String
|
2394
2406
|
#
|
2395
2407
|
# resp.content_type #=> String
|
@@ -2588,7 +2600,7 @@ module Aws::BedrockRuntime
|
|
2588
2600
|
tracer: tracer
|
2589
2601
|
)
|
2590
2602
|
context[:gem_name] = 'aws-sdk-bedrockruntime'
|
2591
|
-
context[:gem_version] = '1.
|
2603
|
+
context[:gem_version] = '1.46.0'
|
2592
2604
|
Seahorse::Client::Request.new(handlers, context)
|
2593
2605
|
end
|
2594
2606
|
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# WARNING ABOUT GENERATED CODE
|
2
|
+
#
|
3
|
+
# This file is generated. See the contributing guide for more information:
|
4
|
+
# https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
|
5
|
+
#
|
6
|
+
# WARNING ABOUT GENERATED CODE
|
7
|
+
|
8
|
+
module Aws
|
9
|
+
module BedrockRuntime
|
10
|
+
class AsyncClient < ::Seahorse::Client::AsyncBase
|
11
|
+
include ::Aws::AsyncClientStubs
|
12
|
+
|
13
|
+
# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/BedrockRuntime/AsyncClient.html#initialize-instance_method
|
14
|
+
def self.new: (
|
15
|
+
?credentials: untyped,
|
16
|
+
?region: String,
|
17
|
+
?access_key_id: String,
|
18
|
+
?account_id: String,
|
19
|
+
?adaptive_retry_wait_to_fill: bool,
|
20
|
+
?convert_params: bool,
|
21
|
+
?correct_clock_skew: bool,
|
22
|
+
?defaults_mode: String,
|
23
|
+
?disable_request_compression: bool,
|
24
|
+
?endpoint: String,
|
25
|
+
?event_stream_handler: Proc,
|
26
|
+
?ignore_configured_endpoint_urls: bool,
|
27
|
+
?input_event_stream_handler: Proc,
|
28
|
+
?log_formatter: untyped,
|
29
|
+
?log_level: Symbol,
|
30
|
+
?logger: untyped,
|
31
|
+
?max_attempts: Integer,
|
32
|
+
?output_event_stream_handler: Proc,
|
33
|
+
?profile: String,
|
34
|
+
?request_checksum_calculation: String,
|
35
|
+
?request_min_compression_size_bytes: Integer,
|
36
|
+
?response_checksum_validation: String,
|
37
|
+
?retry_backoff: Proc,
|
38
|
+
?retry_base_delay: Float,
|
39
|
+
?retry_jitter: (:none | :equal | :full | ^(Integer) -> Integer),
|
40
|
+
?retry_limit: Integer,
|
41
|
+
?retry_max_delay: Integer,
|
42
|
+
?retry_mode: ("legacy" | "standard" | "adaptive"),
|
43
|
+
?sdk_ua_app_id: String,
|
44
|
+
?secret_access_key: String,
|
45
|
+
?session_token: String,
|
46
|
+
?sigv4a_signing_region_set: Array[String],
|
47
|
+
?stub_responses: untyped,
|
48
|
+
?telemetry_provider: Aws::Telemetry::TelemetryProviderBase,
|
49
|
+
?token_provider: untyped,
|
50
|
+
?use_dualstack_endpoint: bool,
|
51
|
+
?use_fips_endpoint: bool,
|
52
|
+
?validate_params: bool,
|
53
|
+
?endpoint_provider: untyped,
|
54
|
+
?connection_read_timeout: (Float | Integer),
|
55
|
+
?connection_timeout: (Float | Integer),
|
56
|
+
?enable_alpn: bool,
|
57
|
+
?max_concurrent_streams: (Float | Integer),
|
58
|
+
?read_chunk_size: (Float | Integer),
|
59
|
+
?http_wire_trace: bool,
|
60
|
+
?ssl_verify_peer: bool,
|
61
|
+
?ssl_ca_bundle: String,
|
62
|
+
?ssl_ca_directory: String,
|
63
|
+
?ssl_ca_store: String,
|
64
|
+
?raise_response_errors: bool
|
65
|
+
) -> instance
|
66
|
+
| (?Hash[Symbol, untyped]) -> instance
|
67
|
+
|
68
|
+
|
69
|
+
interface _InvokeModelWithBidirectionalStreamResponseSuccess
|
70
|
+
include ::Seahorse::Client::_ResponseSuccess[Types::InvokeModelWithBidirectionalStreamResponse]
|
71
|
+
def body: () -> Types::InvokeModelWithBidirectionalStreamOutput
|
72
|
+
end
|
73
|
+
# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/BedrockRuntime/AsyncClient.html#invoke_model_with_bidirectional_stream-instance_method
|
74
|
+
def invoke_model_with_bidirectional_stream: (
|
75
|
+
model_id: ::String,
|
76
|
+
input_event_stream_handler: untyped,
|
77
|
+
output_event_stream_handler: untyped
|
78
|
+
) ?{ (*untyped) -> void } -> _InvokeModelWithBidirectionalStreamResponseSuccess
|
79
|
+
| (Hash[Symbol, untyped] params, ?Hash[Symbol, untyped] options) ?{ (*untyped) -> void } -> _InvokeModelWithBidirectionalStreamResponseSuccess
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/sig/client.rbs
CHANGED
@@ -532,17 +532,6 @@ module Aws
|
|
532
532
|
) -> _InvokeModelResponseSuccess
|
533
533
|
| (Hash[Symbol, untyped] params, ?Hash[Symbol, untyped] options) -> _InvokeModelResponseSuccess
|
534
534
|
|
535
|
-
interface _InvokeModelWithBidirectionalStreamResponseSuccess
|
536
|
-
include ::Seahorse::Client::_ResponseSuccess[Types::InvokeModelWithBidirectionalStreamResponse]
|
537
|
-
def body: () -> Types::InvokeModelWithBidirectionalStreamOutput
|
538
|
-
end
|
539
|
-
# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/BedrockRuntime/Client.html#invoke_model_with_bidirectional_stream-instance_method
|
540
|
-
def invoke_model_with_bidirectional_stream: (
|
541
|
-
model_id: ::String,
|
542
|
-
input_event_stream_hander: untyped
|
543
|
-
) ?{ (*untyped) -> void } -> _InvokeModelWithBidirectionalStreamResponseSuccess
|
544
|
-
| (Hash[Symbol, untyped] params, ?Hash[Symbol, untyped] options) ?{ (*untyped) -> void } -> _InvokeModelWithBidirectionalStreamResponseSuccess
|
545
|
-
|
546
535
|
interface _InvokeModelWithResponseStreamResponseSuccess
|
547
536
|
include ::Seahorse::Client::_ResponseSuccess[Types::InvokeModelWithResponseStreamResponse]
|
548
537
|
def body: () -> Types::ResponseStream
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-sdk-bedrockruntime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.46.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amazon Web Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- lib/aws-sdk-bedrockruntime/resource.rb
|
70
70
|
- lib/aws-sdk-bedrockruntime/types.rb
|
71
71
|
- lib/aws-sdk-bedrockruntime/waiters.rb
|
72
|
+
- sig/async_client.rbs
|
72
73
|
- sig/client.rbs
|
73
74
|
- sig/errors.rbs
|
74
75
|
- sig/resource.rbs
|