aws-sdk-bedrockruntime 1.55.0 → 1.56.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 +1 -1
- data/lib/aws-sdk-bedrockruntime/client.rb +270 -1
- data/lib/aws-sdk-bedrockruntime/client_api.rb +43 -0
- data/lib/aws-sdk-bedrockruntime/types.rb +149 -15
- data/lib/aws-sdk-bedrockruntime.rb +1 -1
- data/sig/client.rbs +202 -0
- data/sig/types.rbs +36 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8435e366259ba96b5331f1a8b88ce27642c312205c34e2624ab900036aa2a4bf
|
4
|
+
data.tar.gz: d94ab0b5513a93e712c5a157b1a6b935d38c0bf891375a53490e25e7baf5e666
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2560328aace32b3f047979b3b0c77965685b8d6f85c606abf51e210285171b5e49d337a6c745aa4563168c700c7804ae6261a01d6627596b739f33eefed7d01
|
7
|
+
data.tar.gz: dea05c731fd747111abba06ffd1049dd39c8161f8142fb1c06e50a47d17364e75ed3a83b3efdce4cbce4f31bd38c4846e3860de87734fc3eb9c202a91f7e6102
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.56.0
|
@@ -2607,6 +2607,275 @@ module Aws::BedrockRuntime
|
|
2607
2607
|
req.send_request(options, &block)
|
2608
2608
|
end
|
2609
2609
|
|
2610
|
+
# Returns the token count for a given inference request. This operation
|
2611
|
+
# helps you estimate token usage before sending requests to foundation
|
2612
|
+
# models by returning the token count that would be used if the same
|
2613
|
+
# input were sent to the model in an inference request.
|
2614
|
+
#
|
2615
|
+
# Token counting is model-specific because different models use
|
2616
|
+
# different tokenization strategies. The token count returned by this
|
2617
|
+
# operation will match the token count that would be charged if the same
|
2618
|
+
# input were sent to the model in an `InvokeModel` or `Converse`
|
2619
|
+
# request.
|
2620
|
+
#
|
2621
|
+
# You can use this operation to:
|
2622
|
+
#
|
2623
|
+
# * Estimate costs before sending inference requests.
|
2624
|
+
#
|
2625
|
+
# * Optimize prompts to fit within token limits.
|
2626
|
+
#
|
2627
|
+
# * Plan for token usage in your applications.
|
2628
|
+
#
|
2629
|
+
# This operation accepts the same input formats as `InvokeModel` and
|
2630
|
+
# `Converse`, allowing you to count tokens for both raw text inputs and
|
2631
|
+
# structured conversation formats.
|
2632
|
+
#
|
2633
|
+
# The following operations are related to `CountTokens`:
|
2634
|
+
#
|
2635
|
+
# * [InvokeModel][1] - Sends inference requests to foundation models
|
2636
|
+
#
|
2637
|
+
# * [Converse][2] - Sends conversation-based inference requests to
|
2638
|
+
# foundation models
|
2639
|
+
#
|
2640
|
+
#
|
2641
|
+
#
|
2642
|
+
# [1]: https://docs.aws.amazon.com/bedrock/latest/API/API_runtime_InvokeModel.html
|
2643
|
+
# [2]: https://docs.aws.amazon.com/bedrock/latest/API/API_runtime_Converse.html
|
2644
|
+
#
|
2645
|
+
# @option params [required, String] :model_id
|
2646
|
+
# The unique identifier or ARN of the foundation model to use for token
|
2647
|
+
# counting. Each model processes tokens differently, so the token count
|
2648
|
+
# is specific to the model you specify.
|
2649
|
+
#
|
2650
|
+
# @option params [required, Types::CountTokensInput] :input
|
2651
|
+
# The input for which to count tokens. The structure of this parameter
|
2652
|
+
# depends on whether you're counting tokens for an `InvokeModel` or
|
2653
|
+
# `Converse` request:
|
2654
|
+
#
|
2655
|
+
# * For `InvokeModel` requests, provide the request body in the
|
2656
|
+
# `invokeModel` field
|
2657
|
+
#
|
2658
|
+
# * For `Converse` requests, provide the messages and system content in
|
2659
|
+
# the `converse` field
|
2660
|
+
#
|
2661
|
+
# The input format must be compatible with the model specified in the
|
2662
|
+
# `modelId` parameter.
|
2663
|
+
#
|
2664
|
+
# @return [Types::CountTokensResponse] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
|
2665
|
+
#
|
2666
|
+
# * {Types::CountTokensResponse#input_tokens #input_tokens} => Integer
|
2667
|
+
#
|
2668
|
+
# @example Request syntax with placeholder values
|
2669
|
+
#
|
2670
|
+
# resp = client.count_tokens({
|
2671
|
+
# model_id: "FoundationModelVersionIdentifier", # required
|
2672
|
+
# input: { # required
|
2673
|
+
# invoke_model: {
|
2674
|
+
# body: "data", # required
|
2675
|
+
# },
|
2676
|
+
# converse: {
|
2677
|
+
# messages: [
|
2678
|
+
# {
|
2679
|
+
# role: "user", # required, accepts user, assistant
|
2680
|
+
# content: [ # required
|
2681
|
+
# {
|
2682
|
+
# text: "String",
|
2683
|
+
# image: {
|
2684
|
+
# format: "png", # required, accepts png, jpeg, gif, webp
|
2685
|
+
# source: { # required
|
2686
|
+
# bytes: "data",
|
2687
|
+
# s3_location: {
|
2688
|
+
# uri: "S3Uri", # required
|
2689
|
+
# bucket_owner: "AccountId",
|
2690
|
+
# },
|
2691
|
+
# },
|
2692
|
+
# },
|
2693
|
+
# document: {
|
2694
|
+
# format: "pdf", # accepts pdf, csv, doc, docx, xls, xlsx, html, txt, md
|
2695
|
+
# name: "DocumentBlockNameString", # required
|
2696
|
+
# source: { # required
|
2697
|
+
# bytes: "data",
|
2698
|
+
# s3_location: {
|
2699
|
+
# uri: "S3Uri", # required
|
2700
|
+
# bucket_owner: "AccountId",
|
2701
|
+
# },
|
2702
|
+
# text: "String",
|
2703
|
+
# content: [
|
2704
|
+
# {
|
2705
|
+
# text: "String",
|
2706
|
+
# },
|
2707
|
+
# ],
|
2708
|
+
# },
|
2709
|
+
# context: "String",
|
2710
|
+
# citations: {
|
2711
|
+
# enabled: false, # required
|
2712
|
+
# },
|
2713
|
+
# },
|
2714
|
+
# video: {
|
2715
|
+
# format: "mkv", # required, accepts mkv, mov, mp4, webm, flv, mpeg, mpg, wmv, three_gp
|
2716
|
+
# source: { # required
|
2717
|
+
# bytes: "data",
|
2718
|
+
# s3_location: {
|
2719
|
+
# uri: "S3Uri", # required
|
2720
|
+
# bucket_owner: "AccountId",
|
2721
|
+
# },
|
2722
|
+
# },
|
2723
|
+
# },
|
2724
|
+
# tool_use: {
|
2725
|
+
# tool_use_id: "ToolUseId", # required
|
2726
|
+
# name: "ToolName", # required
|
2727
|
+
# input: { # required
|
2728
|
+
# },
|
2729
|
+
# },
|
2730
|
+
# tool_result: {
|
2731
|
+
# tool_use_id: "ToolUseId", # required
|
2732
|
+
# content: [ # required
|
2733
|
+
# {
|
2734
|
+
# json: {
|
2735
|
+
# },
|
2736
|
+
# text: "String",
|
2737
|
+
# image: {
|
2738
|
+
# format: "png", # required, accepts png, jpeg, gif, webp
|
2739
|
+
# source: { # required
|
2740
|
+
# bytes: "data",
|
2741
|
+
# s3_location: {
|
2742
|
+
# uri: "S3Uri", # required
|
2743
|
+
# bucket_owner: "AccountId",
|
2744
|
+
# },
|
2745
|
+
# },
|
2746
|
+
# },
|
2747
|
+
# document: {
|
2748
|
+
# format: "pdf", # accepts pdf, csv, doc, docx, xls, xlsx, html, txt, md
|
2749
|
+
# name: "DocumentBlockNameString", # required
|
2750
|
+
# source: { # required
|
2751
|
+
# bytes: "data",
|
2752
|
+
# s3_location: {
|
2753
|
+
# uri: "S3Uri", # required
|
2754
|
+
# bucket_owner: "AccountId",
|
2755
|
+
# },
|
2756
|
+
# text: "String",
|
2757
|
+
# content: [
|
2758
|
+
# {
|
2759
|
+
# text: "String",
|
2760
|
+
# },
|
2761
|
+
# ],
|
2762
|
+
# },
|
2763
|
+
# context: "String",
|
2764
|
+
# citations: {
|
2765
|
+
# enabled: false, # required
|
2766
|
+
# },
|
2767
|
+
# },
|
2768
|
+
# video: {
|
2769
|
+
# format: "mkv", # required, accepts mkv, mov, mp4, webm, flv, mpeg, mpg, wmv, three_gp
|
2770
|
+
# source: { # required
|
2771
|
+
# bytes: "data",
|
2772
|
+
# s3_location: {
|
2773
|
+
# uri: "S3Uri", # required
|
2774
|
+
# bucket_owner: "AccountId",
|
2775
|
+
# },
|
2776
|
+
# },
|
2777
|
+
# },
|
2778
|
+
# },
|
2779
|
+
# ],
|
2780
|
+
# status: "success", # accepts success, error
|
2781
|
+
# },
|
2782
|
+
# guard_content: {
|
2783
|
+
# text: {
|
2784
|
+
# text: "String", # required
|
2785
|
+
# qualifiers: ["grounding_source"], # accepts grounding_source, query, guard_content
|
2786
|
+
# },
|
2787
|
+
# image: {
|
2788
|
+
# format: "png", # required, accepts png, jpeg
|
2789
|
+
# source: { # required
|
2790
|
+
# bytes: "data",
|
2791
|
+
# },
|
2792
|
+
# },
|
2793
|
+
# },
|
2794
|
+
# cache_point: {
|
2795
|
+
# type: "default", # required, accepts default
|
2796
|
+
# },
|
2797
|
+
# reasoning_content: {
|
2798
|
+
# reasoning_text: {
|
2799
|
+
# text: "String", # required
|
2800
|
+
# signature: "String",
|
2801
|
+
# },
|
2802
|
+
# redacted_content: "data",
|
2803
|
+
# },
|
2804
|
+
# citations_content: {
|
2805
|
+
# content: [
|
2806
|
+
# {
|
2807
|
+
# text: "String",
|
2808
|
+
# },
|
2809
|
+
# ],
|
2810
|
+
# citations: [
|
2811
|
+
# {
|
2812
|
+
# title: "String",
|
2813
|
+
# source_content: [
|
2814
|
+
# {
|
2815
|
+
# text: "String",
|
2816
|
+
# },
|
2817
|
+
# ],
|
2818
|
+
# location: {
|
2819
|
+
# document_char: {
|
2820
|
+
# document_index: 1,
|
2821
|
+
# start: 1,
|
2822
|
+
# end: 1,
|
2823
|
+
# },
|
2824
|
+
# document_page: {
|
2825
|
+
# document_index: 1,
|
2826
|
+
# start: 1,
|
2827
|
+
# end: 1,
|
2828
|
+
# },
|
2829
|
+
# document_chunk: {
|
2830
|
+
# document_index: 1,
|
2831
|
+
# start: 1,
|
2832
|
+
# end: 1,
|
2833
|
+
# },
|
2834
|
+
# },
|
2835
|
+
# },
|
2836
|
+
# ],
|
2837
|
+
# },
|
2838
|
+
# },
|
2839
|
+
# ],
|
2840
|
+
# },
|
2841
|
+
# ],
|
2842
|
+
# system: [
|
2843
|
+
# {
|
2844
|
+
# text: "NonEmptyString",
|
2845
|
+
# guard_content: {
|
2846
|
+
# text: {
|
2847
|
+
# text: "String", # required
|
2848
|
+
# qualifiers: ["grounding_source"], # accepts grounding_source, query, guard_content
|
2849
|
+
# },
|
2850
|
+
# image: {
|
2851
|
+
# format: "png", # required, accepts png, jpeg
|
2852
|
+
# source: { # required
|
2853
|
+
# bytes: "data",
|
2854
|
+
# },
|
2855
|
+
# },
|
2856
|
+
# },
|
2857
|
+
# cache_point: {
|
2858
|
+
# type: "default", # required, accepts default
|
2859
|
+
# },
|
2860
|
+
# },
|
2861
|
+
# ],
|
2862
|
+
# },
|
2863
|
+
# },
|
2864
|
+
# })
|
2865
|
+
#
|
2866
|
+
# @example Response structure
|
2867
|
+
#
|
2868
|
+
# resp.input_tokens #=> Integer
|
2869
|
+
#
|
2870
|
+
# @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/CountTokens AWS API Documentation
|
2871
|
+
#
|
2872
|
+
# @overload count_tokens(params = {})
|
2873
|
+
# @param [Hash] params ({})
|
2874
|
+
def count_tokens(params = {}, options = {})
|
2875
|
+
req = build_request(:count_tokens, params)
|
2876
|
+
req.send_request(options)
|
2877
|
+
end
|
2878
|
+
|
2610
2879
|
# Retrieve information about an asynchronous invocation.
|
2611
2880
|
#
|
2612
2881
|
# @option params [required, String] :invocation_arn
|
@@ -3305,7 +3574,7 @@ module Aws::BedrockRuntime
|
|
3305
3574
|
tracer: tracer
|
3306
3575
|
)
|
3307
3576
|
context[:gem_name] = 'aws-sdk-bedrockruntime'
|
3308
|
-
context[:gem_version] = '1.
|
3577
|
+
context[:gem_version] = '1.56.0'
|
3309
3578
|
Seahorse::Client::Request.new(handlers, context)
|
3310
3579
|
end
|
3311
3580
|
|
@@ -73,7 +73,11 @@ module Aws::BedrockRuntime
|
|
73
73
|
ConverseStreamRequestAdditionalModelResponseFieldPathsListMemberString = Shapes::StringShape.new(name: 'ConverseStreamRequestAdditionalModelResponseFieldPathsListMemberString')
|
74
74
|
ConverseStreamResponse = Shapes::StructureShape.new(name: 'ConverseStreamResponse')
|
75
75
|
ConverseStreamTrace = Shapes::StructureShape.new(name: 'ConverseStreamTrace')
|
76
|
+
ConverseTokensRequest = Shapes::StructureShape.new(name: 'ConverseTokensRequest')
|
76
77
|
ConverseTrace = Shapes::StructureShape.new(name: 'ConverseTrace')
|
78
|
+
CountTokensInput = Shapes::UnionShape.new(name: 'CountTokensInput')
|
79
|
+
CountTokensRequest = Shapes::StructureShape.new(name: 'CountTokensRequest')
|
80
|
+
CountTokensResponse = Shapes::StructureShape.new(name: 'CountTokensResponse')
|
77
81
|
Document = Shapes::DocumentShape.new(name: 'Document', document: true)
|
78
82
|
DocumentBlock = Shapes::StructureShape.new(name: 'DocumentBlock')
|
79
83
|
DocumentBlockNameString = Shapes::StringShape.new(name: 'DocumentBlockNameString')
|
@@ -94,6 +98,7 @@ module Aws::BedrockRuntime
|
|
94
98
|
DocumentPageLocationStartInteger = Shapes::IntegerShape.new(name: 'DocumentPageLocationStartInteger')
|
95
99
|
DocumentSource = Shapes::UnionShape.new(name: 'DocumentSource')
|
96
100
|
DocumentSourceBytesBlob = Shapes::BlobShape.new(name: 'DocumentSourceBytesBlob')
|
101
|
+
FoundationModelVersionIdentifier = Shapes::StringShape.new(name: 'FoundationModelVersionIdentifier')
|
97
102
|
GetAsyncInvokeRequest = Shapes::StructureShape.new(name: 'GetAsyncInvokeRequest')
|
98
103
|
GetAsyncInvokeResponse = Shapes::StructureShape.new(name: 'GetAsyncInvokeResponse')
|
99
104
|
GuardrailAction = Shapes::StringShape.new(name: 'GuardrailAction')
|
@@ -217,11 +222,13 @@ module Aws::BedrockRuntime
|
|
217
222
|
InferenceConfigurationStopSequencesList = Shapes::ListShape.new(name: 'InferenceConfigurationStopSequencesList')
|
218
223
|
InferenceConfigurationTemperatureFloat = Shapes::FloatShape.new(name: 'InferenceConfigurationTemperatureFloat')
|
219
224
|
InferenceConfigurationTopPFloat = Shapes::FloatShape.new(name: 'InferenceConfigurationTopPFloat')
|
225
|
+
Integer = Shapes::IntegerShape.new(name: 'Integer')
|
220
226
|
InternalServerException = Shapes::StructureShape.new(name: 'InternalServerException')
|
221
227
|
InvocationArn = Shapes::StringShape.new(name: 'InvocationArn')
|
222
228
|
InvokeModelIdentifier = Shapes::StringShape.new(name: 'InvokeModelIdentifier')
|
223
229
|
InvokeModelRequest = Shapes::StructureShape.new(name: 'InvokeModelRequest')
|
224
230
|
InvokeModelResponse = Shapes::StructureShape.new(name: 'InvokeModelResponse')
|
231
|
+
InvokeModelTokensRequest = Shapes::StructureShape.new(name: 'InvokeModelTokensRequest')
|
225
232
|
InvokeModelWithBidirectionalStreamInput = Shapes::StructureShape.new(name: 'InvokeModelWithBidirectionalStreamInput')
|
226
233
|
InvokeModelWithBidirectionalStreamOutput = Shapes::StructureShape.new(name: 'InvokeModelWithBidirectionalStreamOutput')
|
227
234
|
InvokeModelWithBidirectionalStreamRequest = Shapes::StructureShape.new(name: 'InvokeModelWithBidirectionalStreamRequest')
|
@@ -556,10 +563,29 @@ module Aws::BedrockRuntime
|
|
556
563
|
ConverseStreamTrace.add_member(:prompt_router, Shapes::ShapeRef.new(shape: PromptRouterTrace, location_name: "promptRouter"))
|
557
564
|
ConverseStreamTrace.struct_class = Types::ConverseStreamTrace
|
558
565
|
|
566
|
+
ConverseTokensRequest.add_member(:messages, Shapes::ShapeRef.new(shape: Messages, location_name: "messages"))
|
567
|
+
ConverseTokensRequest.add_member(:system, Shapes::ShapeRef.new(shape: SystemContentBlocks, location_name: "system"))
|
568
|
+
ConverseTokensRequest.struct_class = Types::ConverseTokensRequest
|
569
|
+
|
559
570
|
ConverseTrace.add_member(:guardrail, Shapes::ShapeRef.new(shape: GuardrailTraceAssessment, location_name: "guardrail"))
|
560
571
|
ConverseTrace.add_member(:prompt_router, Shapes::ShapeRef.new(shape: PromptRouterTrace, location_name: "promptRouter"))
|
561
572
|
ConverseTrace.struct_class = Types::ConverseTrace
|
562
573
|
|
574
|
+
CountTokensInput.add_member(:invoke_model, Shapes::ShapeRef.new(shape: InvokeModelTokensRequest, location_name: "invokeModel"))
|
575
|
+
CountTokensInput.add_member(:converse, Shapes::ShapeRef.new(shape: ConverseTokensRequest, location_name: "converse"))
|
576
|
+
CountTokensInput.add_member(:unknown, Shapes::ShapeRef.new(shape: nil, location_name: 'unknown'))
|
577
|
+
CountTokensInput.add_member_subclass(:invoke_model, Types::CountTokensInput::InvokeModel)
|
578
|
+
CountTokensInput.add_member_subclass(:converse, Types::CountTokensInput::Converse)
|
579
|
+
CountTokensInput.add_member_subclass(:unknown, Types::CountTokensInput::Unknown)
|
580
|
+
CountTokensInput.struct_class = Types::CountTokensInput
|
581
|
+
|
582
|
+
CountTokensRequest.add_member(:model_id, Shapes::ShapeRef.new(shape: FoundationModelVersionIdentifier, required: true, location: "uri", location_name: "modelId"))
|
583
|
+
CountTokensRequest.add_member(:input, Shapes::ShapeRef.new(shape: CountTokensInput, required: true, location_name: "input"))
|
584
|
+
CountTokensRequest.struct_class = Types::CountTokensRequest
|
585
|
+
|
586
|
+
CountTokensResponse.add_member(:input_tokens, Shapes::ShapeRef.new(shape: Integer, required: true, location_name: "inputTokens"))
|
587
|
+
CountTokensResponse.struct_class = Types::CountTokensResponse
|
588
|
+
|
563
589
|
DocumentBlock.add_member(:format, Shapes::ShapeRef.new(shape: DocumentFormat, location_name: "format"))
|
564
590
|
DocumentBlock.add_member(:name, Shapes::ShapeRef.new(shape: DocumentBlockNameString, required: true, location_name: "name"))
|
565
591
|
DocumentBlock.add_member(:source, Shapes::ShapeRef.new(shape: DocumentSource, required: true, location_name: "source"))
|
@@ -944,6 +970,9 @@ module Aws::BedrockRuntime
|
|
944
970
|
InvokeModelResponse[:payload] = :body
|
945
971
|
InvokeModelResponse[:payload_member] = InvokeModelResponse.member(:body)
|
946
972
|
|
973
|
+
InvokeModelTokensRequest.add_member(:body, Shapes::ShapeRef.new(shape: Body, required: true, location_name: "body"))
|
974
|
+
InvokeModelTokensRequest.struct_class = Types::InvokeModelTokensRequest
|
975
|
+
|
947
976
|
InvokeModelWithBidirectionalStreamInput.add_member(:chunk, Shapes::ShapeRef.new(shape: BidirectionalInputPayloadPart, event: true, location_name: "chunk"))
|
948
977
|
InvokeModelWithBidirectionalStreamInput.struct_class = Types::InvokeModelWithBidirectionalStreamInput
|
949
978
|
|
@@ -1287,6 +1316,20 @@ module Aws::BedrockRuntime
|
|
1287
1316
|
o.errors << Shapes::ShapeRef.new(shape: ModelErrorException)
|
1288
1317
|
end)
|
1289
1318
|
|
1319
|
+
api.add_operation(:count_tokens, Seahorse::Model::Operation.new.tap do |o|
|
1320
|
+
o.name = "CountTokens"
|
1321
|
+
o.http_method = "POST"
|
1322
|
+
o.http_request_uri = "/model/{modelId}/count-tokens"
|
1323
|
+
o.input = Shapes::ShapeRef.new(shape: CountTokensRequest)
|
1324
|
+
o.output = Shapes::ShapeRef.new(shape: CountTokensResponse)
|
1325
|
+
o.errors << Shapes::ShapeRef.new(shape: AccessDeniedException)
|
1326
|
+
o.errors << Shapes::ShapeRef.new(shape: ResourceNotFoundException)
|
1327
|
+
o.errors << Shapes::ShapeRef.new(shape: ThrottlingException)
|
1328
|
+
o.errors << Shapes::ShapeRef.new(shape: InternalServerException)
|
1329
|
+
o.errors << Shapes::ShapeRef.new(shape: ServiceUnavailableException)
|
1330
|
+
o.errors << Shapes::ShapeRef.new(shape: ValidationException)
|
1331
|
+
end)
|
1332
|
+
|
1290
1333
|
api.add_operation(:get_async_invoke, Seahorse::Model::Operation.new.tap do |o|
|
1291
1334
|
o.name = "GetAsyncInvoke"
|
1292
1335
|
o.http_method = "GET"
|
@@ -1168,6 +1168,32 @@ module Aws::BedrockRuntime
|
|
1168
1168
|
include Aws::Structure
|
1169
1169
|
end
|
1170
1170
|
|
1171
|
+
# The inputs from a `Converse` API request for token counting.
|
1172
|
+
#
|
1173
|
+
# This structure mirrors the input format for the `Converse` operation,
|
1174
|
+
# allowing you to count tokens for conversation-based inference
|
1175
|
+
# requests.
|
1176
|
+
#
|
1177
|
+
# @!attribute [rw] messages
|
1178
|
+
# An array of messages to count tokens for.
|
1179
|
+
# @return [Array<Types::Message>]
|
1180
|
+
#
|
1181
|
+
# @!attribute [rw] system
|
1182
|
+
# The system content blocks to count tokens for. System content
|
1183
|
+
# provides instructions or context to the model about how it should
|
1184
|
+
# behave or respond. The token count will include any system content
|
1185
|
+
# provided.
|
1186
|
+
# @return [Array<Types::SystemContentBlock>]
|
1187
|
+
#
|
1188
|
+
# @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/ConverseTokensRequest AWS API Documentation
|
1189
|
+
#
|
1190
|
+
class ConverseTokensRequest < Struct.new(
|
1191
|
+
:messages,
|
1192
|
+
:system)
|
1193
|
+
SENSITIVE = []
|
1194
|
+
include Aws::Structure
|
1195
|
+
end
|
1196
|
+
|
1171
1197
|
# The trace object in a response from [Converse][1]. Currently, you can
|
1172
1198
|
# only trace guardrails.
|
1173
1199
|
#
|
@@ -1192,6 +1218,85 @@ module Aws::BedrockRuntime
|
|
1192
1218
|
include Aws::Structure
|
1193
1219
|
end
|
1194
1220
|
|
1221
|
+
# The input value for token counting. The value should be either an
|
1222
|
+
# `InvokeModel` or `Converse` request body.
|
1223
|
+
#
|
1224
|
+
# @note CountTokensInput is a union - when making an API calls you must set exactly one of the members.
|
1225
|
+
#
|
1226
|
+
# @!attribute [rw] invoke_model
|
1227
|
+
# An `InvokeModel` request for which to count tokens. Use this field
|
1228
|
+
# when you want to count tokens for a raw text input that would be
|
1229
|
+
# sent to the `InvokeModel` operation.
|
1230
|
+
# @return [Types::InvokeModelTokensRequest]
|
1231
|
+
#
|
1232
|
+
# @!attribute [rw] converse
|
1233
|
+
# A `Converse` request for which to count tokens. Use this field when
|
1234
|
+
# you want to count tokens for a conversation-based input that would
|
1235
|
+
# be sent to the `Converse` operation.
|
1236
|
+
# @return [Types::ConverseTokensRequest]
|
1237
|
+
#
|
1238
|
+
# @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/CountTokensInput AWS API Documentation
|
1239
|
+
#
|
1240
|
+
class CountTokensInput < Struct.new(
|
1241
|
+
:invoke_model,
|
1242
|
+
:converse,
|
1243
|
+
:unknown)
|
1244
|
+
SENSITIVE = []
|
1245
|
+
include Aws::Structure
|
1246
|
+
include Aws::Structure::Union
|
1247
|
+
|
1248
|
+
class InvokeModel < CountTokensInput; end
|
1249
|
+
class Converse < CountTokensInput; end
|
1250
|
+
class Unknown < CountTokensInput; end
|
1251
|
+
end
|
1252
|
+
|
1253
|
+
# @!attribute [rw] model_id
|
1254
|
+
# The unique identifier or ARN of the foundation model to use for
|
1255
|
+
# token counting. Each model processes tokens differently, so the
|
1256
|
+
# token count is specific to the model you specify.
|
1257
|
+
# @return [String]
|
1258
|
+
#
|
1259
|
+
# @!attribute [rw] input
|
1260
|
+
# The input for which to count tokens. The structure of this parameter
|
1261
|
+
# depends on whether you're counting tokens for an `InvokeModel` or
|
1262
|
+
# `Converse` request:
|
1263
|
+
#
|
1264
|
+
# * For `InvokeModel` requests, provide the request body in the
|
1265
|
+
# `invokeModel` field
|
1266
|
+
#
|
1267
|
+
# * For `Converse` requests, provide the messages and system content
|
1268
|
+
# in the `converse` field
|
1269
|
+
#
|
1270
|
+
# The input format must be compatible with the model specified in the
|
1271
|
+
# `modelId` parameter.
|
1272
|
+
# @return [Types::CountTokensInput]
|
1273
|
+
#
|
1274
|
+
# @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/CountTokensRequest AWS API Documentation
|
1275
|
+
#
|
1276
|
+
class CountTokensRequest < Struct.new(
|
1277
|
+
:model_id,
|
1278
|
+
:input)
|
1279
|
+
SENSITIVE = []
|
1280
|
+
include Aws::Structure
|
1281
|
+
end
|
1282
|
+
|
1283
|
+
# @!attribute [rw] input_tokens
|
1284
|
+
# The number of tokens in the provided input according to the
|
1285
|
+
# specified model's tokenization rules. This count represents the
|
1286
|
+
# number of input tokens that would be processed if the same input
|
1287
|
+
# were sent to the model in an inference request. Use this value to
|
1288
|
+
# estimate costs and ensure your inputs stay within model token
|
1289
|
+
# limits.
|
1290
|
+
# @return [Integer]
|
1291
|
+
#
|
1292
|
+
# @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/CountTokensResponse AWS API Documentation
|
1293
|
+
#
|
1294
|
+
class CountTokensResponse < Struct.new(
|
1295
|
+
:input_tokens)
|
1296
|
+
SENSITIVE = []
|
1297
|
+
include Aws::Structure
|
1298
|
+
end
|
1299
|
+
|
1195
1300
|
# A document to include in a message.
|
1196
1301
|
#
|
1197
1302
|
# @!attribute [rw] format
|
@@ -1521,39 +1626,46 @@ module Aws::BedrockRuntime
|
|
1521
1626
|
# @note GuardrailAutomatedReasoningFinding is a union - when returned from an API call exactly one value will be set and the returned type will be a subclass of GuardrailAutomatedReasoningFinding corresponding to the set member.
|
1522
1627
|
#
|
1523
1628
|
# @!attribute [rw] valid
|
1524
|
-
#
|
1525
|
-
#
|
1526
|
-
#
|
1629
|
+
# Contains the result when the automated reasoning evaluation
|
1630
|
+
# determines that the claims in the input are logically valid and
|
1631
|
+
# definitively true based on the provided premises and policy rules.
|
1527
1632
|
# @return [Types::GuardrailAutomatedReasoningValidFinding]
|
1528
1633
|
#
|
1529
1634
|
# @!attribute [rw] invalid
|
1530
|
-
#
|
1531
|
-
# the
|
1635
|
+
# Contains the result when the automated reasoning evaluation
|
1636
|
+
# determines that the claims in the input are logically invalid and
|
1637
|
+
# contradict the established premises or policy rules.
|
1532
1638
|
# @return [Types::GuardrailAutomatedReasoningInvalidFinding]
|
1533
1639
|
#
|
1534
1640
|
# @!attribute [rw] satisfiable
|
1535
|
-
#
|
1536
|
-
#
|
1641
|
+
# Contains the result when the automated reasoning evaluation
|
1642
|
+
# determines that the claims in the input could be either true or
|
1643
|
+
# false depending on additional assumptions not provided in the input
|
1644
|
+
# context.
|
1537
1645
|
# @return [Types::GuardrailAutomatedReasoningSatisfiableFinding]
|
1538
1646
|
#
|
1539
1647
|
# @!attribute [rw] impossible
|
1540
|
-
#
|
1541
|
-
#
|
1648
|
+
# Contains the result when the automated reasoning evaluation
|
1649
|
+
# determines that no valid logical conclusions can be drawn due to
|
1650
|
+
# contradictions in the premises or policy rules themselves.
|
1542
1651
|
# @return [Types::GuardrailAutomatedReasoningImpossibleFinding]
|
1543
1652
|
#
|
1544
1653
|
# @!attribute [rw] translation_ambiguous
|
1545
|
-
#
|
1546
|
-
#
|
1654
|
+
# Contains the result when the automated reasoning evaluation detects
|
1655
|
+
# that the input has multiple valid logical interpretations, requiring
|
1656
|
+
# additional context or clarification to proceed with validation.
|
1547
1657
|
# @return [Types::GuardrailAutomatedReasoningTranslationAmbiguousFinding]
|
1548
1658
|
#
|
1549
1659
|
# @!attribute [rw] too_complex
|
1550
|
-
#
|
1551
|
-
#
|
1660
|
+
# Contains the result when the automated reasoning evaluation cannot
|
1661
|
+
# process the input due to its complexity or volume exceeding the
|
1662
|
+
# system's processing capacity for logical analysis.
|
1552
1663
|
# @return [Types::GuardrailAutomatedReasoningTooComplexFinding]
|
1553
1664
|
#
|
1554
1665
|
# @!attribute [rw] no_translations
|
1555
|
-
#
|
1556
|
-
# from the input
|
1666
|
+
# Contains the result when the automated reasoning evaluation cannot
|
1667
|
+
# extract any relevant logical information from the input that can be
|
1668
|
+
# validated against the policy rules.
|
1557
1669
|
# @return [Types::GuardrailAutomatedReasoningNoTranslationsFinding]
|
1558
1670
|
#
|
1559
1671
|
# @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/GuardrailAutomatedReasoningFinding AWS API Documentation
|
@@ -2939,6 +3051,28 @@ module Aws::BedrockRuntime
|
|
2939
3051
|
include Aws::Structure
|
2940
3052
|
end
|
2941
3053
|
|
3054
|
+
# The body of an `InvokeModel` API request for token counting. This
|
3055
|
+
# structure mirrors the input format for the `InvokeModel` operation,
|
3056
|
+
# allowing you to count tokens for raw text inference requests.
|
3057
|
+
#
|
3058
|
+
# @!attribute [rw] body
|
3059
|
+
# The request body to count tokens for, formatted according to the
|
3060
|
+
# model's expected input format. To learn about the input format for
|
3061
|
+
# different models, see [Model inference parameters and responses][1].
|
3062
|
+
#
|
3063
|
+
#
|
3064
|
+
#
|
3065
|
+
# [1]: https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html
|
3066
|
+
# @return [String]
|
3067
|
+
#
|
3068
|
+
# @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-runtime-2023-09-30/InvokeModelTokensRequest AWS API Documentation
|
3069
|
+
#
|
3070
|
+
class InvokeModelTokensRequest < Struct.new(
|
3071
|
+
:body)
|
3072
|
+
SENSITIVE = [:body]
|
3073
|
+
include Aws::Structure
|
3074
|
+
end
|
3075
|
+
|
2942
3076
|
# @!attribute [rw] model_id
|
2943
3077
|
# The model ID or ARN of the model ID to use. Currently, only
|
2944
3078
|
# `amazon.nova-sonic-v1:0` is supported.
|
data/sig/client.rbs
CHANGED
@@ -604,6 +604,208 @@ module Aws
|
|
604
604
|
) ?{ (*untyped) -> void } -> _ConverseStreamResponseSuccess
|
605
605
|
| (Hash[Symbol, untyped] params, ?Hash[Symbol, untyped] options) ?{ (*untyped) -> void } -> _ConverseStreamResponseSuccess
|
606
606
|
|
607
|
+
interface _CountTokensResponseSuccess
|
608
|
+
include ::Seahorse::Client::_ResponseSuccess[Types::CountTokensResponse]
|
609
|
+
def input_tokens: () -> ::Integer
|
610
|
+
end
|
611
|
+
# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/BedrockRuntime/Client.html#count_tokens-instance_method
|
612
|
+
def count_tokens: (
|
613
|
+
model_id: ::String,
|
614
|
+
input: {
|
615
|
+
invoke_model: {
|
616
|
+
body: ::String
|
617
|
+
}?,
|
618
|
+
converse: {
|
619
|
+
messages: Array[
|
620
|
+
{
|
621
|
+
role: ("user" | "assistant"),
|
622
|
+
content: Array[
|
623
|
+
{
|
624
|
+
text: ::String?,
|
625
|
+
image: {
|
626
|
+
format: ("png" | "jpeg" | "gif" | "webp"),
|
627
|
+
source: {
|
628
|
+
bytes: ::String?,
|
629
|
+
s3_location: {
|
630
|
+
uri: ::String,
|
631
|
+
bucket_owner: ::String?
|
632
|
+
}?
|
633
|
+
}
|
634
|
+
}?,
|
635
|
+
document: {
|
636
|
+
format: ("pdf" | "csv" | "doc" | "docx" | "xls" | "xlsx" | "html" | "txt" | "md")?,
|
637
|
+
name: ::String,
|
638
|
+
source: {
|
639
|
+
bytes: ::String?,
|
640
|
+
s3_location: {
|
641
|
+
uri: ::String,
|
642
|
+
bucket_owner: ::String?
|
643
|
+
}?,
|
644
|
+
text: ::String?,
|
645
|
+
content: Array[
|
646
|
+
{
|
647
|
+
text: ::String?
|
648
|
+
},
|
649
|
+
]?
|
650
|
+
},
|
651
|
+
context: ::String?,
|
652
|
+
citations: {
|
653
|
+
enabled: bool
|
654
|
+
}?
|
655
|
+
}?,
|
656
|
+
video: {
|
657
|
+
format: ("mkv" | "mov" | "mp4" | "webm" | "flv" | "mpeg" | "mpg" | "wmv" | "three_gp"),
|
658
|
+
source: {
|
659
|
+
bytes: ::String?,
|
660
|
+
s3_location: {
|
661
|
+
uri: ::String,
|
662
|
+
bucket_owner: ::String?
|
663
|
+
}?
|
664
|
+
}
|
665
|
+
}?,
|
666
|
+
tool_use: {
|
667
|
+
tool_use_id: ::String,
|
668
|
+
name: ::String,
|
669
|
+
input: {
|
670
|
+
}
|
671
|
+
}?,
|
672
|
+
tool_result: {
|
673
|
+
tool_use_id: ::String,
|
674
|
+
content: Array[
|
675
|
+
{
|
676
|
+
json: {
|
677
|
+
}?,
|
678
|
+
text: ::String?,
|
679
|
+
image: {
|
680
|
+
format: ("png" | "jpeg" | "gif" | "webp"),
|
681
|
+
source: {
|
682
|
+
bytes: ::String?,
|
683
|
+
s3_location: {
|
684
|
+
uri: ::String,
|
685
|
+
bucket_owner: ::String?
|
686
|
+
}?
|
687
|
+
}
|
688
|
+
}?,
|
689
|
+
document: {
|
690
|
+
format: ("pdf" | "csv" | "doc" | "docx" | "xls" | "xlsx" | "html" | "txt" | "md")?,
|
691
|
+
name: ::String,
|
692
|
+
source: {
|
693
|
+
bytes: ::String?,
|
694
|
+
s3_location: {
|
695
|
+
uri: ::String,
|
696
|
+
bucket_owner: ::String?
|
697
|
+
}?,
|
698
|
+
text: ::String?,
|
699
|
+
content: Array[
|
700
|
+
{
|
701
|
+
text: ::String?
|
702
|
+
},
|
703
|
+
]?
|
704
|
+
},
|
705
|
+
context: ::String?,
|
706
|
+
citations: {
|
707
|
+
enabled: bool
|
708
|
+
}?
|
709
|
+
}?,
|
710
|
+
video: {
|
711
|
+
format: ("mkv" | "mov" | "mp4" | "webm" | "flv" | "mpeg" | "mpg" | "wmv" | "three_gp"),
|
712
|
+
source: {
|
713
|
+
bytes: ::String?,
|
714
|
+
s3_location: {
|
715
|
+
uri: ::String,
|
716
|
+
bucket_owner: ::String?
|
717
|
+
}?
|
718
|
+
}
|
719
|
+
}?
|
720
|
+
},
|
721
|
+
],
|
722
|
+
status: ("success" | "error")?
|
723
|
+
}?,
|
724
|
+
guard_content: {
|
725
|
+
text: {
|
726
|
+
text: ::String,
|
727
|
+
qualifiers: Array[("grounding_source" | "query" | "guard_content")]?
|
728
|
+
}?,
|
729
|
+
image: {
|
730
|
+
format: ("png" | "jpeg"),
|
731
|
+
source: {
|
732
|
+
bytes: ::String?
|
733
|
+
}
|
734
|
+
}?
|
735
|
+
}?,
|
736
|
+
cache_point: {
|
737
|
+
type: ("default")
|
738
|
+
}?,
|
739
|
+
reasoning_content: {
|
740
|
+
reasoning_text: {
|
741
|
+
text: ::String,
|
742
|
+
signature: ::String?
|
743
|
+
}?,
|
744
|
+
redacted_content: ::String?
|
745
|
+
}?,
|
746
|
+
citations_content: {
|
747
|
+
content: Array[
|
748
|
+
{
|
749
|
+
text: ::String?
|
750
|
+
},
|
751
|
+
]?,
|
752
|
+
citations: Array[
|
753
|
+
{
|
754
|
+
title: ::String?,
|
755
|
+
source_content: Array[
|
756
|
+
{
|
757
|
+
text: ::String?
|
758
|
+
},
|
759
|
+
]?,
|
760
|
+
location: {
|
761
|
+
document_char: {
|
762
|
+
document_index: ::Integer?,
|
763
|
+
start: ::Integer?,
|
764
|
+
end: ::Integer?
|
765
|
+
}?,
|
766
|
+
document_page: {
|
767
|
+
document_index: ::Integer?,
|
768
|
+
start: ::Integer?,
|
769
|
+
end: ::Integer?
|
770
|
+
}?,
|
771
|
+
document_chunk: {
|
772
|
+
document_index: ::Integer?,
|
773
|
+
start: ::Integer?,
|
774
|
+
end: ::Integer?
|
775
|
+
}?
|
776
|
+
}?
|
777
|
+
},
|
778
|
+
]?
|
779
|
+
}?
|
780
|
+
},
|
781
|
+
]
|
782
|
+
},
|
783
|
+
]?,
|
784
|
+
system: Array[
|
785
|
+
{
|
786
|
+
text: ::String?,
|
787
|
+
guard_content: {
|
788
|
+
text: {
|
789
|
+
text: ::String,
|
790
|
+
qualifiers: Array[("grounding_source" | "query" | "guard_content")]?
|
791
|
+
}?,
|
792
|
+
image: {
|
793
|
+
format: ("png" | "jpeg"),
|
794
|
+
source: {
|
795
|
+
bytes: ::String?
|
796
|
+
}
|
797
|
+
}?
|
798
|
+
}?,
|
799
|
+
cache_point: {
|
800
|
+
type: ("default")
|
801
|
+
}?
|
802
|
+
},
|
803
|
+
]?
|
804
|
+
}?
|
805
|
+
}
|
806
|
+
) -> _CountTokensResponseSuccess
|
807
|
+
| (Hash[Symbol, untyped] params, ?Hash[Symbol, untyped] options) -> _CountTokensResponseSuccess
|
808
|
+
|
607
809
|
interface _GetAsyncInvokeResponseSuccess
|
608
810
|
include ::Seahorse::Client::_ResponseSuccess[Types::GetAsyncInvokeResponse]
|
609
811
|
def invocation_arn: () -> ::String
|
data/sig/types.rbs
CHANGED
@@ -331,12 +331,43 @@ module Aws::BedrockRuntime
|
|
331
331
|
SENSITIVE: []
|
332
332
|
end
|
333
333
|
|
334
|
+
class ConverseTokensRequest
|
335
|
+
attr_accessor messages: ::Array[Types::Message]
|
336
|
+
attr_accessor system: ::Array[Types::SystemContentBlock]
|
337
|
+
SENSITIVE: []
|
338
|
+
end
|
339
|
+
|
334
340
|
class ConverseTrace
|
335
341
|
attr_accessor guardrail: Types::GuardrailTraceAssessment
|
336
342
|
attr_accessor prompt_router: Types::PromptRouterTrace
|
337
343
|
SENSITIVE: []
|
338
344
|
end
|
339
345
|
|
346
|
+
class CountTokensInput
|
347
|
+
attr_accessor invoke_model: Types::InvokeModelTokensRequest
|
348
|
+
attr_accessor converse: Types::ConverseTokensRequest
|
349
|
+
attr_accessor unknown: untyped
|
350
|
+
SENSITIVE: []
|
351
|
+
|
352
|
+
class InvokeModel < CountTokensInput
|
353
|
+
end
|
354
|
+
class Converse < CountTokensInput
|
355
|
+
end
|
356
|
+
class Unknown < CountTokensInput
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
class CountTokensRequest
|
361
|
+
attr_accessor model_id: ::String
|
362
|
+
attr_accessor input: Types::CountTokensInput
|
363
|
+
SENSITIVE: []
|
364
|
+
end
|
365
|
+
|
366
|
+
class CountTokensResponse
|
367
|
+
attr_accessor input_tokens: ::Integer
|
368
|
+
SENSITIVE: []
|
369
|
+
end
|
370
|
+
|
340
371
|
class DocumentBlock
|
341
372
|
attr_accessor format: ("pdf" | "csv" | "doc" | "docx" | "xls" | "xlsx" | "html" | "txt" | "md")
|
342
373
|
attr_accessor name: ::String
|
@@ -824,6 +855,11 @@ module Aws::BedrockRuntime
|
|
824
855
|
SENSITIVE: [:body]
|
825
856
|
end
|
826
857
|
|
858
|
+
class InvokeModelTokensRequest
|
859
|
+
attr_accessor body: ::String
|
860
|
+
SENSITIVE: [:body]
|
861
|
+
end
|
862
|
+
|
827
863
|
class InvokeModelWithBidirectionalStreamRequest
|
828
864
|
attr_accessor model_id: ::String
|
829
865
|
attr_accessor body: Types::InvokeModelWithBidirectionalStreamInput
|