anthropic 1.1.1 → 1.3.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.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +69 -0
  3. data/README.md +32 -16
  4. data/lib/anthropic/errors.rb +22 -0
  5. data/lib/anthropic/helpers/streaming/events.rb +141 -0
  6. data/lib/anthropic/helpers/streaming/message_stream.rb +238 -0
  7. data/lib/anthropic/helpers/streaming.rb +37 -0
  8. data/lib/anthropic/helpers/vertex/client.rb +4 -1
  9. data/lib/anthropic/internal/stream.rb +4 -2
  10. data/lib/anthropic/internal/transport/base_client.rb +10 -2
  11. data/lib/anthropic/internal/type/array_of.rb +6 -1
  12. data/lib/anthropic/internal/type/base_model.rb +77 -23
  13. data/lib/anthropic/internal/type/base_stream.rb +3 -1
  14. data/lib/anthropic/internal/type/boolean.rb +7 -1
  15. data/lib/anthropic/internal/type/converter.rb +42 -34
  16. data/lib/anthropic/internal/type/enum.rb +16 -5
  17. data/lib/anthropic/internal/type/file_input.rb +6 -1
  18. data/lib/anthropic/internal/type/hash_of.rb +6 -1
  19. data/lib/anthropic/internal/type/union.rb +17 -9
  20. data/lib/anthropic/internal/type/unknown.rb +7 -1
  21. data/lib/anthropic/internal/util.rb +8 -9
  22. data/lib/anthropic/models/beta/beta_base64_pdf_block.rb +1 -65
  23. data/lib/anthropic/models/beta/beta_citation_search_result_location.rb +55 -0
  24. data/lib/anthropic/models/beta/beta_citation_search_result_location_param.rb +55 -0
  25. data/lib/anthropic/models/beta/beta_citations_delta.rb +5 -3
  26. data/lib/anthropic/models/beta/beta_content_block.rb +5 -5
  27. data/lib/anthropic/models/beta/beta_content_block_param.rb +20 -17
  28. data/lib/anthropic/models/beta/beta_message.rb +6 -2
  29. data/lib/anthropic/models/beta/beta_message_param.rb +3 -3
  30. data/lib/anthropic/models/beta/beta_raw_content_block_start_event.rb +7 -7
  31. data/lib/anthropic/models/beta/beta_request_document_block.rb +75 -0
  32. data/lib/anthropic/models/beta/beta_search_result_block_param.rb +55 -0
  33. data/lib/anthropic/models/beta/beta_text_block.rb +2 -2
  34. data/lib/anthropic/models/beta/beta_text_block_param.rb +2 -2
  35. data/lib/anthropic/models/beta/beta_text_citation.rb +3 -1
  36. data/lib/anthropic/models/beta/beta_text_citation_param.rb +3 -1
  37. data/lib/anthropic/models/beta/beta_tool.rb +7 -1
  38. data/lib/anthropic/models/beta/beta_tool_result_block_param.rb +6 -4
  39. data/lib/anthropic/models/beta/beta_tool_union.rb +7 -7
  40. data/lib/anthropic/models/beta/message_count_tokens_params.rb +16 -10
  41. data/lib/anthropic/models/beta/message_create_params.rb +9 -3
  42. data/lib/anthropic/models/beta/messages/batch_create_params.rb +9 -3
  43. data/lib/anthropic/models/content_block.rb +5 -5
  44. data/lib/anthropic/models/content_block_param.rb +11 -11
  45. data/lib/anthropic/models/message.rb +6 -2
  46. data/lib/anthropic/models/message_count_tokens_params.rb +9 -3
  47. data/lib/anthropic/models/message_count_tokens_tool.rb +35 -1
  48. data/lib/anthropic/models/message_create_params.rb +9 -3
  49. data/lib/anthropic/models/message_param.rb +3 -3
  50. data/lib/anthropic/models/messages/batch_create_params.rb +9 -3
  51. data/lib/anthropic/models/model.rb +5 -21
  52. data/lib/anthropic/models/raw_content_block_start_event.rb +7 -7
  53. data/lib/anthropic/models/tool.rb +7 -1
  54. data/lib/anthropic/models/tool_union.rb +34 -1
  55. data/lib/anthropic/models/tool_use_block.rb +6 -0
  56. data/lib/anthropic/models.rb +4 -4
  57. data/lib/anthropic/resources/beta/messages.rb +73 -6
  58. data/lib/anthropic/resources/messages.rb +68 -7
  59. data/lib/anthropic/streaming.rb +5 -0
  60. data/lib/anthropic/version.rb +1 -1
  61. data/lib/anthropic.rb +8 -0
  62. data/rbi/anthropic/errors.rbi +16 -0
  63. data/rbi/anthropic/helpers/bedrock/client.rbi +17 -6
  64. data/rbi/anthropic/helpers/streaming/events.rbi +95 -0
  65. data/rbi/anthropic/helpers/streaming/message_stream.rbi +73 -0
  66. data/rbi/anthropic/helpers/vertex/client.rbi +17 -6
  67. data/rbi/anthropic/internal/type/base_stream.rbi +8 -1
  68. data/rbi/anthropic/internal/type/boolean.rbi +2 -0
  69. data/rbi/anthropic/internal/type/converter.rbi +15 -15
  70. data/rbi/anthropic/internal/type/union.rbi +5 -0
  71. data/rbi/anthropic/internal/type/unknown.rbi +2 -0
  72. data/rbi/anthropic/internal/util.rbi +2 -0
  73. data/rbi/anthropic/models/beta/beta_base64_pdf_block.rbi +1 -128
  74. data/rbi/anthropic/models/beta/beta_citation_search_result_location.rbi +78 -0
  75. data/rbi/anthropic/models/beta/beta_citation_search_result_location_param.rbi +79 -0
  76. data/rbi/anthropic/models/beta/beta_citations_delta.rbi +4 -2
  77. data/rbi/anthropic/models/beta/beta_content_block.rbi +3 -3
  78. data/rbi/anthropic/models/beta/beta_content_block_param.rbi +8 -7
  79. data/rbi/anthropic/models/beta/beta_message.rbi +11 -3
  80. data/rbi/anthropic/models/beta/beta_raw_content_block_start_event.rbi +6 -6
  81. data/rbi/anthropic/models/beta/beta_request_document_block.rbi +140 -0
  82. data/rbi/anthropic/models/beta/beta_search_result_block_param.rbi +91 -0
  83. data/rbi/anthropic/models/beta/beta_text_block.rbi +2 -1
  84. data/rbi/anthropic/models/beta/beta_text_block_param.rbi +6 -3
  85. data/rbi/anthropic/models/beta/beta_text_citation.rbi +2 -1
  86. data/rbi/anthropic/models/beta/beta_text_citation_param.rbi +2 -1
  87. data/rbi/anthropic/models/beta/beta_tool.rbi +14 -5
  88. data/rbi/anthropic/models/beta/beta_tool_result_block_param.rbi +2 -1
  89. data/rbi/anthropic/models/beta/beta_tool_union.rbi +5 -5
  90. data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +39 -27
  91. data/rbi/anthropic/models/beta/message_create_params.rbi +34 -22
  92. data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +34 -22
  93. data/rbi/anthropic/models/content_block.rbi +3 -3
  94. data/rbi/anthropic/models/content_block_param.rbi +5 -5
  95. data/rbi/anthropic/models/message.rbi +11 -3
  96. data/rbi/anthropic/models/message_count_tokens_params.rbi +18 -2
  97. data/rbi/anthropic/models/message_count_tokens_tool.rbi +61 -0
  98. data/rbi/anthropic/models/message_create_params.rbi +18 -2
  99. data/rbi/anthropic/models/messages/batch_create_params.rbi +18 -2
  100. data/rbi/anthropic/models/model.rbi +0 -8
  101. data/rbi/anthropic/models/raw_content_block_start_event.rbi +6 -6
  102. data/rbi/anthropic/models/tool.rbi +16 -5
  103. data/rbi/anthropic/models/tool_union.rbi +61 -0
  104. data/rbi/anthropic/resources/beta/messages.rbi +36 -18
  105. data/rbi/anthropic/resources/messages.rbi +315 -3
  106. data/rbi/anthropic/streaming.rbi +5 -0
  107. data/sig/anthropic/errors.rbs +9 -0
  108. data/sig/anthropic/helpers/streaming/events.rbs +117 -0
  109. data/sig/anthropic/helpers/streaming/message_stream.rbs +57 -0
  110. data/sig/anthropic/internal/type/base_stream.rbs +4 -0
  111. data/sig/anthropic/internal/type/converter.rbs +7 -1
  112. data/sig/anthropic/models/beta/beta_base64_pdf_block.rbs +1 -58
  113. data/sig/anthropic/models/beta/beta_citation_search_result_location.rbs +54 -0
  114. data/sig/anthropic/models/beta/beta_citation_search_result_location_param.rbs +54 -0
  115. data/sig/anthropic/models/beta/beta_citations_delta.rbs +1 -0
  116. data/sig/anthropic/models/beta/beta_content_block.rbs +2 -2
  117. data/sig/anthropic/models/beta/beta_content_block_param.rbs +9 -8
  118. data/sig/anthropic/models/beta/beta_raw_content_block_start_event.rbs +2 -2
  119. data/sig/anthropic/models/beta/beta_request_document_block.rbs +66 -0
  120. data/sig/anthropic/models/beta/beta_search_result_block_param.rbs +53 -0
  121. data/sig/anthropic/models/beta/beta_text_citation.rbs +1 -0
  122. data/sig/anthropic/models/beta/beta_text_citation_param.rbs +1 -0
  123. data/sig/anthropic/models/beta/beta_tool.rbs +14 -3
  124. data/sig/anthropic/models/beta/beta_tool_result_block_param.rbs +1 -0
  125. data/sig/anthropic/models/beta/beta_tool_union.rbs +4 -4
  126. data/sig/anthropic/models/beta/message_count_tokens_params.rbs +4 -4
  127. data/sig/anthropic/models/content_block.rbs +2 -2
  128. data/sig/anthropic/models/content_block_param.rbs +5 -5
  129. data/sig/anthropic/models/message_count_tokens_tool.rbs +28 -0
  130. data/sig/anthropic/models/model.rbs +0 -10
  131. data/sig/anthropic/models/raw_content_block_start_event.rbs +2 -2
  132. data/sig/anthropic/models/tool.rbs +14 -3
  133. data/sig/anthropic/models/tool_union.rbs +28 -0
  134. data/sig/anthropic/streaming.rbs +3 -0
  135. metadata +26 -3
@@ -0,0 +1,57 @@
1
+ module Anthropic
2
+ module Helpers
3
+ module Streaming
4
+ type raw_message_event =
5
+ Anthropic::Models::raw_message_start_event
6
+ | Anthropic::Models::raw_message_delta_event
7
+ | Anthropic::Models::raw_message_stop_event
8
+ | Anthropic::Models::raw_content_block_start_event
9
+ | Anthropic::Models::raw_content_block_delta_event
10
+ | Anthropic::Models::raw_content_block_stop_event
11
+
12
+ type stream_event =
13
+ raw_message_event
14
+ | text_event
15
+ | citation_event
16
+ | thinking_event
17
+ | signature_event
18
+ | input_json_event
19
+ | message_stop_event
20
+ | content_block_stop_event
21
+
22
+ class MessageStream
23
+ include Anthropic::Internal::Type::BaseStream[raw_message_event, stream_event]
24
+
25
+ @raw_stream: Anthropic::Internal::Stream[raw_message_event]
26
+ @accumated_message_snapshot: Anthropic::Models::message?
27
+ @iterator: Enumerable[stream_event]?
28
+
29
+ def initialize: (
30
+ raw_stream: Anthropic::Internal::Stream[raw_message_event]
31
+ ) -> void
32
+
33
+ def until_done: -> void
34
+
35
+ def text: -> Enumerator[String]
36
+
37
+ def accumulated_message: -> Anthropic::Models::message
38
+
39
+ def accumulated_text: -> String
40
+
41
+ private
42
+
43
+ def iterator: -> Enumerable[stream_event]
44
+
45
+ def accumulate_event: (
46
+ event: raw_message_event,
47
+ current_snapshot: Anthropic::Models::message?
48
+ ) -> Anthropic::Models::message
49
+
50
+ def build_events: (
51
+ event: raw_message_event,
52
+ message_snapshot: Anthropic::Models::message
53
+ ) -> ::Array[stream_event]
54
+ end
55
+ end
56
+ end
57
+ end
@@ -23,6 +23,10 @@ module Anthropic
23
23
  url: URI::Generic,
24
24
  status: Integer,
25
25
  response: top,
26
+ unwrap: Symbol
27
+ | Integer
28
+ | ::Array[Symbol | Integer]
29
+ | ^(top arg0) -> top,
26
30
  stream: Enumerable[Message]
27
31
  ) -> void
28
32
 
@@ -8,8 +8,10 @@ module Anthropic
8
8
 
9
9
  type coerce_state =
10
10
  {
11
- strictness: bool | :strong,
11
+ translate_names: bool,
12
+ strictness: bool,
12
13
  exactness: { yes: Integer, no: Integer, maybe: Integer },
14
+ error: Class,
13
15
  branched: Integer
14
16
  }
15
17
 
@@ -37,6 +39,10 @@ module Anthropic
37
39
  | Anthropic::Internal::Type::Converter::input spec
38
40
  ) -> (^-> top)
39
41
 
42
+ def self.new_coerce_state: (
43
+ ?translate_names: bool
44
+ ) -> Anthropic::Internal::Type::Converter::coerce_state
45
+
40
46
  def self.coerce: (
41
47
  Anthropic::Internal::Type::Converter::input target,
42
48
  top value,
@@ -3,64 +3,7 @@ module Anthropic
3
3
  class BetaBase64PDFBlock = Beta::BetaBase64PDFBlock
4
4
 
5
5
  module Beta
6
- type beta_base64_pdf_block =
7
- {
8
- source: Anthropic::Models::Beta::BetaBase64PDFBlock::source,
9
- type: :document,
10
- cache_control: Anthropic::Beta::BetaCacheControlEphemeral?,
11
- citations: Anthropic::Beta::BetaCitationsConfigParam,
12
- context: String?,
13
- title: String?
14
- }
15
-
16
- class BetaBase64PDFBlock < Anthropic::Internal::Type::BaseModel
17
- attr_accessor source: Anthropic::Models::Beta::BetaBase64PDFBlock::source
18
-
19
- attr_accessor type: :document
20
-
21
- attr_accessor cache_control: Anthropic::Beta::BetaCacheControlEphemeral?
22
-
23
- attr_reader citations: Anthropic::Beta::BetaCitationsConfigParam?
24
-
25
- def citations=: (
26
- Anthropic::Beta::BetaCitationsConfigParam
27
- ) -> Anthropic::Beta::BetaCitationsConfigParam
28
-
29
- attr_accessor context: String?
30
-
31
- attr_accessor title: String?
32
-
33
- def initialize: (
34
- source: Anthropic::Models::Beta::BetaBase64PDFBlock::source,
35
- ?cache_control: Anthropic::Beta::BetaCacheControlEphemeral?,
36
- ?citations: Anthropic::Beta::BetaCitationsConfigParam,
37
- ?context: String?,
38
- ?title: String?,
39
- ?type: :document
40
- ) -> void
41
-
42
- def to_hash: -> {
43
- source: Anthropic::Models::Beta::BetaBase64PDFBlock::source,
44
- type: :document,
45
- cache_control: Anthropic::Beta::BetaCacheControlEphemeral?,
46
- citations: Anthropic::Beta::BetaCitationsConfigParam,
47
- context: String?,
48
- title: String?
49
- }
50
-
51
- type source =
52
- Anthropic::Beta::BetaBase64PDFSource
53
- | Anthropic::Beta::BetaPlainTextSource
54
- | Anthropic::Beta::BetaContentBlockSource
55
- | Anthropic::Beta::BetaURLPDFSource
56
- | Anthropic::Beta::BetaFileDocumentSource
57
-
58
- module Source
59
- extend Anthropic::Internal::Type::Union
60
-
61
- def self?.variants: -> ::Array[Anthropic::Models::Beta::BetaBase64PDFBlock::source]
62
- end
63
- end
6
+ class BetaBase64PDFBlock = Anthropic::Models::Beta::BetaRequestDocumentBlock
64
7
  end
65
8
  end
66
9
  end
@@ -0,0 +1,54 @@
1
+ module Anthropic
2
+ module Models
3
+ class BetaCitationSearchResultLocation = Beta::BetaCitationSearchResultLocation
4
+
5
+ module Beta
6
+ type beta_citation_search_result_location =
7
+ {
8
+ cited_text: String,
9
+ end_block_index: Integer,
10
+ search_result_index: Integer,
11
+ source: String,
12
+ start_block_index: Integer,
13
+ title: String?,
14
+ type: :search_result_location
15
+ }
16
+
17
+ class BetaCitationSearchResultLocation < Anthropic::Internal::Type::BaseModel
18
+ attr_accessor cited_text: String
19
+
20
+ attr_accessor end_block_index: Integer
21
+
22
+ attr_accessor search_result_index: Integer
23
+
24
+ attr_accessor source: String
25
+
26
+ attr_accessor start_block_index: Integer
27
+
28
+ attr_accessor title: String?
29
+
30
+ attr_accessor type: :search_result_location
31
+
32
+ def initialize: (
33
+ cited_text: String,
34
+ end_block_index: Integer,
35
+ search_result_index: Integer,
36
+ source: String,
37
+ start_block_index: Integer,
38
+ title: String?,
39
+ ?type: :search_result_location
40
+ ) -> void
41
+
42
+ def to_hash: -> {
43
+ cited_text: String,
44
+ end_block_index: Integer,
45
+ search_result_index: Integer,
46
+ source: String,
47
+ start_block_index: Integer,
48
+ title: String?,
49
+ type: :search_result_location
50
+ }
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,54 @@
1
+ module Anthropic
2
+ module Models
3
+ class BetaCitationSearchResultLocationParam = Beta::BetaCitationSearchResultLocationParam
4
+
5
+ module Beta
6
+ type beta_citation_search_result_location_param =
7
+ {
8
+ cited_text: String,
9
+ end_block_index: Integer,
10
+ search_result_index: Integer,
11
+ source: String,
12
+ start_block_index: Integer,
13
+ title: String?,
14
+ type: :search_result_location
15
+ }
16
+
17
+ class BetaCitationSearchResultLocationParam < Anthropic::Internal::Type::BaseModel
18
+ attr_accessor cited_text: String
19
+
20
+ attr_accessor end_block_index: Integer
21
+
22
+ attr_accessor search_result_index: Integer
23
+
24
+ attr_accessor source: String
25
+
26
+ attr_accessor start_block_index: Integer
27
+
28
+ attr_accessor title: String?
29
+
30
+ attr_accessor type: :search_result_location
31
+
32
+ def initialize: (
33
+ cited_text: String,
34
+ end_block_index: Integer,
35
+ search_result_index: Integer,
36
+ source: String,
37
+ start_block_index: Integer,
38
+ title: String?,
39
+ ?type: :search_result_location
40
+ ) -> void
41
+
42
+ def to_hash: -> {
43
+ cited_text: String,
44
+ end_block_index: Integer,
45
+ search_result_index: Integer,
46
+ source: String,
47
+ start_block_index: Integer,
48
+ title: String?,
49
+ type: :search_result_location
50
+ }
51
+ end
52
+ end
53
+ end
54
+ end
@@ -29,6 +29,7 @@ module Anthropic
29
29
  | Anthropic::Beta::BetaCitationPageLocation
30
30
  | Anthropic::Beta::BetaCitationContentBlockLocation
31
31
  | Anthropic::Beta::BetaCitationsWebSearchResultLocation
32
+ | Anthropic::Beta::BetaCitationSearchResultLocation
32
33
 
33
34
  module Citation
34
35
  extend Anthropic::Internal::Type::Union
@@ -5,6 +5,8 @@ module Anthropic
5
5
  module Beta
6
6
  type beta_content_block =
7
7
  Anthropic::Beta::BetaTextBlock
8
+ | Anthropic::Beta::BetaThinkingBlock
9
+ | Anthropic::Beta::BetaRedactedThinkingBlock
8
10
  | Anthropic::Beta::BetaToolUseBlock
9
11
  | Anthropic::Beta::BetaServerToolUseBlock
10
12
  | Anthropic::Beta::BetaWebSearchToolResultBlock
@@ -12,8 +14,6 @@ module Anthropic
12
14
  | Anthropic::Beta::BetaMCPToolUseBlock
13
15
  | Anthropic::Beta::BetaMCPToolResultBlock
14
16
  | Anthropic::Beta::BetaContainerUploadBlock
15
- | Anthropic::Beta::BetaThinkingBlock
16
- | Anthropic::Beta::BetaRedactedThinkingBlock
17
17
 
18
18
  module BetaContentBlock
19
19
  extend Anthropic::Internal::Type::Union
@@ -4,18 +4,19 @@ module Anthropic
4
4
 
5
5
  module Beta
6
6
  type beta_content_block_param =
7
- Anthropic::Beta::BetaServerToolUseBlockParam
7
+ Anthropic::Beta::BetaTextBlockParam
8
+ | Anthropic::Beta::BetaImageBlockParam
9
+ | Anthropic::Beta::BetaRequestDocumentBlock
10
+ | Anthropic::Beta::BetaSearchResultBlockParam
11
+ | Anthropic::Beta::BetaThinkingBlockParam
12
+ | Anthropic::Beta::BetaRedactedThinkingBlockParam
13
+ | Anthropic::Beta::BetaToolUseBlockParam
14
+ | Anthropic::Beta::BetaToolResultBlockParam
15
+ | Anthropic::Beta::BetaServerToolUseBlockParam
8
16
  | Anthropic::Beta::BetaWebSearchToolResultBlockParam
9
17
  | Anthropic::Beta::BetaCodeExecutionToolResultBlockParam
10
18
  | Anthropic::Beta::BetaMCPToolUseBlockParam
11
19
  | Anthropic::Beta::BetaRequestMCPToolResultBlockParam
12
- | Anthropic::Beta::BetaTextBlockParam
13
- | Anthropic::Beta::BetaImageBlockParam
14
- | Anthropic::Beta::BetaToolUseBlockParam
15
- | Anthropic::Beta::BetaToolResultBlockParam
16
- | Anthropic::Beta::BetaBase64PDFBlock
17
- | Anthropic::Beta::BetaThinkingBlockParam
18
- | Anthropic::Beta::BetaRedactedThinkingBlockParam
19
20
  | Anthropic::Beta::BetaContainerUploadBlockParam
20
21
 
21
22
  module BetaContentBlockParam
@@ -31,6 +31,8 @@ module Anthropic
31
31
 
32
32
  type content_block =
33
33
  Anthropic::Beta::BetaTextBlock
34
+ | Anthropic::Beta::BetaThinkingBlock
35
+ | Anthropic::Beta::BetaRedactedThinkingBlock
34
36
  | Anthropic::Beta::BetaToolUseBlock
35
37
  | Anthropic::Beta::BetaServerToolUseBlock
36
38
  | Anthropic::Beta::BetaWebSearchToolResultBlock
@@ -38,8 +40,6 @@ module Anthropic
38
40
  | Anthropic::Beta::BetaMCPToolUseBlock
39
41
  | Anthropic::Beta::BetaMCPToolResultBlock
40
42
  | Anthropic::Beta::BetaContainerUploadBlock
41
- | Anthropic::Beta::BetaThinkingBlock
42
- | Anthropic::Beta::BetaRedactedThinkingBlock
43
43
 
44
44
  module ContentBlock
45
45
  extend Anthropic::Internal::Type::Union
@@ -0,0 +1,66 @@
1
+ module Anthropic
2
+ module Models
3
+ class BetaRequestDocumentBlock = Beta::BetaRequestDocumentBlock
4
+
5
+ module Beta
6
+ type beta_request_document_block =
7
+ {
8
+ source: Anthropic::Models::Beta::BetaRequestDocumentBlock::source,
9
+ type: :document,
10
+ cache_control: Anthropic::Beta::BetaCacheControlEphemeral?,
11
+ citations: Anthropic::Beta::BetaCitationsConfigParam,
12
+ context: String?,
13
+ title: String?
14
+ }
15
+
16
+ class BetaRequestDocumentBlock < Anthropic::Internal::Type::BaseModel
17
+ attr_accessor source: Anthropic::Models::Beta::BetaRequestDocumentBlock::source
18
+
19
+ attr_accessor type: :document
20
+
21
+ attr_accessor cache_control: Anthropic::Beta::BetaCacheControlEphemeral?
22
+
23
+ attr_reader citations: Anthropic::Beta::BetaCitationsConfigParam?
24
+
25
+ def citations=: (
26
+ Anthropic::Beta::BetaCitationsConfigParam
27
+ ) -> Anthropic::Beta::BetaCitationsConfigParam
28
+
29
+ attr_accessor context: String?
30
+
31
+ attr_accessor title: String?
32
+
33
+ def initialize: (
34
+ source: Anthropic::Models::Beta::BetaRequestDocumentBlock::source,
35
+ ?cache_control: Anthropic::Beta::BetaCacheControlEphemeral?,
36
+ ?citations: Anthropic::Beta::BetaCitationsConfigParam,
37
+ ?context: String?,
38
+ ?title: String?,
39
+ ?type: :document
40
+ ) -> void
41
+
42
+ def to_hash: -> {
43
+ source: Anthropic::Models::Beta::BetaRequestDocumentBlock::source,
44
+ type: :document,
45
+ cache_control: Anthropic::Beta::BetaCacheControlEphemeral?,
46
+ citations: Anthropic::Beta::BetaCitationsConfigParam,
47
+ context: String?,
48
+ title: String?
49
+ }
50
+
51
+ type source =
52
+ Anthropic::Beta::BetaBase64PDFSource
53
+ | Anthropic::Beta::BetaPlainTextSource
54
+ | Anthropic::Beta::BetaContentBlockSource
55
+ | Anthropic::Beta::BetaURLPDFSource
56
+ | Anthropic::Beta::BetaFileDocumentSource
57
+
58
+ module Source
59
+ extend Anthropic::Internal::Type::Union
60
+
61
+ def self?.variants: -> ::Array[Anthropic::Models::Beta::BetaRequestDocumentBlock::source]
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,53 @@
1
+ module Anthropic
2
+ module Models
3
+ class BetaSearchResultBlockParam = Beta::BetaSearchResultBlockParam
4
+
5
+ module Beta
6
+ type beta_search_result_block_param =
7
+ {
8
+ content: ::Array[Anthropic::Beta::BetaTextBlockParam],
9
+ source: String,
10
+ title: String,
11
+ type: :search_result,
12
+ cache_control: Anthropic::Beta::BetaCacheControlEphemeral?,
13
+ citations: Anthropic::Beta::BetaCitationsConfigParam
14
+ }
15
+
16
+ class BetaSearchResultBlockParam < Anthropic::Internal::Type::BaseModel
17
+ attr_accessor content: ::Array[Anthropic::Beta::BetaTextBlockParam]
18
+
19
+ attr_accessor source: String
20
+
21
+ attr_accessor title: String
22
+
23
+ attr_accessor type: :search_result
24
+
25
+ attr_accessor cache_control: Anthropic::Beta::BetaCacheControlEphemeral?
26
+
27
+ attr_reader citations: Anthropic::Beta::BetaCitationsConfigParam?
28
+
29
+ def citations=: (
30
+ Anthropic::Beta::BetaCitationsConfigParam
31
+ ) -> Anthropic::Beta::BetaCitationsConfigParam
32
+
33
+ def initialize: (
34
+ content: ::Array[Anthropic::Beta::BetaTextBlockParam],
35
+ source: String,
36
+ title: String,
37
+ ?cache_control: Anthropic::Beta::BetaCacheControlEphemeral?,
38
+ ?citations: Anthropic::Beta::BetaCitationsConfigParam,
39
+ ?type: :search_result
40
+ ) -> void
41
+
42
+ def to_hash: -> {
43
+ content: ::Array[Anthropic::Beta::BetaTextBlockParam],
44
+ source: String,
45
+ title: String,
46
+ type: :search_result,
47
+ cache_control: Anthropic::Beta::BetaCacheControlEphemeral?,
48
+ citations: Anthropic::Beta::BetaCitationsConfigParam
49
+ }
50
+ end
51
+ end
52
+ end
53
+ end
@@ -8,6 +8,7 @@ module Anthropic
8
8
  | Anthropic::Beta::BetaCitationPageLocation
9
9
  | Anthropic::Beta::BetaCitationContentBlockLocation
10
10
  | Anthropic::Beta::BetaCitationsWebSearchResultLocation
11
+ | Anthropic::Beta::BetaCitationSearchResultLocation
11
12
 
12
13
  module BetaTextCitation
13
14
  extend Anthropic::Internal::Type::Union
@@ -8,6 +8,7 @@ module Anthropic
8
8
  | Anthropic::Beta::BetaCitationPageLocationParam
9
9
  | Anthropic::Beta::BetaCitationContentBlockLocationParam
10
10
  | Anthropic::Beta::BetaCitationWebSearchResultLocationParam
11
+ | Anthropic::Beta::BetaCitationSearchResultLocationParam
11
12
 
12
13
  module BetaTextCitationParam
13
14
  extend Anthropic::Internal::Type::Union
@@ -41,16 +41,27 @@ module Anthropic
41
41
  type: Anthropic::Models::Beta::BetaTool::type_?
42
42
  }
43
43
 
44
- type input_schema = { type: :object, properties: top? }
44
+ type input_schema =
45
+ { type: :object, properties: top?, required: ::Array[String]? }
45
46
 
46
47
  class InputSchema < Anthropic::Internal::Type::BaseModel
47
48
  attr_accessor type: :object
48
49
 
49
50
  attr_accessor properties: top?
50
51
 
51
- def initialize: (?properties: top?, ?type: :object) -> void
52
+ attr_accessor required: ::Array[String]?
52
53
 
53
- def to_hash: -> { type: :object, properties: top? }
54
+ def initialize: (
55
+ ?properties: top?,
56
+ ?required: ::Array[String]?,
57
+ ?type: :object
58
+ ) -> void
59
+
60
+ def to_hash: -> {
61
+ type: :object,
62
+ properties: top?,
63
+ required: ::Array[String]?
64
+ }
54
65
  end
55
66
 
56
67
  type type_ = :custom
@@ -55,6 +55,7 @@ module Anthropic
55
55
  type content =
56
56
  Anthropic::Beta::BetaTextBlockParam
57
57
  | Anthropic::Beta::BetaImageBlockParam
58
+ | Anthropic::Beta::BetaSearchResultBlockParam
58
59
 
59
60
  module Content
60
61
  extend Anthropic::Internal::Type::Union
@@ -5,15 +5,15 @@ module Anthropic
5
5
  module Beta
6
6
  type beta_tool_union =
7
7
  Anthropic::Beta::BetaTool
8
- | Anthropic::Beta::BetaToolComputerUse20241022
9
8
  | Anthropic::Beta::BetaToolBash20241022
10
- | Anthropic::Beta::BetaToolTextEditor20241022
11
- | Anthropic::Beta::BetaToolComputerUse20250124
12
9
  | Anthropic::Beta::BetaToolBash20250124
10
+ | Anthropic::Beta::BetaCodeExecutionTool20250522
11
+ | Anthropic::Beta::BetaToolComputerUse20241022
12
+ | Anthropic::Beta::BetaToolComputerUse20250124
13
+ | Anthropic::Beta::BetaToolTextEditor20241022
13
14
  | Anthropic::Beta::BetaToolTextEditor20250124
14
15
  | Anthropic::Beta::BetaToolTextEditor20250429
15
16
  | Anthropic::Beta::BetaWebSearchTool20250305
16
- | Anthropic::Beta::BetaCodeExecutionTool20250522
17
17
 
18
18
  module BetaToolUnion
19
19
  extend Anthropic::Internal::Type::Union
@@ -94,15 +94,15 @@ module Anthropic
94
94
 
95
95
  type tool =
96
96
  Anthropic::Beta::BetaTool
97
- | Anthropic::Beta::BetaToolComputerUse20241022
98
97
  | Anthropic::Beta::BetaToolBash20241022
99
- | Anthropic::Beta::BetaToolTextEditor20241022
100
- | Anthropic::Beta::BetaToolComputerUse20250124
101
98
  | Anthropic::Beta::BetaToolBash20250124
99
+ | Anthropic::Beta::BetaCodeExecutionTool20250522
100
+ | Anthropic::Beta::BetaToolComputerUse20241022
101
+ | Anthropic::Beta::BetaToolComputerUse20250124
102
+ | Anthropic::Beta::BetaToolTextEditor20241022
102
103
  | Anthropic::Beta::BetaToolTextEditor20250124
103
104
  | Anthropic::Beta::BetaToolTextEditor20250429
104
105
  | Anthropic::Beta::BetaWebSearchTool20250305
105
- | Anthropic::Beta::BetaCodeExecutionTool20250522
106
106
 
107
107
  module Tool
108
108
  extend Anthropic::Internal::Type::Union
@@ -2,11 +2,11 @@ module Anthropic
2
2
  module Models
3
3
  type content_block =
4
4
  Anthropic::TextBlock
5
+ | Anthropic::ThinkingBlock
6
+ | Anthropic::RedactedThinkingBlock
5
7
  | Anthropic::ToolUseBlock
6
8
  | Anthropic::ServerToolUseBlock
7
9
  | Anthropic::WebSearchToolResultBlock
8
- | Anthropic::ThinkingBlock
9
- | Anthropic::RedactedThinkingBlock
10
10
 
11
11
  module ContentBlock
12
12
  extend Anthropic::Internal::Type::Union
@@ -1,15 +1,15 @@
1
1
  module Anthropic
2
2
  module Models
3
3
  type content_block_param =
4
- Anthropic::ServerToolUseBlockParam
5
- | Anthropic::WebSearchToolResultBlockParam
6
- | Anthropic::TextBlockParam
4
+ Anthropic::TextBlockParam
7
5
  | Anthropic::ImageBlockParam
8
- | Anthropic::ToolUseBlockParam
9
- | Anthropic::ToolResultBlockParam
10
6
  | Anthropic::DocumentBlockParam
11
7
  | Anthropic::ThinkingBlockParam
12
8
  | Anthropic::RedactedThinkingBlockParam
9
+ | Anthropic::ToolUseBlockParam
10
+ | Anthropic::ToolResultBlockParam
11
+ | Anthropic::ServerToolUseBlockParam
12
+ | Anthropic::WebSearchToolResultBlockParam
13
13
 
14
14
  module ContentBlockParam
15
15
  extend Anthropic::Internal::Type::Union
@@ -4,11 +4,39 @@ module Anthropic
4
4
  Anthropic::Tool
5
5
  | Anthropic::ToolBash20250124
6
6
  | Anthropic::ToolTextEditor20250124
7
+ | Anthropic::MessageCountTokensTool::TextEditor20250429
7
8
  | Anthropic::WebSearchTool20250305
8
9
 
9
10
  module MessageCountTokensTool
10
11
  extend Anthropic::Internal::Type::Union
11
12
 
13
+ type text_editor20250429 =
14
+ {
15
+ name: :str_replace_based_edit_tool,
16
+ type: :text_editor_20250429,
17
+ cache_control: Anthropic::CacheControlEphemeral?
18
+ }
19
+
20
+ class TextEditor20250429 < Anthropic::Internal::Type::BaseModel
21
+ attr_accessor name: :str_replace_based_edit_tool
22
+
23
+ attr_accessor type: :text_editor_20250429
24
+
25
+ attr_accessor cache_control: Anthropic::CacheControlEphemeral?
26
+
27
+ def initialize: (
28
+ ?cache_control: Anthropic::CacheControlEphemeral?,
29
+ ?name: :str_replace_based_edit_tool,
30
+ ?type: :text_editor_20250429
31
+ ) -> void
32
+
33
+ def to_hash: -> {
34
+ name: :str_replace_based_edit_tool,
35
+ type: :text_editor_20250429,
36
+ cache_control: Anthropic::CacheControlEphemeral?
37
+ }
38
+ end
39
+
12
40
  def self?.variants: -> ::Array[Anthropic::Models::message_count_tokens_tool]
13
41
  end
14
42
  end
@@ -16,10 +16,7 @@ module Anthropic
16
16
  | :"claude-4-opus-20250514"
17
17
  | :"claude-3-opus-latest"
18
18
  | :"claude-3-opus-20240229"
19
- | :"claude-3-sonnet-20240229"
20
19
  | :"claude-3-haiku-20240307"
21
- | :"claude-2.1"
22
- | :"claude-2.0"
23
20
  | String
24
21
 
25
22
  module Model
@@ -71,15 +68,8 @@ module Anthropic
71
68
  # Excels at writing and complex tasks
72
69
  CLAUDE_3_OPUS_20240229: :"claude-3-opus-20240229"
73
70
 
74
- # Balance of speed and intelligence
75
- CLAUDE_3_SONNET_20240229: :"claude-3-sonnet-20240229"
76
-
77
71
  # Our previous most fast and cost-effective
78
72
  CLAUDE_3_HAIKU_20240307: :"claude-3-haiku-20240307"
79
-
80
- CLAUDE_2_1: :"claude-2.1"
81
-
82
- CLAUDE_2_0: :"claude-2.0"
83
73
  end
84
74
  end
85
75
  end