aws-sdk-bedrockagentruntime 1.34.0 → 1.35.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -938,8 +938,46 @@ module Aws::BedrockAgentRuntime
938
938
  # },
939
939
  # },
940
940
  # },
941
+ # implicit_filter_configuration: {
942
+ # metadata_attributes: [ # required
943
+ # {
944
+ # description: "MetadataAttributeSchemaDescriptionString", # required
945
+ # key: "MetadataAttributeSchemaKeyString", # required
946
+ # type: "STRING", # required, accepts STRING, NUMBER, BOOLEAN, STRING_LIST
947
+ # },
948
+ # ],
949
+ # model_arn: "BedrockModelArn", # required
950
+ # },
941
951
  # number_of_results: 1,
942
952
  # override_search_type: "HYBRID", # accepts HYBRID, SEMANTIC
953
+ # reranking_configuration: {
954
+ # bedrock_reranking_configuration: {
955
+ # metadata_configuration: {
956
+ # selection_mode: "SELECTIVE", # required, accepts SELECTIVE, ALL
957
+ # selective_mode_configuration: {
958
+ # fields_to_exclude: [
959
+ # {
960
+ # field_name: "FieldForRerankingFieldNameString", # required
961
+ # },
962
+ # ],
963
+ # fields_to_include: [
964
+ # {
965
+ # field_name: "FieldForRerankingFieldNameString", # required
966
+ # },
967
+ # ],
968
+ # },
969
+ # },
970
+ # model_configuration: { # required
971
+ # additional_model_request_fields: {
972
+ # "AdditionalModelRequestFieldsKey" => {
973
+ # },
974
+ # },
975
+ # model_arn: "BedrockRerankingModelArn", # required
976
+ # },
977
+ # number_of_reranked_results: 1,
978
+ # },
979
+ # type: "BEDROCK_RERANKING_MODEL", # required, accepts BEDROCK_RERANKING_MODEL
980
+ # },
943
981
  # },
944
982
  # },
945
983
  # },
@@ -1006,10 +1044,11 @@ module Aws::BedrockAgentRuntime
1006
1044
  # event.attribution.citations[0].retrieved_references #=> Array
1007
1045
  # event.attribution.citations[0].retrieved_references[0].content.text #=> String
1008
1046
  # event.attribution.citations[0].retrieved_references[0].location.confluence_location.url #=> String
1047
+ # event.attribution.citations[0].retrieved_references[0].location.custom_document_location.id #=> String
1009
1048
  # event.attribution.citations[0].retrieved_references[0].location.s3_location.uri #=> String
1010
1049
  # event.attribution.citations[0].retrieved_references[0].location.salesforce_location.url #=> String
1011
1050
  # event.attribution.citations[0].retrieved_references[0].location.share_point_location.url #=> String
1012
- # event.attribution.citations[0].retrieved_references[0].location.type #=> String, one of "S3", "WEB", "CONFLUENCE", "SALESFORCE", "SHAREPOINT"
1051
+ # event.attribution.citations[0].retrieved_references[0].location.type #=> String, one of "S3", "WEB", "CONFLUENCE", "SALESFORCE", "SHAREPOINT", "CUSTOM"
1013
1052
  # event.attribution.citations[0].retrieved_references[0].location.web_location.url #=> String
1014
1053
  # event.attribution.citations[0].retrieved_references[0].metadata #=> Hash
1015
1054
  # event.bytes #=> String
@@ -1172,10 +1211,11 @@ module Aws::BedrockAgentRuntime
1172
1211
  # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references #=> Array
1173
1212
  # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].content.text #=> String
1174
1213
  # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].location.confluence_location.url #=> String
1214
+ # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].location.custom_document_location.id #=> String
1175
1215
  # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].location.s3_location.uri #=> String
1176
1216
  # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].location.salesforce_location.url #=> String
1177
1217
  # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].location.share_point_location.url #=> String
1178
- # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].location.type #=> String, one of "S3", "WEB", "CONFLUENCE", "SALESFORCE", "SHAREPOINT"
1218
+ # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].location.type #=> String, one of "S3", "WEB", "CONFLUENCE", "SALESFORCE", "SHAREPOINT", "CUSTOM"
1179
1219
  # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].location.web_location.url #=> String
1180
1220
  # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].metadata #=> Hash
1181
1221
  # event.trace.orchestration_trace.observation.reprompt_response.source #=> String, one of "ACTION_GROUP", "KNOWLEDGE_BASE", "PARSER"
@@ -2058,8 +2098,46 @@ module Aws::BedrockAgentRuntime
2058
2098
  # },
2059
2099
  # },
2060
2100
  # },
2101
+ # implicit_filter_configuration: {
2102
+ # metadata_attributes: [ # required
2103
+ # {
2104
+ # description: "MetadataAttributeSchemaDescriptionString", # required
2105
+ # key: "MetadataAttributeSchemaKeyString", # required
2106
+ # type: "STRING", # required, accepts STRING, NUMBER, BOOLEAN, STRING_LIST
2107
+ # },
2108
+ # ],
2109
+ # model_arn: "BedrockModelArn", # required
2110
+ # },
2061
2111
  # number_of_results: 1,
2062
2112
  # override_search_type: "HYBRID", # accepts HYBRID, SEMANTIC
2113
+ # reranking_configuration: {
2114
+ # bedrock_reranking_configuration: {
2115
+ # metadata_configuration: {
2116
+ # selection_mode: "SELECTIVE", # required, accepts SELECTIVE, ALL
2117
+ # selective_mode_configuration: {
2118
+ # fields_to_exclude: [
2119
+ # {
2120
+ # field_name: "FieldForRerankingFieldNameString", # required
2121
+ # },
2122
+ # ],
2123
+ # fields_to_include: [
2124
+ # {
2125
+ # field_name: "FieldForRerankingFieldNameString", # required
2126
+ # },
2127
+ # ],
2128
+ # },
2129
+ # },
2130
+ # model_configuration: { # required
2131
+ # additional_model_request_fields: {
2132
+ # "AdditionalModelRequestFieldsKey" => {
2133
+ # },
2134
+ # },
2135
+ # model_arn: "BedrockRerankingModelArn", # required
2136
+ # },
2137
+ # number_of_reranked_results: 1,
2138
+ # },
2139
+ # type: "BEDROCK_RERANKING_MODEL", # required, accepts BEDROCK_RERANKING_MODEL
2140
+ # },
2063
2141
  # },
2064
2142
  # },
2065
2143
  # },
@@ -2107,10 +2185,11 @@ module Aws::BedrockAgentRuntime
2107
2185
  # event.attribution.citations[0].retrieved_references #=> Array
2108
2186
  # event.attribution.citations[0].retrieved_references[0].content.text #=> String
2109
2187
  # event.attribution.citations[0].retrieved_references[0].location.confluence_location.url #=> String
2188
+ # event.attribution.citations[0].retrieved_references[0].location.custom_document_location.id #=> String
2110
2189
  # event.attribution.citations[0].retrieved_references[0].location.s3_location.uri #=> String
2111
2190
  # event.attribution.citations[0].retrieved_references[0].location.salesforce_location.url #=> String
2112
2191
  # event.attribution.citations[0].retrieved_references[0].location.share_point_location.url #=> String
2113
- # event.attribution.citations[0].retrieved_references[0].location.type #=> String, one of "S3", "WEB", "CONFLUENCE", "SALESFORCE", "SHAREPOINT"
2192
+ # event.attribution.citations[0].retrieved_references[0].location.type #=> String, one of "S3", "WEB", "CONFLUENCE", "SALESFORCE", "SHAREPOINT", "CUSTOM"
2114
2193
  # event.attribution.citations[0].retrieved_references[0].location.web_location.url #=> String
2115
2194
  # event.attribution.citations[0].retrieved_references[0].metadata #=> Hash
2116
2195
  # event.bytes #=> String
@@ -2270,10 +2349,11 @@ module Aws::BedrockAgentRuntime
2270
2349
  # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references #=> Array
2271
2350
  # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].content.text #=> String
2272
2351
  # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].location.confluence_location.url #=> String
2352
+ # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].location.custom_document_location.id #=> String
2273
2353
  # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].location.s3_location.uri #=> String
2274
2354
  # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].location.salesforce_location.url #=> String
2275
2355
  # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].location.share_point_location.url #=> String
2276
- # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].location.type #=> String, one of "S3", "WEB", "CONFLUENCE", "SALESFORCE", "SHAREPOINT"
2356
+ # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].location.type #=> String, one of "S3", "WEB", "CONFLUENCE", "SALESFORCE", "SHAREPOINT", "CUSTOM"
2277
2357
  # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].location.web_location.url #=> String
2278
2358
  # event.trace.orchestration_trace.observation.knowledge_base_lookup_output.retrieved_references[0].metadata #=> Hash
2279
2359
  # event.trace.orchestration_trace.observation.reprompt_response.source #=> String, one of "ACTION_GROUP", "KNOWLEDGE_BASE", "PARSER"
@@ -2587,8 +2667,100 @@ module Aws::BedrockAgentRuntime
2587
2667
  req.send_request(options, &block)
2588
2668
  end
2589
2669
 
2670
+ # Reranks the relevance of sources based on queries. For more
2671
+ # information, see [Improve the relevance of query responses with a
2672
+ # reranker model][1].
2673
+ #
2674
+ #
2675
+ #
2676
+ # [1]: https://docs.aws.amazon.com/bedrock/latest/userguide/rerank.html
2677
+ #
2678
+ # @option params [String] :next_token
2679
+ # If the total number of results was greater than could fit in a
2680
+ # response, a token is returned in the `nextToken` field. You can enter
2681
+ # that token in this field to return the next batch of results.
2682
+ #
2683
+ # @option params [required, Array<Types::RerankQuery>] :queries
2684
+ # An array of objects, each of which contains information about a query
2685
+ # to submit to the reranker model.
2686
+ #
2687
+ # @option params [required, Types::RerankingConfiguration] :reranking_configuration
2688
+ # Contains configurations for reranking.
2689
+ #
2690
+ # @option params [required, Array<Types::RerankSource>] :sources
2691
+ # An array of objects, each of which contains information about the
2692
+ # sources to rerank.
2693
+ #
2694
+ # @return [Types::RerankResponse] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
2695
+ #
2696
+ # * {Types::RerankResponse#next_token #next_token} => String
2697
+ # * {Types::RerankResponse#results #results} => Array&lt;Types::RerankResult&gt;
2698
+ #
2699
+ # The returned {Seahorse::Client::Response response} is a pageable response and is Enumerable. For details on usage see {Aws::PageableResponse PageableResponse}.
2700
+ #
2701
+ # @example Request syntax with placeholder values
2702
+ #
2703
+ # resp = client.rerank({
2704
+ # next_token: "NextToken",
2705
+ # queries: [ # required
2706
+ # {
2707
+ # text_query: { # required
2708
+ # text: "RerankTextDocumentTextString",
2709
+ # },
2710
+ # type: "TEXT", # required, accepts TEXT
2711
+ # },
2712
+ # ],
2713
+ # reranking_configuration: { # required
2714
+ # bedrock_reranking_configuration: { # required
2715
+ # model_configuration: { # required
2716
+ # additional_model_request_fields: {
2717
+ # "AdditionalModelRequestFieldsKey" => {
2718
+ # },
2719
+ # },
2720
+ # model_arn: "BedrockModelArn", # required
2721
+ # },
2722
+ # number_of_results: 1,
2723
+ # },
2724
+ # type: "BEDROCK_RERANKING_MODEL", # required, accepts BEDROCK_RERANKING_MODEL
2725
+ # },
2726
+ # sources: [ # required
2727
+ # {
2728
+ # inline_document_source: { # required
2729
+ # json_document: {
2730
+ # },
2731
+ # text_document: {
2732
+ # text: "RerankTextDocumentTextString",
2733
+ # },
2734
+ # type: "TEXT", # required, accepts TEXT, JSON
2735
+ # },
2736
+ # type: "INLINE", # required, accepts INLINE
2737
+ # },
2738
+ # ],
2739
+ # })
2740
+ #
2741
+ # @example Response structure
2742
+ #
2743
+ # resp.next_token #=> String
2744
+ # resp.results #=> Array
2745
+ # resp.results[0].document.text_document.text #=> String
2746
+ # resp.results[0].document.type #=> String, one of "TEXT", "JSON"
2747
+ # resp.results[0].index #=> Integer
2748
+ # resp.results[0].relevance_score #=> Float
2749
+ #
2750
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-agent-runtime-2023-07-26/Rerank AWS API Documentation
2751
+ #
2752
+ # @overload rerank(params = {})
2753
+ # @param [Hash] params ({})
2754
+ def rerank(params = {}, options = {})
2755
+ req = build_request(:rerank, params)
2756
+ req.send_request(options)
2757
+ end
2758
+
2590
2759
  # Queries a knowledge base and retrieves information from it.
2591
2760
  #
2761
+ # @option params [Types::GuardrailConfiguration] :guardrail_configuration
2762
+ # Guardrail settings.
2763
+ #
2592
2764
  # @option params [required, String] :knowledge_base_id
2593
2765
  # The unique identifier of the knowledge base to query.
2594
2766
  #
@@ -2610,6 +2782,7 @@ module Aws::BedrockAgentRuntime
2610
2782
  #
2611
2783
  # @return [Types::RetrieveResponse] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
2612
2784
  #
2785
+ # * {Types::RetrieveResponse#guardrail_action #guardrail_action} => String
2613
2786
  # * {Types::RetrieveResponse#next_token #next_token} => String
2614
2787
  # * {Types::RetrieveResponse#retrieval_results #retrieval_results} => Array&lt;Types::KnowledgeBaseRetrievalResult&gt;
2615
2788
  #
@@ -2618,6 +2791,10 @@ module Aws::BedrockAgentRuntime
2618
2791
  # @example Request syntax with placeholder values
2619
2792
  #
2620
2793
  # resp = client.retrieve({
2794
+ # guardrail_configuration: {
2795
+ # guardrail_id: "GuardrailConfigurationGuardrailIdString", # required
2796
+ # guardrail_version: "GuardrailConfigurationGuardrailVersionString", # required
2797
+ # },
2621
2798
  # knowledge_base_id: "KnowledgeBaseId", # required
2622
2799
  # next_token: "NextToken",
2623
2800
  # retrieval_configuration: {
@@ -2689,8 +2866,46 @@ module Aws::BedrockAgentRuntime
2689
2866
  # },
2690
2867
  # },
2691
2868
  # },
2869
+ # implicit_filter_configuration: {
2870
+ # metadata_attributes: [ # required
2871
+ # {
2872
+ # description: "MetadataAttributeSchemaDescriptionString", # required
2873
+ # key: "MetadataAttributeSchemaKeyString", # required
2874
+ # type: "STRING", # required, accepts STRING, NUMBER, BOOLEAN, STRING_LIST
2875
+ # },
2876
+ # ],
2877
+ # model_arn: "BedrockModelArn", # required
2878
+ # },
2692
2879
  # number_of_results: 1,
2693
2880
  # override_search_type: "HYBRID", # accepts HYBRID, SEMANTIC
2881
+ # reranking_configuration: {
2882
+ # bedrock_reranking_configuration: {
2883
+ # metadata_configuration: {
2884
+ # selection_mode: "SELECTIVE", # required, accepts SELECTIVE, ALL
2885
+ # selective_mode_configuration: {
2886
+ # fields_to_exclude: [
2887
+ # {
2888
+ # field_name: "FieldForRerankingFieldNameString", # required
2889
+ # },
2890
+ # ],
2891
+ # fields_to_include: [
2892
+ # {
2893
+ # field_name: "FieldForRerankingFieldNameString", # required
2894
+ # },
2895
+ # ],
2896
+ # },
2897
+ # },
2898
+ # model_configuration: { # required
2899
+ # additional_model_request_fields: {
2900
+ # "AdditionalModelRequestFieldsKey" => {
2901
+ # },
2902
+ # },
2903
+ # model_arn: "BedrockRerankingModelArn", # required
2904
+ # },
2905
+ # number_of_reranked_results: 1,
2906
+ # },
2907
+ # type: "BEDROCK_RERANKING_MODEL", # required, accepts BEDROCK_RERANKING_MODEL
2908
+ # },
2694
2909
  # },
2695
2910
  # },
2696
2911
  # retrieval_query: { # required
@@ -2700,14 +2915,16 @@ module Aws::BedrockAgentRuntime
2700
2915
  #
2701
2916
  # @example Response structure
2702
2917
  #
2918
+ # resp.guardrail_action #=> String, one of "INTERVENED", "NONE"
2703
2919
  # resp.next_token #=> String
2704
2920
  # resp.retrieval_results #=> Array
2705
2921
  # resp.retrieval_results[0].content.text #=> String
2706
2922
  # resp.retrieval_results[0].location.confluence_location.url #=> String
2923
+ # resp.retrieval_results[0].location.custom_document_location.id #=> String
2707
2924
  # resp.retrieval_results[0].location.s3_location.uri #=> String
2708
2925
  # resp.retrieval_results[0].location.salesforce_location.url #=> String
2709
2926
  # resp.retrieval_results[0].location.share_point_location.url #=> String
2710
- # resp.retrieval_results[0].location.type #=> String, one of "S3", "WEB", "CONFLUENCE", "SALESFORCE", "SHAREPOINT"
2927
+ # resp.retrieval_results[0].location.type #=> String, one of "S3", "WEB", "CONFLUENCE", "SALESFORCE", "SHAREPOINT", "CUSTOM"
2711
2928
  # resp.retrieval_results[0].location.web_location.url #=> String
2712
2929
  # resp.retrieval_results[0].metadata #=> Hash
2713
2930
  # resp.retrieval_results[0].score #=> Float
@@ -2916,8 +3133,46 @@ module Aws::BedrockAgentRuntime
2916
3133
  # },
2917
3134
  # },
2918
3135
  # },
3136
+ # implicit_filter_configuration: {
3137
+ # metadata_attributes: [ # required
3138
+ # {
3139
+ # description: "MetadataAttributeSchemaDescriptionString", # required
3140
+ # key: "MetadataAttributeSchemaKeyString", # required
3141
+ # type: "STRING", # required, accepts STRING, NUMBER, BOOLEAN, STRING_LIST
3142
+ # },
3143
+ # ],
3144
+ # model_arn: "BedrockModelArn", # required
3145
+ # },
2919
3146
  # number_of_results: 1,
2920
3147
  # override_search_type: "HYBRID", # accepts HYBRID, SEMANTIC
3148
+ # reranking_configuration: {
3149
+ # bedrock_reranking_configuration: {
3150
+ # metadata_configuration: {
3151
+ # selection_mode: "SELECTIVE", # required, accepts SELECTIVE, ALL
3152
+ # selective_mode_configuration: {
3153
+ # fields_to_exclude: [
3154
+ # {
3155
+ # field_name: "FieldForRerankingFieldNameString", # required
3156
+ # },
3157
+ # ],
3158
+ # fields_to_include: [
3159
+ # {
3160
+ # field_name: "FieldForRerankingFieldNameString", # required
3161
+ # },
3162
+ # ],
3163
+ # },
3164
+ # },
3165
+ # model_configuration: { # required
3166
+ # additional_model_request_fields: {
3167
+ # "AdditionalModelRequestFieldsKey" => {
3168
+ # },
3169
+ # },
3170
+ # model_arn: "BedrockRerankingModelArn", # required
3171
+ # },
3172
+ # number_of_reranked_results: 1,
3173
+ # },
3174
+ # type: "BEDROCK_RERANKING_MODEL", # required, accepts BEDROCK_RERANKING_MODEL
3175
+ # },
2921
3176
  # },
2922
3177
  # },
2923
3178
  # },
@@ -2938,10 +3193,11 @@ module Aws::BedrockAgentRuntime
2938
3193
  # resp.citations[0].retrieved_references #=> Array
2939
3194
  # resp.citations[0].retrieved_references[0].content.text #=> String
2940
3195
  # resp.citations[0].retrieved_references[0].location.confluence_location.url #=> String
3196
+ # resp.citations[0].retrieved_references[0].location.custom_document_location.id #=> String
2941
3197
  # resp.citations[0].retrieved_references[0].location.s3_location.uri #=> String
2942
3198
  # resp.citations[0].retrieved_references[0].location.salesforce_location.url #=> String
2943
3199
  # resp.citations[0].retrieved_references[0].location.share_point_location.url #=> String
2944
- # resp.citations[0].retrieved_references[0].location.type #=> String, one of "S3", "WEB", "CONFLUENCE", "SALESFORCE", "SHAREPOINT"
3200
+ # resp.citations[0].retrieved_references[0].location.type #=> String, one of "S3", "WEB", "CONFLUENCE", "SALESFORCE", "SHAREPOINT", "CUSTOM"
2945
3201
  # resp.citations[0].retrieved_references[0].location.web_location.url #=> String
2946
3202
  # resp.citations[0].retrieved_references[0].metadata #=> Hash
2947
3203
  # resp.guardrail_action #=> String, one of "INTERVENED", "NONE"
@@ -2957,6 +3213,515 @@ module Aws::BedrockAgentRuntime
2957
3213
  req.send_request(options)
2958
3214
  end
2959
3215
 
3216
+ # Queries a knowledge base and generates responses based on the
3217
+ # retrieved results, with output in streaming format.
3218
+ #
3219
+ # <note markdown="1"> The CLI doesn't support streaming operations in Amazon Bedrock,
3220
+ # including `InvokeModelWithResponseStream`.
3221
+ #
3222
+ # </note>
3223
+ #
3224
+ # @option params [required, Types::RetrieveAndGenerateInput] :input
3225
+ # Contains the query to be made to the knowledge base.
3226
+ #
3227
+ # @option params [Types::RetrieveAndGenerateConfiguration] :retrieve_and_generate_configuration
3228
+ # Contains configurations for the knowledge base query and retrieval
3229
+ # process. For more information, see [Query configurations][1].
3230
+ #
3231
+ #
3232
+ #
3233
+ # [1]: https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html
3234
+ #
3235
+ # @option params [Types::RetrieveAndGenerateSessionConfiguration] :session_configuration
3236
+ # Contains details about the session with the knowledge base.
3237
+ #
3238
+ # @option params [String] :session_id
3239
+ # The unique identifier of the session. When you first make a
3240
+ # `RetrieveAndGenerate` request, Amazon Bedrock automatically generates
3241
+ # this value. You must reuse this value for all subsequent requests in
3242
+ # the same conversational session. This value allows Amazon Bedrock to
3243
+ # maintain context and knowledge from previous interactions. You can't
3244
+ # explicitly set the `sessionId` yourself.
3245
+ #
3246
+ # @return [Types::RetrieveAndGenerateStreamResponse] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
3247
+ #
3248
+ # * {Types::RetrieveAndGenerateStreamResponse#session_id #session_id} => String
3249
+ # * {Types::RetrieveAndGenerateStreamResponse#stream #stream} => Types::RetrieveAndGenerateStreamResponseOutput
3250
+ #
3251
+ # @example EventStream Operation Example
3252
+ #
3253
+ # You can process the event once it arrives immediately, or wait until the
3254
+ # full response is complete and iterate through the eventstream enumerator.
3255
+ #
3256
+ # To interact with event immediately, you need to register #retrieve_and_generate_stream
3257
+ # with callbacks. Callbacks can be registered for specific events or for all
3258
+ # events, including error events.
3259
+ #
3260
+ # Callbacks can be passed into the `:event_stream_handler` option or within a
3261
+ # block statement attached to the #retrieve_and_generate_stream call directly. Hybrid
3262
+ # pattern of both is also supported.
3263
+ #
3264
+ # `:event_stream_handler` option takes in either a Proc object or
3265
+ # Aws::BedrockAgentRuntime::EventStreams::RetrieveAndGenerateStreamResponseOutput object.
3266
+ #
3267
+ # Usage pattern a): Callbacks with a block attached to #retrieve_and_generate_stream
3268
+ # Example for registering callbacks for all event types and an error event
3269
+ #
3270
+ # client.retrieve_and_generate_stream( # params input# ) do |stream|
3271
+ # stream.on_error_event do |event|
3272
+ # # catch unmodeled error event in the stream
3273
+ # raise event
3274
+ # # => Aws::Errors::EventError
3275
+ # # event.event_type => :error
3276
+ # # event.error_code => String
3277
+ # # event.error_message => String
3278
+ # end
3279
+ #
3280
+ # stream.on_event do |event|
3281
+ # # process all events arrive
3282
+ # puts event.event_type
3283
+ # ...
3284
+ # end
3285
+ #
3286
+ # end
3287
+ #
3288
+ # Usage pattern b): Pass in `:event_stream_handler` for #retrieve_and_generate_stream
3289
+ #
3290
+ # 1) Create a Aws::BedrockAgentRuntime::EventStreams::RetrieveAndGenerateStreamResponseOutput object
3291
+ # Example for registering callbacks with specific events
3292
+ #
3293
+ # handler = Aws::BedrockAgentRuntime::EventStreams::RetrieveAndGenerateStreamResponseOutput.new
3294
+ # handler.on_access_denied_exception_event do |event|
3295
+ # event # => Aws::BedrockAgentRuntime::Types::accessDeniedException
3296
+ # end
3297
+ # handler.on_bad_gateway_exception_event do |event|
3298
+ # event # => Aws::BedrockAgentRuntime::Types::badGatewayException
3299
+ # end
3300
+ # handler.on_citation_event do |event|
3301
+ # event # => Aws::BedrockAgentRuntime::Types::citation
3302
+ # end
3303
+ # handler.on_conflict_exception_event do |event|
3304
+ # event # => Aws::BedrockAgentRuntime::Types::conflictException
3305
+ # end
3306
+ # handler.on_dependency_failed_exception_event do |event|
3307
+ # event # => Aws::BedrockAgentRuntime::Types::dependencyFailedException
3308
+ # end
3309
+ # handler.on_guardrail_event do |event|
3310
+ # event # => Aws::BedrockAgentRuntime::Types::guardrail
3311
+ # end
3312
+ # handler.on_internal_server_exception_event do |event|
3313
+ # event # => Aws::BedrockAgentRuntime::Types::internalServerException
3314
+ # end
3315
+ # handler.on_output_event do |event|
3316
+ # event # => Aws::BedrockAgentRuntime::Types::output
3317
+ # end
3318
+ # handler.on_resource_not_found_exception_event do |event|
3319
+ # event # => Aws::BedrockAgentRuntime::Types::resourceNotFoundException
3320
+ # end
3321
+ # handler.on_service_quota_exceeded_exception_event do |event|
3322
+ # event # => Aws::BedrockAgentRuntime::Types::serviceQuotaExceededException
3323
+ # end
3324
+ # handler.on_throttling_exception_event do |event|
3325
+ # event # => Aws::BedrockAgentRuntime::Types::throttlingException
3326
+ # end
3327
+ # handler.on_validation_exception_event do |event|
3328
+ # event # => Aws::BedrockAgentRuntime::Types::validationException
3329
+ # end
3330
+ #
3331
+ # client.retrieve_and_generate_stream( # params input #, event_stream_handler: handler)
3332
+ #
3333
+ # 2) Use a Ruby Proc object
3334
+ # Example for registering callbacks with specific events
3335
+ #
3336
+ # handler = Proc.new do |stream|
3337
+ # stream.on_access_denied_exception_event do |event|
3338
+ # event # => Aws::BedrockAgentRuntime::Types::accessDeniedException
3339
+ # end
3340
+ # stream.on_bad_gateway_exception_event do |event|
3341
+ # event # => Aws::BedrockAgentRuntime::Types::badGatewayException
3342
+ # end
3343
+ # stream.on_citation_event do |event|
3344
+ # event # => Aws::BedrockAgentRuntime::Types::citation
3345
+ # end
3346
+ # stream.on_conflict_exception_event do |event|
3347
+ # event # => Aws::BedrockAgentRuntime::Types::conflictException
3348
+ # end
3349
+ # stream.on_dependency_failed_exception_event do |event|
3350
+ # event # => Aws::BedrockAgentRuntime::Types::dependencyFailedException
3351
+ # end
3352
+ # stream.on_guardrail_event do |event|
3353
+ # event # => Aws::BedrockAgentRuntime::Types::guardrail
3354
+ # end
3355
+ # stream.on_internal_server_exception_event do |event|
3356
+ # event # => Aws::BedrockAgentRuntime::Types::internalServerException
3357
+ # end
3358
+ # stream.on_output_event do |event|
3359
+ # event # => Aws::BedrockAgentRuntime::Types::output
3360
+ # end
3361
+ # stream.on_resource_not_found_exception_event do |event|
3362
+ # event # => Aws::BedrockAgentRuntime::Types::resourceNotFoundException
3363
+ # end
3364
+ # stream.on_service_quota_exceeded_exception_event do |event|
3365
+ # event # => Aws::BedrockAgentRuntime::Types::serviceQuotaExceededException
3366
+ # end
3367
+ # stream.on_throttling_exception_event do |event|
3368
+ # event # => Aws::BedrockAgentRuntime::Types::throttlingException
3369
+ # end
3370
+ # stream.on_validation_exception_event do |event|
3371
+ # event # => Aws::BedrockAgentRuntime::Types::validationException
3372
+ # end
3373
+ # end
3374
+ #
3375
+ # client.retrieve_and_generate_stream( # params input #, event_stream_handler: handler)
3376
+ #
3377
+ # Usage pattern c): Hybrid pattern of a) and b)
3378
+ #
3379
+ # handler = Aws::BedrockAgentRuntime::EventStreams::RetrieveAndGenerateStreamResponseOutput.new
3380
+ # handler.on_access_denied_exception_event do |event|
3381
+ # event # => Aws::BedrockAgentRuntime::Types::accessDeniedException
3382
+ # end
3383
+ # handler.on_bad_gateway_exception_event do |event|
3384
+ # event # => Aws::BedrockAgentRuntime::Types::badGatewayException
3385
+ # end
3386
+ # handler.on_citation_event do |event|
3387
+ # event # => Aws::BedrockAgentRuntime::Types::citation
3388
+ # end
3389
+ # handler.on_conflict_exception_event do |event|
3390
+ # event # => Aws::BedrockAgentRuntime::Types::conflictException
3391
+ # end
3392
+ # handler.on_dependency_failed_exception_event do |event|
3393
+ # event # => Aws::BedrockAgentRuntime::Types::dependencyFailedException
3394
+ # end
3395
+ # handler.on_guardrail_event do |event|
3396
+ # event # => Aws::BedrockAgentRuntime::Types::guardrail
3397
+ # end
3398
+ # handler.on_internal_server_exception_event do |event|
3399
+ # event # => Aws::BedrockAgentRuntime::Types::internalServerException
3400
+ # end
3401
+ # handler.on_output_event do |event|
3402
+ # event # => Aws::BedrockAgentRuntime::Types::output
3403
+ # end
3404
+ # handler.on_resource_not_found_exception_event do |event|
3405
+ # event # => Aws::BedrockAgentRuntime::Types::resourceNotFoundException
3406
+ # end
3407
+ # handler.on_service_quota_exceeded_exception_event do |event|
3408
+ # event # => Aws::BedrockAgentRuntime::Types::serviceQuotaExceededException
3409
+ # end
3410
+ # handler.on_throttling_exception_event do |event|
3411
+ # event # => Aws::BedrockAgentRuntime::Types::throttlingException
3412
+ # end
3413
+ # handler.on_validation_exception_event do |event|
3414
+ # event # => Aws::BedrockAgentRuntime::Types::validationException
3415
+ # end
3416
+ #
3417
+ # client.retrieve_and_generate_stream( # params input #, event_stream_handler: handler) do |stream|
3418
+ # stream.on_error_event do |event|
3419
+ # # catch unmodeled error event in the stream
3420
+ # raise event
3421
+ # # => Aws::Errors::EventError
3422
+ # # event.event_type => :error
3423
+ # # event.error_code => String
3424
+ # # event.error_message => String
3425
+ # end
3426
+ # end
3427
+ #
3428
+ # You can also iterate through events after the response complete.
3429
+ #
3430
+ # Events are available at resp.stream # => Enumerator
3431
+ # For parameter input example, please refer to following request syntax
3432
+ #
3433
+ # @example Request syntax with placeholder values
3434
+ #
3435
+ # resp = client.retrieve_and_generate_stream({
3436
+ # input: { # required
3437
+ # text: "RetrieveAndGenerateInputTextString", # required
3438
+ # },
3439
+ # retrieve_and_generate_configuration: {
3440
+ # external_sources_configuration: {
3441
+ # generation_configuration: {
3442
+ # additional_model_request_fields: {
3443
+ # "AdditionalModelRequestFieldsKey" => {
3444
+ # },
3445
+ # },
3446
+ # guardrail_configuration: {
3447
+ # guardrail_id: "GuardrailConfigurationGuardrailIdString", # required
3448
+ # guardrail_version: "GuardrailConfigurationGuardrailVersionString", # required
3449
+ # },
3450
+ # inference_config: {
3451
+ # text_inference_config: {
3452
+ # max_tokens: 1,
3453
+ # stop_sequences: ["RAGStopSequencesMemberString"],
3454
+ # temperature: 1.0,
3455
+ # top_p: 1.0,
3456
+ # },
3457
+ # },
3458
+ # prompt_template: {
3459
+ # text_prompt_template: "TextPromptTemplate",
3460
+ # },
3461
+ # },
3462
+ # model_arn: "BedrockModelArn", # required
3463
+ # sources: [ # required
3464
+ # {
3465
+ # byte_content: {
3466
+ # content_type: "ContentType", # required
3467
+ # data: "data", # required
3468
+ # identifier: "Identifier", # required
3469
+ # },
3470
+ # s3_location: {
3471
+ # uri: "S3Uri", # required
3472
+ # },
3473
+ # source_type: "S3", # required, accepts S3, BYTE_CONTENT
3474
+ # },
3475
+ # ],
3476
+ # },
3477
+ # knowledge_base_configuration: {
3478
+ # generation_configuration: {
3479
+ # additional_model_request_fields: {
3480
+ # "AdditionalModelRequestFieldsKey" => {
3481
+ # },
3482
+ # },
3483
+ # guardrail_configuration: {
3484
+ # guardrail_id: "GuardrailConfigurationGuardrailIdString", # required
3485
+ # guardrail_version: "GuardrailConfigurationGuardrailVersionString", # required
3486
+ # },
3487
+ # inference_config: {
3488
+ # text_inference_config: {
3489
+ # max_tokens: 1,
3490
+ # stop_sequences: ["RAGStopSequencesMemberString"],
3491
+ # temperature: 1.0,
3492
+ # top_p: 1.0,
3493
+ # },
3494
+ # },
3495
+ # prompt_template: {
3496
+ # text_prompt_template: "TextPromptTemplate",
3497
+ # },
3498
+ # },
3499
+ # knowledge_base_id: "KnowledgeBaseId", # required
3500
+ # model_arn: "BedrockModelArn", # required
3501
+ # orchestration_configuration: {
3502
+ # additional_model_request_fields: {
3503
+ # "AdditionalModelRequestFieldsKey" => {
3504
+ # },
3505
+ # },
3506
+ # inference_config: {
3507
+ # text_inference_config: {
3508
+ # max_tokens: 1,
3509
+ # stop_sequences: ["RAGStopSequencesMemberString"],
3510
+ # temperature: 1.0,
3511
+ # top_p: 1.0,
3512
+ # },
3513
+ # },
3514
+ # prompt_template: {
3515
+ # text_prompt_template: "TextPromptTemplate",
3516
+ # },
3517
+ # query_transformation_configuration: {
3518
+ # type: "QUERY_DECOMPOSITION", # required, accepts QUERY_DECOMPOSITION
3519
+ # },
3520
+ # },
3521
+ # retrieval_configuration: {
3522
+ # vector_search_configuration: { # required
3523
+ # filter: {
3524
+ # and_all: [
3525
+ # {
3526
+ # # recursive RetrievalFilter
3527
+ # },
3528
+ # ],
3529
+ # equals: {
3530
+ # key: "FilterKey", # required
3531
+ # value: { # required
3532
+ # },
3533
+ # },
3534
+ # greater_than: {
3535
+ # key: "FilterKey", # required
3536
+ # value: { # required
3537
+ # },
3538
+ # },
3539
+ # greater_than_or_equals: {
3540
+ # key: "FilterKey", # required
3541
+ # value: { # required
3542
+ # },
3543
+ # },
3544
+ # in: {
3545
+ # key: "FilterKey", # required
3546
+ # value: { # required
3547
+ # },
3548
+ # },
3549
+ # less_than: {
3550
+ # key: "FilterKey", # required
3551
+ # value: { # required
3552
+ # },
3553
+ # },
3554
+ # less_than_or_equals: {
3555
+ # key: "FilterKey", # required
3556
+ # value: { # required
3557
+ # },
3558
+ # },
3559
+ # list_contains: {
3560
+ # key: "FilterKey", # required
3561
+ # value: { # required
3562
+ # },
3563
+ # },
3564
+ # not_equals: {
3565
+ # key: "FilterKey", # required
3566
+ # value: { # required
3567
+ # },
3568
+ # },
3569
+ # not_in: {
3570
+ # key: "FilterKey", # required
3571
+ # value: { # required
3572
+ # },
3573
+ # },
3574
+ # or_all: [
3575
+ # {
3576
+ # # recursive RetrievalFilter
3577
+ # },
3578
+ # ],
3579
+ # starts_with: {
3580
+ # key: "FilterKey", # required
3581
+ # value: { # required
3582
+ # },
3583
+ # },
3584
+ # string_contains: {
3585
+ # key: "FilterKey", # required
3586
+ # value: { # required
3587
+ # },
3588
+ # },
3589
+ # },
3590
+ # implicit_filter_configuration: {
3591
+ # metadata_attributes: [ # required
3592
+ # {
3593
+ # description: "MetadataAttributeSchemaDescriptionString", # required
3594
+ # key: "MetadataAttributeSchemaKeyString", # required
3595
+ # type: "STRING", # required, accepts STRING, NUMBER, BOOLEAN, STRING_LIST
3596
+ # },
3597
+ # ],
3598
+ # model_arn: "BedrockModelArn", # required
3599
+ # },
3600
+ # number_of_results: 1,
3601
+ # override_search_type: "HYBRID", # accepts HYBRID, SEMANTIC
3602
+ # reranking_configuration: {
3603
+ # bedrock_reranking_configuration: {
3604
+ # metadata_configuration: {
3605
+ # selection_mode: "SELECTIVE", # required, accepts SELECTIVE, ALL
3606
+ # selective_mode_configuration: {
3607
+ # fields_to_exclude: [
3608
+ # {
3609
+ # field_name: "FieldForRerankingFieldNameString", # required
3610
+ # },
3611
+ # ],
3612
+ # fields_to_include: [
3613
+ # {
3614
+ # field_name: "FieldForRerankingFieldNameString", # required
3615
+ # },
3616
+ # ],
3617
+ # },
3618
+ # },
3619
+ # model_configuration: { # required
3620
+ # additional_model_request_fields: {
3621
+ # "AdditionalModelRequestFieldsKey" => {
3622
+ # },
3623
+ # },
3624
+ # model_arn: "BedrockRerankingModelArn", # required
3625
+ # },
3626
+ # number_of_reranked_results: 1,
3627
+ # },
3628
+ # type: "BEDROCK_RERANKING_MODEL", # required, accepts BEDROCK_RERANKING_MODEL
3629
+ # },
3630
+ # },
3631
+ # },
3632
+ # },
3633
+ # type: "KNOWLEDGE_BASE", # required, accepts KNOWLEDGE_BASE, EXTERNAL_SOURCES
3634
+ # },
3635
+ # session_configuration: {
3636
+ # kms_key_arn: "KmsKeyArn", # required
3637
+ # },
3638
+ # session_id: "SessionId",
3639
+ # })
3640
+ #
3641
+ # @example Response structure
3642
+ #
3643
+ # resp.session_id #=> String
3644
+ # All events are available at resp.stream:
3645
+ # resp.stream #=> Enumerator
3646
+ # resp.stream.event_types #=> [:access_denied_exception, :bad_gateway_exception, :citation, :conflict_exception, :dependency_failed_exception, :guardrail, :internal_server_exception, :output, :resource_not_found_exception, :service_quota_exceeded_exception, :throttling_exception, :validation_exception]
3647
+ #
3648
+ # For :access_denied_exception event available at #on_access_denied_exception_event callback and response eventstream enumerator:
3649
+ # event.message #=> String
3650
+ #
3651
+ # For :bad_gateway_exception event available at #on_bad_gateway_exception_event callback and response eventstream enumerator:
3652
+ # event.message #=> String
3653
+ # event.resource_name #=> String
3654
+ #
3655
+ # For :citation event available at #on_citation_event callback and response eventstream enumerator:
3656
+ # event.citation.generated_response_part.text_response_part.span.end #=> Integer
3657
+ # event.citation.generated_response_part.text_response_part.span.start #=> Integer
3658
+ # event.citation.generated_response_part.text_response_part.text #=> String
3659
+ # event.citation.retrieved_references #=> Array
3660
+ # event.citation.retrieved_references[0].content.text #=> String
3661
+ # event.citation.retrieved_references[0].location.confluence_location.url #=> String
3662
+ # event.citation.retrieved_references[0].location.custom_document_location.id #=> String
3663
+ # event.citation.retrieved_references[0].location.s3_location.uri #=> String
3664
+ # event.citation.retrieved_references[0].location.salesforce_location.url #=> String
3665
+ # event.citation.retrieved_references[0].location.share_point_location.url #=> String
3666
+ # event.citation.retrieved_references[0].location.type #=> String, one of "S3", "WEB", "CONFLUENCE", "SALESFORCE", "SHAREPOINT", "CUSTOM"
3667
+ # event.citation.retrieved_references[0].location.web_location.url #=> String
3668
+ # event.citation.retrieved_references[0].metadata #=> Hash
3669
+ #
3670
+ # For :conflict_exception event available at #on_conflict_exception_event callback and response eventstream enumerator:
3671
+ # event.message #=> String
3672
+ #
3673
+ # For :dependency_failed_exception event available at #on_dependency_failed_exception_event callback and response eventstream enumerator:
3674
+ # event.message #=> String
3675
+ # event.resource_name #=> String
3676
+ #
3677
+ # For :guardrail event available at #on_guardrail_event callback and response eventstream enumerator:
3678
+ # event.action #=> String, one of "INTERVENED", "NONE"
3679
+ #
3680
+ # For :internal_server_exception event available at #on_internal_server_exception_event callback and response eventstream enumerator:
3681
+ # event.message #=> String
3682
+ #
3683
+ # For :output event available at #on_output_event callback and response eventstream enumerator:
3684
+ # event.text #=> String
3685
+ #
3686
+ # For :resource_not_found_exception event available at #on_resource_not_found_exception_event callback and response eventstream enumerator:
3687
+ # event.message #=> String
3688
+ #
3689
+ # For :service_quota_exceeded_exception event available at #on_service_quota_exceeded_exception_event callback and response eventstream enumerator:
3690
+ # event.message #=> String
3691
+ #
3692
+ # For :throttling_exception event available at #on_throttling_exception_event callback and response eventstream enumerator:
3693
+ # event.message #=> String
3694
+ #
3695
+ # For :validation_exception event available at #on_validation_exception_event callback and response eventstream enumerator:
3696
+ # event.message #=> String
3697
+ #
3698
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-agent-runtime-2023-07-26/RetrieveAndGenerateStream AWS API Documentation
3699
+ #
3700
+ # @overload retrieve_and_generate_stream(params = {})
3701
+ # @param [Hash] params ({})
3702
+ def retrieve_and_generate_stream(params = {}, options = {}, &block)
3703
+ params = params.dup
3704
+ event_stream_handler = case handler = params.delete(:event_stream_handler)
3705
+ when EventStreams::RetrieveAndGenerateStreamResponseOutput then handler
3706
+ when Proc then EventStreams::RetrieveAndGenerateStreamResponseOutput.new.tap(&handler)
3707
+ when nil then EventStreams::RetrieveAndGenerateStreamResponseOutput.new
3708
+ else
3709
+ msg = "expected :event_stream_handler to be a block or "\
3710
+ "instance of Aws::BedrockAgentRuntime::EventStreams::RetrieveAndGenerateStreamResponseOutput"\
3711
+ ", got `#{handler.inspect}` instead"
3712
+ raise ArgumentError, msg
3713
+ end
3714
+
3715
+ yield(event_stream_handler) if block_given?
3716
+
3717
+ req = build_request(:retrieve_and_generate_stream, params)
3718
+
3719
+ req.context[:event_stream_handler] = event_stream_handler
3720
+ req.handlers.add(Aws::Binary::DecodeHandler, priority: 95)
3721
+
3722
+ req.send_request(options, &block)
3723
+ end
3724
+
2960
3725
  # @!endgroup
2961
3726
 
2962
3727
  # @param params ({})
@@ -2975,7 +3740,7 @@ module Aws::BedrockAgentRuntime
2975
3740
  tracer: tracer
2976
3741
  )
2977
3742
  context[:gem_name] = 'aws-sdk-bedrockagentruntime'
2978
- context[:gem_version] = '1.34.0'
3743
+ context[:gem_version] = '1.35.0'
2979
3744
  Seahorse::Client::Request.new(handlers, context)
2980
3745
  end
2981
3746