anthropic 1.1.0 → 1.2.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 +62 -0
- data/README.md +32 -16
- data/lib/anthropic/errors.rb +22 -0
- data/lib/anthropic/helpers/bedrock/client.rb +3 -1
- data/lib/anthropic/helpers/streaming/events.rb +141 -0
- data/lib/anthropic/helpers/streaming/message_stream.rb +238 -0
- data/lib/anthropic/helpers/streaming.rb +37 -0
- data/lib/anthropic/helpers/vertex/client.rb +8 -3
- data/lib/anthropic/internal/stream.rb +4 -2
- data/lib/anthropic/internal/transport/base_client.rb +10 -2
- data/lib/anthropic/internal/type/array_of.rb +6 -1
- data/lib/anthropic/internal/type/base_model.rb +77 -23
- data/lib/anthropic/internal/type/base_stream.rb +3 -1
- data/lib/anthropic/internal/type/boolean.rb +7 -1
- data/lib/anthropic/internal/type/converter.rb +42 -34
- data/lib/anthropic/internal/type/enum.rb +16 -5
- data/lib/anthropic/internal/type/file_input.rb +6 -1
- data/lib/anthropic/internal/type/hash_of.rb +6 -1
- data/lib/anthropic/internal/type/union.rb +17 -9
- data/lib/anthropic/internal/type/unknown.rb +7 -1
- data/lib/anthropic/internal/util.rb +18 -11
- data/lib/anthropic/models/beta/beta_base64_pdf_block.rb +1 -65
- data/lib/anthropic/models/beta/beta_citation_search_result_location.rb +55 -0
- data/lib/anthropic/models/beta/beta_citation_search_result_location_param.rb +55 -0
- data/lib/anthropic/models/beta/beta_citations_delta.rb +5 -3
- data/lib/anthropic/models/beta/beta_content_block.rb +5 -5
- data/lib/anthropic/models/beta/beta_content_block_param.rb +20 -17
- data/lib/anthropic/models/beta/beta_message.rb +6 -2
- data/lib/anthropic/models/beta/beta_message_param.rb +3 -3
- data/lib/anthropic/models/beta/beta_raw_content_block_start_event.rb +7 -7
- data/lib/anthropic/models/beta/beta_request_document_block.rb +75 -0
- data/lib/anthropic/models/beta/beta_search_result_block_param.rb +55 -0
- data/lib/anthropic/models/beta/beta_text_block.rb +2 -2
- data/lib/anthropic/models/beta/beta_text_block_param.rb +2 -2
- data/lib/anthropic/models/beta/beta_text_citation.rb +3 -1
- data/lib/anthropic/models/beta/beta_text_citation_param.rb +3 -1
- data/lib/anthropic/models/beta/beta_tool.rb +7 -1
- data/lib/anthropic/models/beta/beta_tool_result_block_param.rb +6 -4
- data/lib/anthropic/models/beta/beta_tool_union.rb +7 -7
- data/lib/anthropic/models/beta/message_count_tokens_params.rb +16 -10
- data/lib/anthropic/models/beta/message_create_params.rb +9 -3
- data/lib/anthropic/models/beta/messages/batch_create_params.rb +9 -3
- data/lib/anthropic/models/content_block.rb +5 -5
- data/lib/anthropic/models/content_block_param.rb +11 -11
- data/lib/anthropic/models/message.rb +6 -2
- data/lib/anthropic/models/message_count_tokens_params.rb +9 -3
- data/lib/anthropic/models/message_count_tokens_tool.rb +35 -1
- data/lib/anthropic/models/message_create_params.rb +9 -3
- data/lib/anthropic/models/message_param.rb +3 -3
- data/lib/anthropic/models/messages/batch_create_params.rb +9 -3
- data/lib/anthropic/models/model.rb +6 -0
- data/lib/anthropic/models/raw_content_block_start_event.rb +7 -7
- data/lib/anthropic/models/tool.rb +7 -1
- data/lib/anthropic/models/tool_union.rb +34 -1
- data/lib/anthropic/models/tool_use_block.rb +6 -0
- data/lib/anthropic/models.rb +4 -4
- data/lib/anthropic/resources/beta/messages.rb +5 -5
- data/lib/anthropic/resources/messages.rb +68 -7
- data/lib/anthropic/streaming.rb +5 -0
- data/lib/anthropic/version.rb +1 -1
- data/lib/anthropic.rb +11 -1
- data/rbi/anthropic/errors.rbi +16 -0
- data/rbi/anthropic/helpers/streaming/events.rbi +85 -0
- data/rbi/anthropic/helpers/streaming/message_stream.rbi +59 -0
- data/rbi/anthropic/internal/type/base_stream.rbi +8 -1
- data/rbi/anthropic/internal/type/boolean.rbi +2 -0
- data/rbi/anthropic/internal/type/converter.rbi +15 -15
- data/rbi/anthropic/internal/type/union.rbi +5 -0
- data/rbi/anthropic/internal/type/unknown.rbi +2 -0
- data/rbi/anthropic/internal/util.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_base64_pdf_block.rbi +1 -128
- data/rbi/anthropic/models/beta/beta_citation_search_result_location.rbi +78 -0
- data/rbi/anthropic/models/beta/beta_citation_search_result_location_param.rbi +79 -0
- data/rbi/anthropic/models/beta/beta_citations_delta.rbi +4 -2
- data/rbi/anthropic/models/beta/beta_content_block.rbi +3 -3
- data/rbi/anthropic/models/beta/beta_content_block_param.rbi +8 -7
- data/rbi/anthropic/models/beta/beta_message.rbi +11 -3
- data/rbi/anthropic/models/beta/beta_raw_content_block_start_event.rbi +6 -6
- data/rbi/anthropic/models/beta/beta_request_document_block.rbi +140 -0
- data/rbi/anthropic/models/beta/beta_search_result_block_param.rbi +91 -0
- data/rbi/anthropic/models/beta/beta_text_block.rbi +2 -1
- data/rbi/anthropic/models/beta/beta_text_block_param.rbi +6 -3
- data/rbi/anthropic/models/beta/beta_text_citation.rbi +2 -1
- data/rbi/anthropic/models/beta/beta_text_citation_param.rbi +2 -1
- data/rbi/anthropic/models/beta/beta_tool.rbi +14 -5
- data/rbi/anthropic/models/beta/beta_tool_result_block_param.rbi +2 -1
- data/rbi/anthropic/models/beta/beta_tool_union.rbi +5 -5
- data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +39 -27
- data/rbi/anthropic/models/beta/message_create_params.rbi +34 -22
- data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +34 -22
- data/rbi/anthropic/models/content_block.rbi +3 -3
- data/rbi/anthropic/models/content_block_param.rbi +5 -5
- data/rbi/anthropic/models/message.rbi +11 -3
- data/rbi/anthropic/models/message_count_tokens_params.rbi +18 -2
- data/rbi/anthropic/models/message_count_tokens_tool.rbi +61 -0
- data/rbi/anthropic/models/message_create_params.rbi +18 -2
- data/rbi/anthropic/models/messages/batch_create_params.rbi +18 -2
- data/rbi/anthropic/models/raw_content_block_start_event.rbi +6 -6
- data/rbi/anthropic/models/tool.rbi +16 -5
- data/rbi/anthropic/models/tool_union.rbi +61 -0
- data/rbi/anthropic/resources/beta/messages.rbi +36 -18
- data/rbi/anthropic/resources/messages.rbi +293 -3
- data/rbi/anthropic/streaming.rbi +5 -0
- data/sig/anthropic/errors.rbs +9 -0
- data/sig/anthropic/helpers/streaming/events.rbs +119 -0
- data/sig/anthropic/helpers/streaming/message_stream.rbs +55 -0
- data/sig/anthropic/internal/type/base_stream.rbs +4 -0
- data/sig/anthropic/internal/type/converter.rbs +7 -1
- data/sig/anthropic/models/beta/beta_base64_pdf_block.rbs +1 -58
- data/sig/anthropic/models/beta/beta_citation_search_result_location.rbs +54 -0
- data/sig/anthropic/models/beta/beta_citation_search_result_location_param.rbs +54 -0
- data/sig/anthropic/models/beta/beta_citations_delta.rbs +1 -0
- data/sig/anthropic/models/beta/beta_content_block.rbs +2 -2
- data/sig/anthropic/models/beta/beta_content_block_param.rbs +9 -8
- data/sig/anthropic/models/beta/beta_raw_content_block_start_event.rbs +2 -2
- data/sig/anthropic/models/beta/beta_request_document_block.rbs +66 -0
- data/sig/anthropic/models/beta/beta_search_result_block_param.rbs +53 -0
- data/sig/anthropic/models/beta/beta_text_citation.rbs +1 -0
- data/sig/anthropic/models/beta/beta_text_citation_param.rbs +1 -0
- data/sig/anthropic/models/beta/beta_tool.rbs +14 -3
- data/sig/anthropic/models/beta/beta_tool_result_block_param.rbs +1 -0
- data/sig/anthropic/models/beta/beta_tool_union.rbs +4 -4
- data/sig/anthropic/models/beta/message_count_tokens_params.rbs +4 -4
- data/sig/anthropic/models/content_block.rbs +2 -2
- data/sig/anthropic/models/content_block_param.rbs +5 -5
- data/sig/anthropic/models/message_count_tokens_tool.rbs +28 -0
- data/sig/anthropic/models/raw_content_block_start_event.rbs +2 -2
- data/sig/anthropic/models/tool.rbs +14 -3
- data/sig/anthropic/models/tool_union.rbs +28 -0
- data/sig/anthropic/streaming.rbs +3 -0
- metadata +26 -3
@@ -140,14 +140,23 @@ module Anthropic
|
|
140
140
|
|
141
141
|
# @api private
|
142
142
|
#
|
143
|
+
# Tries to efficiently coerce the given value to one of the known variants.
|
144
|
+
#
|
145
|
+
# If the value cannot match any of the known variants, the coercion is considered
|
146
|
+
# non-viable and returns the original value.
|
147
|
+
#
|
143
148
|
# @param value [Object]
|
144
149
|
#
|
145
150
|
# @param state [Hash{Symbol=>Object}] .
|
146
151
|
#
|
147
|
-
# @option state [Boolean
|
152
|
+
# @option state [Boolean] :translate_names
|
153
|
+
#
|
154
|
+
# @option state [Boolean] :strictness
|
148
155
|
#
|
149
156
|
# @option state [Hash{Symbol=>Object}] :exactness
|
150
157
|
#
|
158
|
+
# @option state [Class<StandardError>] :error
|
159
|
+
#
|
151
160
|
# @option state [Integer] :branched
|
152
161
|
#
|
153
162
|
# @return [Object]
|
@@ -158,7 +167,6 @@ module Anthropic
|
|
158
167
|
|
159
168
|
strictness = state.fetch(:strictness)
|
160
169
|
exactness = state.fetch(:exactness)
|
161
|
-
state[:strictness] = strictness == :strong ? true : strictness
|
162
170
|
|
163
171
|
alternatives = []
|
164
172
|
known_variants.each do |_, variant_fn|
|
@@ -177,13 +185,10 @@ module Anthropic
|
|
177
185
|
end
|
178
186
|
end
|
179
187
|
|
180
|
-
case alternatives.sort_by(&:first)
|
188
|
+
case alternatives.sort_by!(&:first)
|
181
189
|
in []
|
182
190
|
exactness[:no] += 1
|
183
|
-
|
184
|
-
message = "no possible conversion of #{value.class} into a variant of #{target.inspect}"
|
185
|
-
raise ArgumentError.new(message)
|
186
|
-
end
|
191
|
+
state[:error] = ArgumentError.new("no matching variant for #{value.inspect}")
|
187
192
|
value
|
188
193
|
in [[_, exact, coerced], *]
|
189
194
|
exact.each { exactness[_1] += _2 }
|
@@ -220,11 +225,14 @@ module Anthropic
|
|
220
225
|
#
|
221
226
|
# @return [Object]
|
222
227
|
def to_sorbet_type
|
223
|
-
|
228
|
+
types = variants.map { Anthropic::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(_1) }.uniq
|
229
|
+
case types
|
224
230
|
in []
|
225
231
|
T.noreturn
|
232
|
+
in [type]
|
233
|
+
type
|
226
234
|
else
|
227
|
-
T.any(*
|
235
|
+
T.any(*types)
|
228
236
|
end
|
229
237
|
end
|
230
238
|
|
@@ -33,14 +33,20 @@ module Anthropic
|
|
33
33
|
class << self
|
34
34
|
# @api private
|
35
35
|
#
|
36
|
+
# No coercion needed for Unknown type.
|
37
|
+
#
|
36
38
|
# @param value [Object]
|
37
39
|
#
|
38
40
|
# @param state [Hash{Symbol=>Object}] .
|
39
41
|
#
|
40
|
-
# @option state [Boolean
|
42
|
+
# @option state [Boolean] :translate_names
|
43
|
+
#
|
44
|
+
# @option state [Boolean] :strictness
|
41
45
|
#
|
42
46
|
# @option state [Hash{Symbol=>Object}] :exactness
|
43
47
|
#
|
48
|
+
# @option state [Class<StandardError>] :error
|
49
|
+
#
|
44
50
|
# @option state [Integer] :branched
|
45
51
|
#
|
46
52
|
# @return [Object]
|
@@ -497,7 +497,7 @@ module Anthropic
|
|
497
497
|
# @param closing [Array<Proc>]
|
498
498
|
# @param content_type [String, nil]
|
499
499
|
private def write_multipart_content(y, val:, closing:, content_type: nil)
|
500
|
-
|
500
|
+
content_line = "Content-Type: %s\r\n\r\n"
|
501
501
|
|
502
502
|
case val
|
503
503
|
in Anthropic::FilePart
|
@@ -508,24 +508,21 @@ module Anthropic
|
|
508
508
|
content_type: val.content_type
|
509
509
|
)
|
510
510
|
in Pathname
|
511
|
-
y <<
|
511
|
+
y << format(content_line, content_type || "application/octet-stream")
|
512
512
|
io = val.open(binmode: true)
|
513
513
|
closing << io.method(:close)
|
514
514
|
IO.copy_stream(io, y)
|
515
515
|
in IO
|
516
|
-
y <<
|
516
|
+
y << format(content_line, content_type || "application/octet-stream")
|
517
517
|
IO.copy_stream(val, y)
|
518
518
|
in StringIO
|
519
|
-
y <<
|
519
|
+
y << format(content_line, content_type || "application/octet-stream")
|
520
520
|
y << val.string
|
521
|
-
in String
|
522
|
-
y << "Content-Type: #{content_type}\r\n\r\n"
|
523
|
-
y << val.to_s
|
524
521
|
in -> { primitive?(_1) }
|
525
|
-
y << "
|
522
|
+
y << format(content_line, content_type || "text/plain")
|
526
523
|
y << val.to_s
|
527
524
|
else
|
528
|
-
y << "
|
525
|
+
y << format(content_line, content_type || "application/json")
|
529
526
|
y << JSON.generate(val)
|
530
527
|
end
|
531
528
|
y << "\r\n"
|
@@ -563,6 +560,8 @@ module Anthropic
|
|
563
560
|
|
564
561
|
# @api private
|
565
562
|
#
|
563
|
+
# https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#special-considerations-for-multipart-content
|
564
|
+
#
|
566
565
|
# @param body [Object]
|
567
566
|
#
|
568
567
|
# @return [Array(String, Enumerable<String>)]
|
@@ -600,11 +599,13 @@ module Anthropic
|
|
600
599
|
#
|
601
600
|
# @return [Object]
|
602
601
|
def encode_content(headers, body)
|
602
|
+
# rubocop:disable Style/CaseEquality
|
603
|
+
# rubocop:disable Layout/LineLength
|
603
604
|
content_type = headers["content-type"]
|
604
605
|
case [content_type, body]
|
605
606
|
in [Anthropic::Internal::Util::JSON_CONTENT, Hash | Array | -> { primitive?(_1) }]
|
606
607
|
[headers, JSON.generate(body)]
|
607
|
-
in [Anthropic::Internal::Util::JSONL_CONTENT, Enumerable] unless
|
608
|
+
in [Anthropic::Internal::Util::JSONL_CONTENT, Enumerable] unless Anthropic::Internal::Type::FileInput === body
|
608
609
|
[headers, body.lazy.map { JSON.generate(_1) }]
|
609
610
|
in [%r{^multipart/form-data}, Hash | Anthropic::Internal::Type::FileInput]
|
610
611
|
boundary, strio = encode_multipart_streaming(body)
|
@@ -619,6 +620,8 @@ module Anthropic
|
|
619
620
|
else
|
620
621
|
[headers, body]
|
621
622
|
end
|
623
|
+
# rubocop:enable Layout/LineLength
|
624
|
+
# rubocop:enable Style/CaseEquality
|
622
625
|
end
|
623
626
|
|
624
627
|
# @api private
|
@@ -871,8 +874,12 @@ module Anthropic
|
|
871
874
|
case type
|
872
875
|
in Anthropic::Internal::Util::SorbetRuntimeSupport
|
873
876
|
type.to_sorbet_type
|
874
|
-
|
877
|
+
in Class | Module
|
875
878
|
type
|
879
|
+
in true | false
|
880
|
+
T::Boolean
|
881
|
+
else
|
882
|
+
type.class
|
876
883
|
end
|
877
884
|
end
|
878
885
|
end
|
@@ -3,71 +3,7 @@
|
|
3
3
|
module Anthropic
|
4
4
|
module Models
|
5
5
|
module Beta
|
6
|
-
|
7
|
-
# @!attribute source
|
8
|
-
#
|
9
|
-
# @return [Anthropic::Models::Beta::BetaBase64PDFSource, Anthropic::Models::Beta::BetaPlainTextSource, Anthropic::Models::Beta::BetaContentBlockSource, Anthropic::Models::Beta::BetaURLPDFSource, Anthropic::Models::Beta::BetaFileDocumentSource]
|
10
|
-
required :source, union: -> { Anthropic::Beta::BetaBase64PDFBlock::Source }
|
11
|
-
|
12
|
-
# @!attribute type
|
13
|
-
#
|
14
|
-
# @return [Symbol, :document]
|
15
|
-
required :type, const: :document
|
16
|
-
|
17
|
-
# @!attribute cache_control
|
18
|
-
# Create a cache control breakpoint at this content block.
|
19
|
-
#
|
20
|
-
# @return [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil]
|
21
|
-
optional :cache_control, -> { Anthropic::Beta::BetaCacheControlEphemeral }, nil?: true
|
22
|
-
|
23
|
-
# @!attribute citations
|
24
|
-
#
|
25
|
-
# @return [Anthropic::Models::Beta::BetaCitationsConfigParam, nil]
|
26
|
-
optional :citations, -> { Anthropic::Beta::BetaCitationsConfigParam }
|
27
|
-
|
28
|
-
# @!attribute context
|
29
|
-
#
|
30
|
-
# @return [String, nil]
|
31
|
-
optional :context, String, nil?: true
|
32
|
-
|
33
|
-
# @!attribute title
|
34
|
-
#
|
35
|
-
# @return [String, nil]
|
36
|
-
optional :title, String, nil?: true
|
37
|
-
|
38
|
-
# @!method initialize(source:, cache_control: nil, citations: nil, context: nil, title: nil, type: :document)
|
39
|
-
# @param source [Anthropic::Models::Beta::BetaBase64PDFSource, Anthropic::Models::Beta::BetaPlainTextSource, Anthropic::Models::Beta::BetaContentBlockSource, Anthropic::Models::Beta::BetaURLPDFSource, Anthropic::Models::Beta::BetaFileDocumentSource]
|
40
|
-
#
|
41
|
-
# @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
|
42
|
-
#
|
43
|
-
# @param citations [Anthropic::Models::Beta::BetaCitationsConfigParam]
|
44
|
-
#
|
45
|
-
# @param context [String, nil]
|
46
|
-
#
|
47
|
-
# @param title [String, nil]
|
48
|
-
#
|
49
|
-
# @param type [Symbol, :document]
|
50
|
-
|
51
|
-
# @see Anthropic::Models::Beta::BetaBase64PDFBlock#source
|
52
|
-
module Source
|
53
|
-
extend Anthropic::Internal::Type::Union
|
54
|
-
|
55
|
-
discriminator :type
|
56
|
-
|
57
|
-
variant :base64, -> { Anthropic::Beta::BetaBase64PDFSource }
|
58
|
-
|
59
|
-
variant :text, -> { Anthropic::Beta::BetaPlainTextSource }
|
60
|
-
|
61
|
-
variant :content, -> { Anthropic::Beta::BetaContentBlockSource }
|
62
|
-
|
63
|
-
variant :url, -> { Anthropic::Beta::BetaURLPDFSource }
|
64
|
-
|
65
|
-
variant :file, -> { Anthropic::Beta::BetaFileDocumentSource }
|
66
|
-
|
67
|
-
# @!method self.variants
|
68
|
-
# @return [Array(Anthropic::Models::Beta::BetaBase64PDFSource, Anthropic::Models::Beta::BetaPlainTextSource, Anthropic::Models::Beta::BetaContentBlockSource, Anthropic::Models::Beta::BetaURLPDFSource, Anthropic::Models::Beta::BetaFileDocumentSource)]
|
69
|
-
end
|
70
|
-
end
|
6
|
+
BetaBase64PDFBlock = Anthropic::Models::Beta::BetaRequestDocumentBlock
|
71
7
|
end
|
72
8
|
|
73
9
|
BetaBase64PDFBlock = Beta::BetaBase64PDFBlock
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Anthropic
|
4
|
+
module Models
|
5
|
+
module Beta
|
6
|
+
class BetaCitationSearchResultLocation < Anthropic::Internal::Type::BaseModel
|
7
|
+
# @!attribute cited_text
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
required :cited_text, String
|
11
|
+
|
12
|
+
# @!attribute end_block_index
|
13
|
+
#
|
14
|
+
# @return [Integer]
|
15
|
+
required :end_block_index, Integer
|
16
|
+
|
17
|
+
# @!attribute search_result_index
|
18
|
+
#
|
19
|
+
# @return [Integer]
|
20
|
+
required :search_result_index, Integer
|
21
|
+
|
22
|
+
# @!attribute source
|
23
|
+
#
|
24
|
+
# @return [String]
|
25
|
+
required :source, String
|
26
|
+
|
27
|
+
# @!attribute start_block_index
|
28
|
+
#
|
29
|
+
# @return [Integer]
|
30
|
+
required :start_block_index, Integer
|
31
|
+
|
32
|
+
# @!attribute title
|
33
|
+
#
|
34
|
+
# @return [String, nil]
|
35
|
+
required :title, String, nil?: true
|
36
|
+
|
37
|
+
# @!attribute type
|
38
|
+
#
|
39
|
+
# @return [Symbol, :search_result_location]
|
40
|
+
required :type, const: :search_result_location
|
41
|
+
|
42
|
+
# @!method initialize(cited_text:, end_block_index:, search_result_index:, source:, start_block_index:, title:, type: :search_result_location)
|
43
|
+
# @param cited_text [String]
|
44
|
+
# @param end_block_index [Integer]
|
45
|
+
# @param search_result_index [Integer]
|
46
|
+
# @param source [String]
|
47
|
+
# @param start_block_index [Integer]
|
48
|
+
# @param title [String, nil]
|
49
|
+
# @param type [Symbol, :search_result_location]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
BetaCitationSearchResultLocation = Beta::BetaCitationSearchResultLocation
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Anthropic
|
4
|
+
module Models
|
5
|
+
module Beta
|
6
|
+
class BetaCitationSearchResultLocationParam < Anthropic::Internal::Type::BaseModel
|
7
|
+
# @!attribute cited_text
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
required :cited_text, String
|
11
|
+
|
12
|
+
# @!attribute end_block_index
|
13
|
+
#
|
14
|
+
# @return [Integer]
|
15
|
+
required :end_block_index, Integer
|
16
|
+
|
17
|
+
# @!attribute search_result_index
|
18
|
+
#
|
19
|
+
# @return [Integer]
|
20
|
+
required :search_result_index, Integer
|
21
|
+
|
22
|
+
# @!attribute source
|
23
|
+
#
|
24
|
+
# @return [String]
|
25
|
+
required :source, String
|
26
|
+
|
27
|
+
# @!attribute start_block_index
|
28
|
+
#
|
29
|
+
# @return [Integer]
|
30
|
+
required :start_block_index, Integer
|
31
|
+
|
32
|
+
# @!attribute title
|
33
|
+
#
|
34
|
+
# @return [String, nil]
|
35
|
+
required :title, String, nil?: true
|
36
|
+
|
37
|
+
# @!attribute type
|
38
|
+
#
|
39
|
+
# @return [Symbol, :search_result_location]
|
40
|
+
required :type, const: :search_result_location
|
41
|
+
|
42
|
+
# @!method initialize(cited_text:, end_block_index:, search_result_index:, source:, start_block_index:, title:, type: :search_result_location)
|
43
|
+
# @param cited_text [String]
|
44
|
+
# @param end_block_index [Integer]
|
45
|
+
# @param search_result_index [Integer]
|
46
|
+
# @param source [String]
|
47
|
+
# @param start_block_index [Integer]
|
48
|
+
# @param title [String, nil]
|
49
|
+
# @param type [Symbol, :search_result_location]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
BetaCitationSearchResultLocationParam = Beta::BetaCitationSearchResultLocationParam
|
54
|
+
end
|
55
|
+
end
|
@@ -6,7 +6,7 @@ module Anthropic
|
|
6
6
|
class BetaCitationsDelta < Anthropic::Internal::Type::BaseModel
|
7
7
|
# @!attribute citation
|
8
8
|
#
|
9
|
-
# @return [Anthropic::Models::Beta::BetaCitationCharLocation, Anthropic::Models::Beta::BetaCitationPageLocation, Anthropic::Models::Beta::BetaCitationContentBlockLocation, Anthropic::Models::Beta::BetaCitationsWebSearchResultLocation]
|
9
|
+
# @return [Anthropic::Models::Beta::BetaCitationCharLocation, Anthropic::Models::Beta::BetaCitationPageLocation, Anthropic::Models::Beta::BetaCitationContentBlockLocation, Anthropic::Models::Beta::BetaCitationsWebSearchResultLocation, Anthropic::Models::Beta::BetaCitationSearchResultLocation]
|
10
10
|
required :citation, union: -> { Anthropic::Beta::BetaCitationsDelta::Citation }
|
11
11
|
|
12
12
|
# @!attribute type
|
@@ -15,7 +15,7 @@ module Anthropic
|
|
15
15
|
required :type, const: :citations_delta
|
16
16
|
|
17
17
|
# @!method initialize(citation:, type: :citations_delta)
|
18
|
-
# @param citation [Anthropic::Models::Beta::BetaCitationCharLocation, Anthropic::Models::Beta::BetaCitationPageLocation, Anthropic::Models::Beta::BetaCitationContentBlockLocation, Anthropic::Models::Beta::BetaCitationsWebSearchResultLocation]
|
18
|
+
# @param citation [Anthropic::Models::Beta::BetaCitationCharLocation, Anthropic::Models::Beta::BetaCitationPageLocation, Anthropic::Models::Beta::BetaCitationContentBlockLocation, Anthropic::Models::Beta::BetaCitationsWebSearchResultLocation, Anthropic::Models::Beta::BetaCitationSearchResultLocation]
|
19
19
|
# @param type [Symbol, :citations_delta]
|
20
20
|
|
21
21
|
# @see Anthropic::Models::Beta::BetaCitationsDelta#citation
|
@@ -32,8 +32,10 @@ module Anthropic
|
|
32
32
|
|
33
33
|
variant :web_search_result_location, -> { Anthropic::Beta::BetaCitationsWebSearchResultLocation }
|
34
34
|
|
35
|
+
variant :search_result_location, -> { Anthropic::Beta::BetaCitationSearchResultLocation }
|
36
|
+
|
35
37
|
# @!method self.variants
|
36
|
-
# @return [Array(Anthropic::Models::Beta::BetaCitationCharLocation, Anthropic::Models::Beta::BetaCitationPageLocation, Anthropic::Models::Beta::BetaCitationContentBlockLocation, Anthropic::Models::Beta::BetaCitationsWebSearchResultLocation)]
|
38
|
+
# @return [Array(Anthropic::Models::Beta::BetaCitationCharLocation, Anthropic::Models::Beta::BetaCitationPageLocation, Anthropic::Models::Beta::BetaCitationContentBlockLocation, Anthropic::Models::Beta::BetaCitationsWebSearchResultLocation, Anthropic::Models::Beta::BetaCitationSearchResultLocation)]
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -11,6 +11,10 @@ module Anthropic
|
|
11
11
|
|
12
12
|
variant :text, -> { Anthropic::Beta::BetaTextBlock }
|
13
13
|
|
14
|
+
variant :thinking, -> { Anthropic::Beta::BetaThinkingBlock }
|
15
|
+
|
16
|
+
variant :redacted_thinking, -> { Anthropic::Beta::BetaRedactedThinkingBlock }
|
17
|
+
|
14
18
|
variant :tool_use, -> { Anthropic::Beta::BetaToolUseBlock }
|
15
19
|
|
16
20
|
variant :server_tool_use, -> { Anthropic::Beta::BetaServerToolUseBlock }
|
@@ -26,12 +30,8 @@ module Anthropic
|
|
26
30
|
# Response model for a file uploaded to the container.
|
27
31
|
variant :container_upload, -> { Anthropic::Beta::BetaContainerUploadBlock }
|
28
32
|
|
29
|
-
variant :thinking, -> { Anthropic::Beta::BetaThinkingBlock }
|
30
|
-
|
31
|
-
variant :redacted_thinking, -> { Anthropic::Beta::BetaRedactedThinkingBlock }
|
32
|
-
|
33
33
|
# @!method self.variants
|
34
|
-
# @return [Array(Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::
|
34
|
+
# @return [Array(Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock)]
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -9,43 +9,46 @@ module Anthropic
|
|
9
9
|
|
10
10
|
discriminator :type
|
11
11
|
|
12
|
-
variant :server_tool_use, -> { Anthropic::Beta::BetaServerToolUseBlockParam }
|
13
|
-
|
14
|
-
variant :web_search_tool_result, -> { Anthropic::Beta::BetaWebSearchToolResultBlockParam }
|
15
|
-
|
16
|
-
variant :code_execution_tool_result, -> { Anthropic::Beta::BetaCodeExecutionToolResultBlockParam }
|
17
|
-
|
18
|
-
variant :mcp_tool_use, -> { Anthropic::Beta::BetaMCPToolUseBlockParam }
|
19
|
-
|
20
|
-
variant :mcp_tool_result, -> { Anthropic::Beta::BetaRequestMCPToolResultBlockParam }
|
21
|
-
|
22
12
|
# Regular text content.
|
23
13
|
variant :text, -> { Anthropic::Beta::BetaTextBlockParam }
|
24
14
|
|
25
15
|
# Image content specified directly as base64 data or as a reference via a URL.
|
26
16
|
variant :image, -> { Anthropic::Beta::BetaImageBlockParam }
|
27
17
|
|
18
|
+
# Document content, either specified directly as base64 data, as text, or as a reference via a URL.
|
19
|
+
variant :document, -> { Anthropic::Beta::BetaRequestDocumentBlock }
|
20
|
+
|
21
|
+
# A search result block containing source, title, and content from search operations.
|
22
|
+
variant :search_result, -> { Anthropic::Beta::BetaSearchResultBlockParam }
|
23
|
+
|
24
|
+
# A block specifying internal thinking by the model.
|
25
|
+
variant :thinking, -> { Anthropic::Beta::BetaThinkingBlockParam }
|
26
|
+
|
27
|
+
# A block specifying internal, redacted thinking by the model.
|
28
|
+
variant :redacted_thinking, -> { Anthropic::Beta::BetaRedactedThinkingBlockParam }
|
29
|
+
|
28
30
|
# A block indicating a tool use by the model.
|
29
31
|
variant :tool_use, -> { Anthropic::Beta::BetaToolUseBlockParam }
|
30
32
|
|
31
33
|
# A block specifying the results of a tool use by the model.
|
32
34
|
variant :tool_result, -> { Anthropic::Beta::BetaToolResultBlockParam }
|
33
35
|
|
34
|
-
|
35
|
-
variant :document, -> { Anthropic::Beta::BetaBase64PDFBlock }
|
36
|
+
variant :server_tool_use, -> { Anthropic::Beta::BetaServerToolUseBlockParam }
|
36
37
|
|
37
|
-
|
38
|
-
variant :thinking, -> { Anthropic::Beta::BetaThinkingBlockParam }
|
38
|
+
variant :web_search_tool_result, -> { Anthropic::Beta::BetaWebSearchToolResultBlockParam }
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
variant :code_execution_tool_result, -> { Anthropic::Beta::BetaCodeExecutionToolResultBlockParam }
|
41
|
+
|
42
|
+
variant :mcp_tool_use, -> { Anthropic::Beta::BetaMCPToolUseBlockParam }
|
43
|
+
|
44
|
+
variant :mcp_tool_result, -> { Anthropic::Beta::BetaRequestMCPToolResultBlockParam }
|
42
45
|
|
43
46
|
# A content block that represents a file to be uploaded to the container
|
44
47
|
# Files uploaded via this block will be available in the container's input directory.
|
45
48
|
variant :container_upload, -> { Anthropic::Beta::BetaContainerUploadBlockParam }
|
46
49
|
|
47
50
|
# @!method self.variants
|
48
|
-
# @return [Array(Anthropic::Models::Beta::
|
51
|
+
# @return [Array(Anthropic::Models::Beta::BetaTextBlockParam, Anthropic::Models::Beta::BetaImageBlockParam, Anthropic::Models::Beta::BetaRequestDocumentBlock, Anthropic::Models::Beta::BetaSearchResultBlockParam, Anthropic::Models::Beta::BetaThinkingBlockParam, Anthropic::Models::Beta::BetaRedactedThinkingBlockParam, Anthropic::Models::Beta::BetaToolUseBlockParam, Anthropic::Models::Beta::BetaToolResultBlockParam, Anthropic::Models::Beta::BetaServerToolUseBlockParam, Anthropic::Models::Beta::BetaWebSearchToolResultBlockParam, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlockParam, Anthropic::Models::Beta::BetaMCPToolUseBlockParam, Anthropic::Models::Beta::BetaRequestMCPToolResultBlockParam, Anthropic::Models::Beta::BetaContainerUploadBlockParam)]
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
@@ -56,7 +56,7 @@ module Anthropic
|
|
56
56
|
# [{ "type": "text", "text": "B)" }]
|
57
57
|
# ```
|
58
58
|
#
|
59
|
-
# @return [Array<Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::
|
59
|
+
# @return [Array<Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock>]
|
60
60
|
required :content, -> { Anthropic::Internal::Type::ArrayOf[union: Anthropic::Beta::BetaContentBlock] }
|
61
61
|
|
62
62
|
# @!attribute model
|
@@ -84,6 +84,10 @@ module Anthropic
|
|
84
84
|
# - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum
|
85
85
|
# - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
|
86
86
|
# - `"tool_use"`: the model invoked one or more tools
|
87
|
+
# - `"pause_turn"`: we paused a long-running turn. You may provide the response
|
88
|
+
# back as-is in a subsequent request to let the model continue.
|
89
|
+
# - `"refusal"`: when streaming classifiers intervene to handle potential policy
|
90
|
+
# violations
|
87
91
|
#
|
88
92
|
# In non-streaming mode this value is always non-null. In streaming mode, it is
|
89
93
|
# null in the `message_start` event and non-null otherwise.
|
@@ -136,7 +140,7 @@ module Anthropic
|
|
136
140
|
#
|
137
141
|
# @param container [Anthropic::Models::Beta::BetaContainer, nil] Information about the container used in the request (for the code execution tool
|
138
142
|
#
|
139
|
-
# @param content [Array<Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::
|
143
|
+
# @param content [Array<Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock>] Content generated by the model.
|
140
144
|
#
|
141
145
|
# @param model [Symbol, String, Anthropic::Models::Model] The model that will complete your prompt.\n\nSee [models](https://docs.anthropic
|
142
146
|
#
|
@@ -6,7 +6,7 @@ module Anthropic
|
|
6
6
|
class BetaMessageParam < Anthropic::Internal::Type::BaseModel
|
7
7
|
# @!attribute content
|
8
8
|
#
|
9
|
-
# @return [String, Array<Anthropic::Models::Beta::
|
9
|
+
# @return [String, Array<Anthropic::Models::Beta::BetaTextBlockParam, Anthropic::Models::Beta::BetaImageBlockParam, Anthropic::Models::Beta::BetaRequestDocumentBlock, Anthropic::Models::Beta::BetaSearchResultBlockParam, Anthropic::Models::Beta::BetaThinkingBlockParam, Anthropic::Models::Beta::BetaRedactedThinkingBlockParam, Anthropic::Models::Beta::BetaToolUseBlockParam, Anthropic::Models::Beta::BetaToolResultBlockParam, Anthropic::Models::Beta::BetaServerToolUseBlockParam, Anthropic::Models::Beta::BetaWebSearchToolResultBlockParam, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlockParam, Anthropic::Models::Beta::BetaMCPToolUseBlockParam, Anthropic::Models::Beta::BetaRequestMCPToolResultBlockParam, Anthropic::Models::Beta::BetaContainerUploadBlockParam>]
|
10
10
|
required :content, union: -> { Anthropic::Beta::BetaMessageParam::Content }
|
11
11
|
|
12
12
|
# @!attribute role
|
@@ -15,7 +15,7 @@ module Anthropic
|
|
15
15
|
required :role, enum: -> { Anthropic::Beta::BetaMessageParam::Role }
|
16
16
|
|
17
17
|
# @!method initialize(content:, role:)
|
18
|
-
# @param content [String, Array<Anthropic::Models::Beta::
|
18
|
+
# @param content [String, Array<Anthropic::Models::Beta::BetaTextBlockParam, Anthropic::Models::Beta::BetaImageBlockParam, Anthropic::Models::Beta::BetaRequestDocumentBlock, Anthropic::Models::Beta::BetaSearchResultBlockParam, Anthropic::Models::Beta::BetaThinkingBlockParam, Anthropic::Models::Beta::BetaRedactedThinkingBlockParam, Anthropic::Models::Beta::BetaToolUseBlockParam, Anthropic::Models::Beta::BetaToolResultBlockParam, Anthropic::Models::Beta::BetaServerToolUseBlockParam, Anthropic::Models::Beta::BetaWebSearchToolResultBlockParam, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlockParam, Anthropic::Models::Beta::BetaMCPToolUseBlockParam, Anthropic::Models::Beta::BetaRequestMCPToolResultBlockParam, Anthropic::Models::Beta::BetaContainerUploadBlockParam>]
|
19
19
|
# @param role [Symbol, Anthropic::Models::Beta::BetaMessageParam::Role]
|
20
20
|
|
21
21
|
# @see Anthropic::Models::Beta::BetaMessageParam#content
|
@@ -27,7 +27,7 @@ module Anthropic
|
|
27
27
|
variant -> { Anthropic::Models::Beta::BetaMessageParam::Content::BetaContentBlockParamArray }
|
28
28
|
|
29
29
|
# @!method self.variants
|
30
|
-
# @return [Array(String, Array<Anthropic::Models::Beta::
|
30
|
+
# @return [Array(String, Array<Anthropic::Models::Beta::BetaTextBlockParam, Anthropic::Models::Beta::BetaImageBlockParam, Anthropic::Models::Beta::BetaRequestDocumentBlock, Anthropic::Models::Beta::BetaSearchResultBlockParam, Anthropic::Models::Beta::BetaThinkingBlockParam, Anthropic::Models::Beta::BetaRedactedThinkingBlockParam, Anthropic::Models::Beta::BetaToolUseBlockParam, Anthropic::Models::Beta::BetaToolResultBlockParam, Anthropic::Models::Beta::BetaServerToolUseBlockParam, Anthropic::Models::Beta::BetaWebSearchToolResultBlockParam, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlockParam, Anthropic::Models::Beta::BetaMCPToolUseBlockParam, Anthropic::Models::Beta::BetaRequestMCPToolResultBlockParam, Anthropic::Models::Beta::BetaContainerUploadBlockParam>)]
|
31
31
|
|
32
32
|
# @type [Anthropic::Internal::Type::Converter]
|
33
33
|
BetaContentBlockParamArray =
|
@@ -7,7 +7,7 @@ module Anthropic
|
|
7
7
|
# @!attribute content_block
|
8
8
|
# Response model for a file uploaded to the container.
|
9
9
|
#
|
10
|
-
# @return [Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::
|
10
|
+
# @return [Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock]
|
11
11
|
required :content_block, union: -> { Anthropic::Beta::BetaRawContentBlockStartEvent::ContentBlock }
|
12
12
|
|
13
13
|
# @!attribute index
|
@@ -21,7 +21,7 @@ module Anthropic
|
|
21
21
|
required :type, const: :content_block_start
|
22
22
|
|
23
23
|
# @!method initialize(content_block:, index:, type: :content_block_start)
|
24
|
-
# @param content_block [Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::
|
24
|
+
# @param content_block [Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock] Response model for a file uploaded to the container.
|
25
25
|
#
|
26
26
|
# @param index [Integer]
|
27
27
|
#
|
@@ -37,6 +37,10 @@ module Anthropic
|
|
37
37
|
|
38
38
|
variant :text, -> { Anthropic::Beta::BetaTextBlock }
|
39
39
|
|
40
|
+
variant :thinking, -> { Anthropic::Beta::BetaThinkingBlock }
|
41
|
+
|
42
|
+
variant :redacted_thinking, -> { Anthropic::Beta::BetaRedactedThinkingBlock }
|
43
|
+
|
40
44
|
variant :tool_use, -> { Anthropic::Beta::BetaToolUseBlock }
|
41
45
|
|
42
46
|
variant :server_tool_use, -> { Anthropic::Beta::BetaServerToolUseBlock }
|
@@ -52,12 +56,8 @@ module Anthropic
|
|
52
56
|
# Response model for a file uploaded to the container.
|
53
57
|
variant :container_upload, -> { Anthropic::Beta::BetaContainerUploadBlock }
|
54
58
|
|
55
|
-
variant :thinking, -> { Anthropic::Beta::BetaThinkingBlock }
|
56
|
-
|
57
|
-
variant :redacted_thinking, -> { Anthropic::Beta::BetaRedactedThinkingBlock }
|
58
|
-
|
59
59
|
# @!method self.variants
|
60
|
-
# @return [Array(Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::
|
60
|
+
# @return [Array(Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock)]
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|