aws-sdk-bedrockruntime 1.8.0 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 379fc87c980cf6cb474ea0ae2077550160a60d59b81e98add9322c1de98d2b92
4
- data.tar.gz: 0fb0feb9d93fc1f9ec7fe2e183475a97882a40ed337c932b8272a96172bbe691
3
+ metadata.gz: e0e0200afdf318bf8b42e56aa891f1c946e2ec4e9d7809d27eb667fa6cbc8387
4
+ data.tar.gz: 1fede36e7d7af358c468cef01370b6638486dc034f6b73e830d500ad692f9d86
5
5
  SHA512:
6
- metadata.gz: 539cc2b947f978c80d5c4529c39f93cfa40ea9aa4435d67f68471a804ea35fe7e4cdc99b19104bcad35ea07c2c8f96a572fb98a258600dfc2472a190ec1b9334
7
- data.tar.gz: f791f4021fbb59a3c05eaaa817a1e34d3de5b019ff98e1dada30c8345cd7a8923531badde15819bf5f925680de9c6ad3f7374f28a44463e06e49a3d7dd21c983
6
+ metadata.gz: c78778047928bc6fec7f83e47fb6e23016e760d1da29ea312d5a36dcb88612e69c878d6bedf5ed27f1ece1a6295f60114161e277c1b2552db09fae535b7ccc07
7
+ data.tar.gz: f8ae819ac4a3205c105e66b2195867a45e600ac7001f878f3730662c15536080fe52ba2affe3d06340b5352f31780efcd9d969ee73148f4aceefa297eb00a0dd
data/CHANGELOG.md CHANGED
@@ -1,6 +1,16 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 1.10.0 (2024-06-05)
5
+ ------------------
6
+
7
+ * Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
8
+
9
+ 1.9.0 (2024-05-30)
10
+ ------------------
11
+
12
+ * Feature - This release adds Converse and ConverseStream APIs to Bedrock Runtime
13
+
4
14
  1.8.0 (2024-05-13)
5
15
  ------------------
6
16
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.8.0
1
+ 1.10.0
@@ -424,6 +424,639 @@ module Aws::BedrockRuntime
424
424
 
425
425
  # @!group API Operations
426
426
 
427
+ # Sends messages to the specified Amazon Bedrock model. `Converse`
428
+ # provides a consistent interface that works with all models that
429
+ # support messages. This allows you to write code once and use it with
430
+ # different models. Should a model have unique inference parameters, you
431
+ # can also pass those unique parameters to the model. For more
432
+ # information, see [Run inference][1] in the Bedrock User Guide.
433
+ #
434
+ # This operation requires permission for the `bedrock:InvokeModel`
435
+ # action.
436
+ #
437
+ #
438
+ #
439
+ # [1]: https://docs.aws.amazon.com/bedrock/latest/userguide/api-methods-run.html
440
+ #
441
+ # @option params [required, String] :model_id
442
+ # The identifier for the model that you want to call.
443
+ #
444
+ # The `modelId` to provide depends on the type of model that you use:
445
+ #
446
+ # * If you use a base model, specify the model ID or its ARN. For a list
447
+ # of model IDs for base models, see [Amazon Bedrock base model IDs
448
+ # (on-demand throughput)][1] in the Amazon Bedrock User Guide.
449
+ #
450
+ # * If you use a provisioned model, specify the ARN of the Provisioned
451
+ # Throughput. For more information, see [Run inference using a
452
+ # Provisioned Throughput][2] in the Amazon Bedrock User Guide.
453
+ #
454
+ # * If you use a custom model, first purchase Provisioned Throughput for
455
+ # it. Then specify the ARN of the resulting provisioned model. For
456
+ # more information, see [Use a custom model in Amazon Bedrock][3] in
457
+ # the Amazon Bedrock User Guide.
458
+ #
459
+ #
460
+ #
461
+ # [1]: https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids.html#model-ids-arns
462
+ # [2]: https://docs.aws.amazon.com/bedrock/latest/userguide/prov-thru-use.html
463
+ # [3]: https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-use.html
464
+ #
465
+ # @option params [required, Array<Types::Message>] :messages
466
+ # The messages that you want to send to the model.
467
+ #
468
+ # @option params [Array<Types::SystemContentBlock>] :system
469
+ # A system prompt to pass to the model.
470
+ #
471
+ # @option params [Types::InferenceConfiguration] :inference_config
472
+ # Inference parameters to pass to the model. `Converse` supports a base
473
+ # set of inference parameters. If you need to pass additional parameters
474
+ # that the model supports, use the `additionalModelRequestFields`
475
+ # request field.
476
+ #
477
+ # @option params [Types::ToolConfiguration] :tool_config
478
+ # Configuration information for the tools that the model can use when
479
+ # generating a response.
480
+ #
481
+ # <note markdown="1"> This field is only supported by Anthropic Claude 3, Cohere Command R,
482
+ # Cohere Command R+, and Mistral Large models.
483
+ #
484
+ # </note>
485
+ #
486
+ # @option params [Hash,Array,String,Numeric,Boolean] :additional_model_request_fields
487
+ # Additional inference parameters that the model supports, beyond the
488
+ # base set of inference parameters that `Converse` supports in the
489
+ # `inferenceConfig` field. For more information, see [Model
490
+ # parameters][1].
491
+ #
492
+ # Document type used to carry open content
493
+ # (Hash,Array,String,Numeric,Boolean). A document type value is
494
+ # serialized using the same format as its surroundings and requires no
495
+ # additional encoding or escaping.
496
+ #
497
+ #
498
+ #
499
+ # [1]: https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html
500
+ #
501
+ # @option params [Array<String>] :additional_model_response_field_paths
502
+ # Additional model parameters field paths to return in the response.
503
+ # `Converse` returns the requested fields as a JSON Pointer object in
504
+ # the `additionalModelResultFields` field. The following is example JSON
505
+ # for `additionalModelResponseFieldPaths`.
506
+ #
507
+ # `[ "/stop_sequence" ]`
508
+ #
509
+ # For information about the JSON Pointer syntax, see the [Internet
510
+ # Engineering Task Force (IETF)][1] documentation.
511
+ #
512
+ # `Converse` rejects an empty JSON Pointer or incorrectly structured
513
+ # JSON Pointer with a `400` error code. if the JSON Pointer is valid,
514
+ # but the requested field is not in the model response, it is ignored by
515
+ # `Converse`.
516
+ #
517
+ #
518
+ #
519
+ # [1]: https://datatracker.ietf.org/doc/html/rfc6901
520
+ #
521
+ # @return [Types::ConverseResponse] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
522
+ #
523
+ # * {Types::ConverseResponse#output #output} => Types::ConverseOutput
524
+ # * {Types::ConverseResponse#stop_reason #stop_reason} => String
525
+ # * {Types::ConverseResponse#usage #usage} => Types::TokenUsage
526
+ # * {Types::ConverseResponse#metrics #metrics} => Types::ConverseMetrics
527
+ # * {Types::ConverseResponse#additional_model_response_fields #additional_model_response_fields} => Hash,Array,String,Numeric,Boolean
528
+ #
529
+ # @example Request syntax with placeholder values
530
+ #
531
+ # resp = client.converse({
532
+ # model_id: "ConversationalModelId", # required
533
+ # messages: [ # required
534
+ # {
535
+ # role: "user", # required, accepts user, assistant
536
+ # content: [ # required
537
+ # {
538
+ # text: "String",
539
+ # image: {
540
+ # format: "png", # required, accepts png, jpeg, gif, webp
541
+ # source: { # required
542
+ # bytes: "data",
543
+ # },
544
+ # },
545
+ # tool_use: {
546
+ # tool_use_id: "ToolUseId", # required
547
+ # name: "ToolName", # required
548
+ # input: { # required
549
+ # },
550
+ # },
551
+ # tool_result: {
552
+ # tool_use_id: "ToolUseId", # required
553
+ # content: [ # required
554
+ # {
555
+ # json: {
556
+ # },
557
+ # text: "String",
558
+ # image: {
559
+ # format: "png", # required, accepts png, jpeg, gif, webp
560
+ # source: { # required
561
+ # bytes: "data",
562
+ # },
563
+ # },
564
+ # },
565
+ # ],
566
+ # status: "success", # accepts success, error
567
+ # },
568
+ # },
569
+ # ],
570
+ # },
571
+ # ],
572
+ # system: [
573
+ # {
574
+ # text: "NonEmptyString",
575
+ # },
576
+ # ],
577
+ # inference_config: {
578
+ # max_tokens: 1,
579
+ # temperature: 1.0,
580
+ # top_p: 1.0,
581
+ # stop_sequences: ["NonEmptyString"],
582
+ # },
583
+ # tool_config: {
584
+ # tools: [ # required
585
+ # {
586
+ # tool_spec: {
587
+ # name: "ToolName", # required
588
+ # description: "NonEmptyString",
589
+ # input_schema: { # required
590
+ # json: {
591
+ # },
592
+ # },
593
+ # },
594
+ # },
595
+ # ],
596
+ # tool_choice: {
597
+ # auto: {
598
+ # },
599
+ # any: {
600
+ # },
601
+ # tool: {
602
+ # name: "ToolName", # required
603
+ # },
604
+ # },
605
+ # },
606
+ # additional_model_request_fields: {
607
+ # },
608
+ # additional_model_response_field_paths: ["ConverseRequestAdditionalModelResponseFieldPathsListMemberString"],
609
+ # })
610
+ #
611
+ # @example Response structure
612
+ #
613
+ # resp.output.message.role #=> String, one of "user", "assistant"
614
+ # resp.output.message.content #=> Array
615
+ # resp.output.message.content[0].text #=> String
616
+ # resp.output.message.content[0].image.format #=> String, one of "png", "jpeg", "gif", "webp"
617
+ # resp.output.message.content[0].image.source.bytes #=> String
618
+ # resp.output.message.content[0].tool_use.tool_use_id #=> String
619
+ # resp.output.message.content[0].tool_use.name #=> String
620
+ # resp.output.message.content[0].tool_result.tool_use_id #=> String
621
+ # resp.output.message.content[0].tool_result.content #=> Array
622
+ # resp.output.message.content[0].tool_result.content[0].text #=> String
623
+ # resp.output.message.content[0].tool_result.content[0].image.format #=> String, one of "png", "jpeg", "gif", "webp"
624
+ # resp.output.message.content[0].tool_result.content[0].image.source.bytes #=> String
625
+ # resp.output.message.content[0].tool_result.status #=> String, one of "success", "error"
626
+ # resp.stop_reason #=> String, one of "end_turn", "tool_use", "max_tokens", "stop_sequence", "content_filtered"
627
+ # resp.usage.input_tokens #=> Integer
628
+ # resp.usage.output_tokens #=> Integer
629
+ # resp.usage.total_tokens #=> Integer
630
+ # resp.metrics.latency_ms #=> Integer
631
+ #
632
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/Converse AWS API Documentation
633
+ #
634
+ # @overload converse(params = {})
635
+ # @param [Hash] params ({})
636
+ def converse(params = {}, options = {})
637
+ req = build_request(:converse, params)
638
+ req.send_request(options)
639
+ end
640
+
641
+ # Sends messages to the specified Amazon Bedrock model and returns the
642
+ # response in a stream. `ConverseStream` provides a consistent API that
643
+ # works with all Amazon Bedrock models that support messages. This
644
+ # allows you to write code once and use it with different models. Should
645
+ # a model have unique inference parameters, you can also pass those
646
+ # unique parameters to the model. For more information, see [Run
647
+ # inference][1] in the Bedrock User Guide.
648
+ #
649
+ # To find out if a model supports streaming, call
650
+ # [GetFoundationModel][2] and check the `responseStreamingSupported`
651
+ # field in the response.
652
+ #
653
+ # For example code, see *Invoke model with streaming code example* in
654
+ # the *Amazon Bedrock User Guide*.
655
+ #
656
+ # This operation requires permission for the
657
+ # `bedrock:InvokeModelWithResponseStream` action.
658
+ #
659
+ #
660
+ #
661
+ # [1]: https://docs.aws.amazon.com/bedrock/latest/userguide/api-methods-run.html
662
+ # [2]: https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GetFoundationModel.html
663
+ #
664
+ # @option params [required, String] :model_id
665
+ # The ID for the model.
666
+ #
667
+ # The `modelId` to provide depends on the type of model that you use:
668
+ #
669
+ # * If you use a base model, specify the model ID or its ARN. For a list
670
+ # of model IDs for base models, see [Amazon Bedrock base model IDs
671
+ # (on-demand throughput)][1] in the Amazon Bedrock User Guide.
672
+ #
673
+ # * If you use a provisioned model, specify the ARN of the Provisioned
674
+ # Throughput. For more information, see [Run inference using a
675
+ # Provisioned Throughput][2] in the Amazon Bedrock User Guide.
676
+ #
677
+ # * If you use a custom model, first purchase Provisioned Throughput for
678
+ # it. Then specify the ARN of the resulting provisioned model. For
679
+ # more information, see [Use a custom model in Amazon Bedrock][3] in
680
+ # the Amazon Bedrock User Guide.
681
+ #
682
+ #
683
+ #
684
+ # [1]: https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids.html#model-ids-arns
685
+ # [2]: https://docs.aws.amazon.com/bedrock/latest/userguide/prov-thru-use.html
686
+ # [3]: https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-use.html
687
+ #
688
+ # @option params [required, Array<Types::Message>] :messages
689
+ # The messages that you want to send to the model.
690
+ #
691
+ # @option params [Array<Types::SystemContentBlock>] :system
692
+ # A system prompt to send to the model.
693
+ #
694
+ # @option params [Types::InferenceConfiguration] :inference_config
695
+ # Inference parameters to pass to the model. `ConverseStream` supports a
696
+ # base set of inference parameters. If you need to pass additional
697
+ # parameters that the model supports, use the
698
+ # `additionalModelRequestFields` request field.
699
+ #
700
+ # @option params [Types::ToolConfiguration] :tool_config
701
+ # Configuration information for the tools that the model can use when
702
+ # generating a response.
703
+ #
704
+ # <note markdown="1"> This field is only supported by Anthropic Claude 3 models.
705
+ #
706
+ # </note>
707
+ #
708
+ # @option params [Hash,Array,String,Numeric,Boolean] :additional_model_request_fields
709
+ # Additional inference parameters that the model supports, beyond the
710
+ # base set of inference parameters that `ConverseStream` supports in the
711
+ # `inferenceConfig` field.
712
+ #
713
+ # Document type used to carry open content
714
+ # (Hash,Array,String,Numeric,Boolean). A document type value is
715
+ # serialized using the same format as its surroundings and requires no
716
+ # additional encoding or escaping.
717
+ #
718
+ # @option params [Array<String>] :additional_model_response_field_paths
719
+ # Additional model parameters field paths to return in the response.
720
+ # `ConverseStream` returns the requested fields as a JSON Pointer object
721
+ # in the `additionalModelResultFields` field. The following is example
722
+ # JSON for `additionalModelResponseFieldPaths`.
723
+ #
724
+ # `[ "/stop_sequence" ]`
725
+ #
726
+ # For information about the JSON Pointer syntax, see the [Internet
727
+ # Engineering Task Force (IETF)][1] documentation.
728
+ #
729
+ # `ConverseStream` rejects an empty JSON Pointer or incorrectly
730
+ # structured JSON Pointer with a `400` error code. if the JSON Pointer
731
+ # is valid, but the requested field is not in the model response, it is
732
+ # ignored by `ConverseStream`.
733
+ #
734
+ #
735
+ #
736
+ # [1]: https://datatracker.ietf.org/doc/html/rfc6901
737
+ #
738
+ # @return [Types::ConverseStreamResponse] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
739
+ #
740
+ # * {Types::ConverseStreamResponse#stream #stream} => Types::ConverseStreamOutput
741
+ #
742
+ # @example EventStream Operation Example
743
+ #
744
+ # You can process the event once it arrives immediately, or wait until the
745
+ # full response is complete and iterate through the eventstream enumerator.
746
+ #
747
+ # To interact with event immediately, you need to register #converse_stream
748
+ # with callbacks. Callbacks can be registered for specific events or for all
749
+ # events, including error events.
750
+ #
751
+ # Callbacks can be passed into the `:event_stream_handler` option or within a
752
+ # block statement attached to the #converse_stream call directly. Hybrid
753
+ # pattern of both is also supported.
754
+ #
755
+ # `:event_stream_handler` option takes in either a Proc object or
756
+ # Aws::BedrockRuntime::EventStreams::ConverseStreamOutput object.
757
+ #
758
+ # Usage pattern a): Callbacks with a block attached to #converse_stream
759
+ # Example for registering callbacks for all event types and an error event
760
+ #
761
+ # client.converse_stream( # params input# ) do |stream|
762
+ # stream.on_error_event do |event|
763
+ # # catch unmodeled error event in the stream
764
+ # raise event
765
+ # # => Aws::Errors::EventError
766
+ # # event.event_type => :error
767
+ # # event.error_code => String
768
+ # # event.error_message => String
769
+ # end
770
+ #
771
+ # stream.on_event do |event|
772
+ # # process all events arrive
773
+ # puts event.event_type
774
+ # ...
775
+ # end
776
+ #
777
+ # end
778
+ #
779
+ # Usage pattern b): Pass in `:event_stream_handler` for #converse_stream
780
+ #
781
+ # 1) Create a Aws::BedrockRuntime::EventStreams::ConverseStreamOutput object
782
+ # Example for registering callbacks with specific events
783
+ #
784
+ # handler = Aws::BedrockRuntime::EventStreams::ConverseStreamOutput.new
785
+ # handler.on_message_start_event do |event|
786
+ # event # => Aws::BedrockRuntime::Types::messageStart
787
+ # end
788
+ # handler.on_content_block_start_event do |event|
789
+ # event # => Aws::BedrockRuntime::Types::contentBlockStart
790
+ # end
791
+ # handler.on_content_block_delta_event do |event|
792
+ # event # => Aws::BedrockRuntime::Types::contentBlockDelta
793
+ # end
794
+ # handler.on_content_block_stop_event do |event|
795
+ # event # => Aws::BedrockRuntime::Types::contentBlockStop
796
+ # end
797
+ # handler.on_message_stop_event do |event|
798
+ # event # => Aws::BedrockRuntime::Types::messageStop
799
+ # end
800
+ # handler.on_metadata_event do |event|
801
+ # event # => Aws::BedrockRuntime::Types::metadata
802
+ # end
803
+ # handler.on_internal_server_exception_event do |event|
804
+ # event # => Aws::BedrockRuntime::Types::internalServerException
805
+ # end
806
+ # handler.on_model_stream_error_exception_event do |event|
807
+ # event # => Aws::BedrockRuntime::Types::modelStreamErrorException
808
+ # end
809
+ # handler.on_validation_exception_event do |event|
810
+ # event # => Aws::BedrockRuntime::Types::validationException
811
+ # end
812
+ # handler.on_throttling_exception_event do |event|
813
+ # event # => Aws::BedrockRuntime::Types::throttlingException
814
+ # end
815
+ #
816
+ # client.converse_stream( # params input #, event_stream_handler: handler)
817
+ #
818
+ # 2) Use a Ruby Proc object
819
+ # Example for registering callbacks with specific events
820
+ #
821
+ # handler = Proc.new do |stream|
822
+ # stream.on_message_start_event do |event|
823
+ # event # => Aws::BedrockRuntime::Types::messageStart
824
+ # end
825
+ # stream.on_content_block_start_event do |event|
826
+ # event # => Aws::BedrockRuntime::Types::contentBlockStart
827
+ # end
828
+ # stream.on_content_block_delta_event do |event|
829
+ # event # => Aws::BedrockRuntime::Types::contentBlockDelta
830
+ # end
831
+ # stream.on_content_block_stop_event do |event|
832
+ # event # => Aws::BedrockRuntime::Types::contentBlockStop
833
+ # end
834
+ # stream.on_message_stop_event do |event|
835
+ # event # => Aws::BedrockRuntime::Types::messageStop
836
+ # end
837
+ # stream.on_metadata_event do |event|
838
+ # event # => Aws::BedrockRuntime::Types::metadata
839
+ # end
840
+ # stream.on_internal_server_exception_event do |event|
841
+ # event # => Aws::BedrockRuntime::Types::internalServerException
842
+ # end
843
+ # stream.on_model_stream_error_exception_event do |event|
844
+ # event # => Aws::BedrockRuntime::Types::modelStreamErrorException
845
+ # end
846
+ # stream.on_validation_exception_event do |event|
847
+ # event # => Aws::BedrockRuntime::Types::validationException
848
+ # end
849
+ # stream.on_throttling_exception_event do |event|
850
+ # event # => Aws::BedrockRuntime::Types::throttlingException
851
+ # end
852
+ # end
853
+ #
854
+ # client.converse_stream( # params input #, event_stream_handler: handler)
855
+ #
856
+ # Usage pattern c): Hybrid pattern of a) and b)
857
+ #
858
+ # handler = Aws::BedrockRuntime::EventStreams::ConverseStreamOutput.new
859
+ # handler.on_message_start_event do |event|
860
+ # event # => Aws::BedrockRuntime::Types::messageStart
861
+ # end
862
+ # handler.on_content_block_start_event do |event|
863
+ # event # => Aws::BedrockRuntime::Types::contentBlockStart
864
+ # end
865
+ # handler.on_content_block_delta_event do |event|
866
+ # event # => Aws::BedrockRuntime::Types::contentBlockDelta
867
+ # end
868
+ # handler.on_content_block_stop_event do |event|
869
+ # event # => Aws::BedrockRuntime::Types::contentBlockStop
870
+ # end
871
+ # handler.on_message_stop_event do |event|
872
+ # event # => Aws::BedrockRuntime::Types::messageStop
873
+ # end
874
+ # handler.on_metadata_event do |event|
875
+ # event # => Aws::BedrockRuntime::Types::metadata
876
+ # end
877
+ # handler.on_internal_server_exception_event do |event|
878
+ # event # => Aws::BedrockRuntime::Types::internalServerException
879
+ # end
880
+ # handler.on_model_stream_error_exception_event do |event|
881
+ # event # => Aws::BedrockRuntime::Types::modelStreamErrorException
882
+ # end
883
+ # handler.on_validation_exception_event do |event|
884
+ # event # => Aws::BedrockRuntime::Types::validationException
885
+ # end
886
+ # handler.on_throttling_exception_event do |event|
887
+ # event # => Aws::BedrockRuntime::Types::throttlingException
888
+ # end
889
+ #
890
+ # client.converse_stream( # params input #, event_stream_handler: handler) do |stream|
891
+ # stream.on_error_event do |event|
892
+ # # catch unmodeled error event in the stream
893
+ # raise event
894
+ # # => Aws::Errors::EventError
895
+ # # event.event_type => :error
896
+ # # event.error_code => String
897
+ # # event.error_message => String
898
+ # end
899
+ # end
900
+ #
901
+ # You can also iterate through events after the response complete.
902
+ #
903
+ # Events are available at resp.stream # => Enumerator
904
+ # For parameter input example, please refer to following request syntax
905
+ #
906
+ # @example Request syntax with placeholder values
907
+ #
908
+ # resp = client.converse_stream({
909
+ # model_id: "ConversationalModelId", # required
910
+ # messages: [ # required
911
+ # {
912
+ # role: "user", # required, accepts user, assistant
913
+ # content: [ # required
914
+ # {
915
+ # text: "String",
916
+ # image: {
917
+ # format: "png", # required, accepts png, jpeg, gif, webp
918
+ # source: { # required
919
+ # bytes: "data",
920
+ # },
921
+ # },
922
+ # tool_use: {
923
+ # tool_use_id: "ToolUseId", # required
924
+ # name: "ToolName", # required
925
+ # input: { # required
926
+ # },
927
+ # },
928
+ # tool_result: {
929
+ # tool_use_id: "ToolUseId", # required
930
+ # content: [ # required
931
+ # {
932
+ # json: {
933
+ # },
934
+ # text: "String",
935
+ # image: {
936
+ # format: "png", # required, accepts png, jpeg, gif, webp
937
+ # source: { # required
938
+ # bytes: "data",
939
+ # },
940
+ # },
941
+ # },
942
+ # ],
943
+ # status: "success", # accepts success, error
944
+ # },
945
+ # },
946
+ # ],
947
+ # },
948
+ # ],
949
+ # system: [
950
+ # {
951
+ # text: "NonEmptyString",
952
+ # },
953
+ # ],
954
+ # inference_config: {
955
+ # max_tokens: 1,
956
+ # temperature: 1.0,
957
+ # top_p: 1.0,
958
+ # stop_sequences: ["NonEmptyString"],
959
+ # },
960
+ # tool_config: {
961
+ # tools: [ # required
962
+ # {
963
+ # tool_spec: {
964
+ # name: "ToolName", # required
965
+ # description: "NonEmptyString",
966
+ # input_schema: { # required
967
+ # json: {
968
+ # },
969
+ # },
970
+ # },
971
+ # },
972
+ # ],
973
+ # tool_choice: {
974
+ # auto: {
975
+ # },
976
+ # any: {
977
+ # },
978
+ # tool: {
979
+ # name: "ToolName", # required
980
+ # },
981
+ # },
982
+ # },
983
+ # additional_model_request_fields: {
984
+ # },
985
+ # additional_model_response_field_paths: ["ConverseStreamRequestAdditionalModelResponseFieldPathsListMemberString"],
986
+ # })
987
+ #
988
+ # @example Response structure
989
+ #
990
+ # All events are available at resp.stream:
991
+ # resp.stream #=> Enumerator
992
+ # 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]
993
+ #
994
+ # For :message_start event available at #on_message_start_event callback and response eventstream enumerator:
995
+ # event.role #=> String, one of "user", "assistant"
996
+ #
997
+ # For :content_block_start event available at #on_content_block_start_event callback and response eventstream enumerator:
998
+ # event.start.tool_use.tool_use_id #=> String
999
+ # event.start.tool_use.name #=> String
1000
+ # event.content_block_index #=> Integer
1001
+ #
1002
+ # For :content_block_delta event available at #on_content_block_delta_event callback and response eventstream enumerator:
1003
+ # event.delta.text #=> String
1004
+ # event.delta.tool_use.input #=> String
1005
+ # event.content_block_index #=> Integer
1006
+ #
1007
+ # For :content_block_stop event available at #on_content_block_stop_event callback and response eventstream enumerator:
1008
+ # event.content_block_index #=> Integer
1009
+ #
1010
+ # For :message_stop event available at #on_message_stop_event callback and response eventstream enumerator:
1011
+ # event.stop_reason #=> String, one of "end_turn", "tool_use", "max_tokens", "stop_sequence", "content_filtered"
1012
+ #
1013
+ # For :metadata event available at #on_metadata_event callback and response eventstream enumerator:
1014
+ # event.usage.input_tokens #=> Integer
1015
+ # event.usage.output_tokens #=> Integer
1016
+ # event.usage.total_tokens #=> Integer
1017
+ # event.metrics.latency_ms #=> Integer
1018
+ #
1019
+ # For :internal_server_exception event available at #on_internal_server_exception_event callback and response eventstream enumerator:
1020
+ # event.message #=> String
1021
+ #
1022
+ # For :model_stream_error_exception event available at #on_model_stream_error_exception_event callback and response eventstream enumerator:
1023
+ # event.message #=> String
1024
+ # event.original_status_code #=> Integer
1025
+ # event.original_message #=> String
1026
+ #
1027
+ # For :validation_exception event available at #on_validation_exception_event callback and response eventstream enumerator:
1028
+ # event.message #=> String
1029
+ #
1030
+ # For :throttling_exception event available at #on_throttling_exception_event callback and response eventstream enumerator:
1031
+ # event.message #=> String
1032
+ #
1033
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/ConverseStream AWS API Documentation
1034
+ #
1035
+ # @overload converse_stream(params = {})
1036
+ # @param [Hash] params ({})
1037
+ def converse_stream(params = {}, options = {}, &block)
1038
+ params = params.dup
1039
+ event_stream_handler = case handler = params.delete(:event_stream_handler)
1040
+ when EventStreams::ConverseStreamOutput then handler
1041
+ when Proc then EventStreams::ConverseStreamOutput.new.tap(&handler)
1042
+ when nil then EventStreams::ConverseStreamOutput.new
1043
+ else
1044
+ msg = "expected :event_stream_handler to be a block or "\
1045
+ "instance of Aws::BedrockRuntime::EventStreams::ConverseStreamOutput"\
1046
+ ", got `#{handler.inspect}` instead"
1047
+ raise ArgumentError, msg
1048
+ end
1049
+
1050
+ yield(event_stream_handler) if block_given?
1051
+
1052
+ req = build_request(:converse_stream, params)
1053
+
1054
+ req.context[:event_stream_handler] = event_stream_handler
1055
+ req.handlers.add(Aws::Binary::DecodeHandler, priority: 95)
1056
+
1057
+ req.send_request(options, &block)
1058
+ end
1059
+
427
1060
  # Invokes the specified Amazon Bedrock model to run inference using the
428
1061
  # prompt and inference parameters provided in the request body. You use
429
1062
  # model inference to generate text, images, and embeddings.
@@ -831,7 +1464,7 @@ module Aws::BedrockRuntime
831
1464
  params: params,
832
1465
  config: config)
833
1466
  context[:gem_name] = 'aws-sdk-bedrockruntime'
834
- context[:gem_version] = '1.8.0'
1467
+ context[:gem_version] = '1.10.0'
835
1468
  Seahorse::Client::Request.new(handlers, context)
836
1469
  end
837
1470