anthropic 1.6.0 → 1.8.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 (147) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -0
  3. data/README.md +1 -1
  4. data/lib/anthropic/helpers/input_schema/array_of.rb +41 -0
  5. data/lib/anthropic/helpers/input_schema/base_model.rb +86 -0
  6. data/lib/anthropic/helpers/input_schema/boolean.rb +29 -0
  7. data/lib/anthropic/helpers/input_schema/enum_of.rb +63 -0
  8. data/lib/anthropic/helpers/input_schema/json_schema_converter.rb +199 -0
  9. data/lib/anthropic/helpers/input_schema/parsed_json.rb +39 -0
  10. data/lib/anthropic/helpers/input_schema/property_mapping.rb +47 -0
  11. data/lib/anthropic/helpers/input_schema/union_of.rb +56 -0
  12. data/lib/anthropic/helpers/input_schema.rb +16 -0
  13. data/lib/anthropic/helpers/streaming/message_stream.rb +41 -1
  14. data/lib/anthropic/input_schema.rb +10 -0
  15. data/lib/anthropic/internal/stream.rb +2 -1
  16. data/lib/anthropic/internal/transport/base_client.rb +1 -2
  17. data/lib/anthropic/internal/transport/pooled_net_requester.rb +1 -9
  18. data/lib/anthropic/internal/type/base_model.rb +2 -9
  19. data/lib/anthropic/internal/util.rb +1 -1
  20. data/lib/anthropic/models/beta/beta_bash_code_execution_output_block.rb +25 -0
  21. data/lib/anthropic/models/beta/beta_bash_code_execution_output_block_param.rb +25 -0
  22. data/lib/anthropic/models/beta/beta_bash_code_execution_result_block.rb +44 -0
  23. data/lib/anthropic/models/beta/beta_bash_code_execution_result_block_param.rb +44 -0
  24. data/lib/anthropic/models/beta/beta_bash_code_execution_tool_result_block.rb +43 -0
  25. data/lib/anthropic/models/beta/beta_bash_code_execution_tool_result_block_param.rb +53 -0
  26. data/lib/anthropic/models/beta/beta_bash_code_execution_tool_result_error.rb +39 -0
  27. data/lib/anthropic/models/beta/beta_bash_code_execution_tool_result_error_param.rb +39 -0
  28. data/lib/anthropic/models/beta/beta_code_execution_tool_20250825.rb +40 -0
  29. data/lib/anthropic/models/beta/beta_content_block.rb +6 -1
  30. data/lib/anthropic/models/beta/beta_content_block_param.rb +7 -1
  31. data/lib/anthropic/models/beta/beta_message.rb +2 -2
  32. data/lib/anthropic/models/beta/beta_message_param.rb +3 -3
  33. data/lib/anthropic/models/beta/beta_raw_content_block_start_event.rb +8 -3
  34. data/lib/anthropic/models/beta/beta_server_tool_use_block.rb +2 -0
  35. data/lib/anthropic/models/beta/beta_server_tool_use_block_param.rb +2 -0
  36. data/lib/anthropic/models/beta/beta_text_editor_code_execution_create_result_block.rb +25 -0
  37. data/lib/anthropic/models/beta/beta_text_editor_code_execution_create_result_block_param.rb +26 -0
  38. data/lib/anthropic/models/beta/beta_text_editor_code_execution_str_replace_result_block.rb +49 -0
  39. data/lib/anthropic/models/beta/beta_text_editor_code_execution_str_replace_result_block_param.rb +50 -0
  40. data/lib/anthropic/models/beta/beta_text_editor_code_execution_tool_result_block.rb +47 -0
  41. data/lib/anthropic/models/beta/beta_text_editor_code_execution_tool_result_block_param.rb +57 -0
  42. data/lib/anthropic/models/beta/beta_text_editor_code_execution_tool_result_error.rb +45 -0
  43. data/lib/anthropic/models/beta/beta_text_editor_code_execution_tool_result_error_param.rb +46 -0
  44. data/lib/anthropic/models/beta/beta_text_editor_code_execution_view_result_block.rb +61 -0
  45. data/lib/anthropic/models/beta/beta_text_editor_code_execution_view_result_block_param.rb +62 -0
  46. data/lib/anthropic/models/beta/beta_tool_union.rb +3 -1
  47. data/lib/anthropic/models/beta/message_count_tokens_params.rb +7 -30
  48. data/lib/anthropic/models/beta/message_create_params.rb +3 -26
  49. data/lib/anthropic/models/beta/messages/batch_create_params.rb +6 -36
  50. data/lib/anthropic/models/beta/messages/beta_message_batch.rb +1 -4
  51. data/lib/anthropic/models/beta_error_response.rb +7 -1
  52. data/lib/anthropic/models/cache_control_ephemeral.rb +39 -1
  53. data/lib/anthropic/models/cache_creation.rb +24 -0
  54. data/lib/anthropic/models/error_response.rb +7 -1
  55. data/lib/anthropic/models/message_count_tokens_params.rb +1 -24
  56. data/lib/anthropic/models/message_create_params.rb +1 -24
  57. data/lib/anthropic/models/messages/batch_create_params.rb +2 -28
  58. data/lib/anthropic/models/model.rb +6 -0
  59. data/lib/anthropic/models/tool_use_block.rb +8 -0
  60. data/lib/anthropic/models/usage.rb +9 -1
  61. data/lib/anthropic/models.rb +2 -0
  62. data/lib/anthropic/resources/beta/messages.rb +3 -3
  63. data/lib/anthropic/resources/messages.rb +85 -1
  64. data/lib/anthropic/version.rb +1 -1
  65. data/lib/anthropic.rb +30 -0
  66. data/rbi/anthropic/errors.rbi +2 -2
  67. data/rbi/anthropic/helpers/input_schema/array_of.rbi +16 -0
  68. data/rbi/anthropic/helpers/input_schema/base_model.rbi +21 -0
  69. data/rbi/anthropic/helpers/input_schema/boolean.rbi +11 -0
  70. data/rbi/anthropic/helpers/input_schema/enum_of.rbi +30 -0
  71. data/rbi/anthropic/helpers/input_schema/json_schema_converter.rbi +89 -0
  72. data/rbi/anthropic/helpers/input_schema/union_of.rbi +23 -0
  73. data/rbi/anthropic/helpers/structured_output.rbi +16 -0
  74. data/rbi/anthropic/input_schema.rbi +12 -0
  75. data/rbi/anthropic/models/beta/beta_bash_code_execution_output_block.rbi +33 -0
  76. data/rbi/anthropic/models/beta/beta_bash_code_execution_output_block_param.rbi +34 -0
  77. data/rbi/anthropic/models/beta/beta_bash_code_execution_result_block.rbi +72 -0
  78. data/rbi/anthropic/models/beta/beta_bash_code_execution_result_block_param.rbi +77 -0
  79. data/rbi/anthropic/models/beta/beta_bash_code_execution_tool_result_block.rbi +86 -0
  80. data/rbi/anthropic/models/beta/beta_bash_code_execution_tool_result_block_param.rbi +110 -0
  81. data/rbi/anthropic/models/beta/beta_bash_code_execution_tool_result_error.rbi +101 -0
  82. data/rbi/anthropic/models/beta/beta_bash_code_execution_tool_result_error_param.rbi +101 -0
  83. data/rbi/anthropic/models/beta/beta_code_execution_tool_20250825.rbi +72 -0
  84. data/rbi/anthropic/models/beta/beta_content_block.rbi +2 -0
  85. data/rbi/anthropic/models/beta/beta_content_block_param.rbi +2 -0
  86. data/rbi/anthropic/models/beta/beta_message.rbi +2 -0
  87. data/rbi/anthropic/models/beta/beta_raw_content_block_start_event.rbi +4 -0
  88. data/rbi/anthropic/models/beta/beta_server_tool_use_block.rbi +10 -0
  89. data/rbi/anthropic/models/beta/beta_server_tool_use_block_param.rbi +10 -0
  90. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_create_result_block.rbi +41 -0
  91. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_create_result_block_param.rbi +41 -0
  92. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_str_replace_result_block.rbi +73 -0
  93. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_str_replace_result_block_param.rbi +73 -0
  94. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_tool_result_block.rbi +90 -0
  95. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_tool_result_block_param.rbi +118 -0
  96. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_tool_result_error.rbi +110 -0
  97. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_tool_result_error_param.rbi +110 -0
  98. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_view_result_block.rbi +118 -0
  99. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_view_result_block_param.rbi +118 -0
  100. data/rbi/anthropic/models/beta/beta_tool_union.rbi +1 -0
  101. data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +7 -48
  102. data/rbi/anthropic/models/beta/message_create_params.rbi +6 -48
  103. data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +6 -48
  104. data/rbi/anthropic/models/beta_error_response.rbi +10 -2
  105. data/rbi/anthropic/models/cache_control_ephemeral.rbi +68 -3
  106. data/rbi/anthropic/models/cache_creation.rbi +45 -0
  107. data/rbi/anthropic/models/error_response.rbi +10 -2
  108. data/rbi/anthropic/models/message_count_tokens_params.rbi +2 -48
  109. data/rbi/anthropic/models/message_create_params.rbi +2 -48
  110. data/rbi/anthropic/models/messages/batch_create_params.rbi +2 -48
  111. data/rbi/anthropic/models/usage.rbi +13 -0
  112. data/rbi/anthropic/models.rbi +2 -0
  113. data/rbi/anthropic/resources/beta/messages.rbi +6 -72
  114. data/rbi/anthropic/resources/messages.rbi +3 -72
  115. data/sig/anthropic/models/beta/beta_bash_code_execution_output_block.rbs +23 -0
  116. data/sig/anthropic/models/beta/beta_bash_code_execution_output_block_param.rbs +23 -0
  117. data/sig/anthropic/models/beta/beta_bash_code_execution_result_block.rbs +44 -0
  118. data/sig/anthropic/models/beta/beta_bash_code_execution_result_block_param.rbs +44 -0
  119. data/sig/anthropic/models/beta/beta_bash_code_execution_tool_result_block.rbs +44 -0
  120. data/sig/anthropic/models/beta/beta_bash_code_execution_tool_result_block_param.rbs +49 -0
  121. data/sig/anthropic/models/beta/beta_bash_code_execution_tool_result_error.rbs +48 -0
  122. data/sig/anthropic/models/beta/beta_bash_code_execution_tool_result_error_param.rbs +48 -0
  123. data/sig/anthropic/models/beta/beta_code_execution_tool_20250825.rbs +34 -0
  124. data/sig/anthropic/models/beta/beta_content_block.rbs +2 -0
  125. data/sig/anthropic/models/beta/beta_content_block_param.rbs +2 -0
  126. data/sig/anthropic/models/beta/beta_raw_content_block_start_event.rbs +2 -0
  127. data/sig/anthropic/models/beta/beta_server_tool_use_block.rbs +7 -1
  128. data/sig/anthropic/models/beta/beta_server_tool_use_block_param.rbs +7 -1
  129. data/sig/anthropic/models/beta/beta_text_editor_code_execution_create_result_block.rbs +29 -0
  130. data/sig/anthropic/models/beta/beta_text_editor_code_execution_create_result_block_param.rbs +29 -0
  131. data/sig/anthropic/models/beta/beta_text_editor_code_execution_str_replace_result_block.rbs +49 -0
  132. data/sig/anthropic/models/beta/beta_text_editor_code_execution_str_replace_result_block_param.rbs +49 -0
  133. data/sig/anthropic/models/beta/beta_text_editor_code_execution_tool_result_block.rbs +46 -0
  134. data/sig/anthropic/models/beta/beta_text_editor_code_execution_tool_result_block_param.rbs +51 -0
  135. data/sig/anthropic/models/beta/beta_text_editor_code_execution_tool_result_error.rbs +53 -0
  136. data/sig/anthropic/models/beta/beta_text_editor_code_execution_tool_result_error_param.rbs +53 -0
  137. data/sig/anthropic/models/beta/beta_text_editor_code_execution_view_result_block.rbs +61 -0
  138. data/sig/anthropic/models/beta/beta_text_editor_code_execution_view_result_block_param.rbs +61 -0
  139. data/sig/anthropic/models/beta/beta_tool_union.rbs +1 -0
  140. data/sig/anthropic/models/beta/message_count_tokens_params.rbs +1 -0
  141. data/sig/anthropic/models/beta_error_response.rbs +13 -2
  142. data/sig/anthropic/models/cache_control_ephemeral.rbs +27 -3
  143. data/sig/anthropic/models/cache_creation.rbs +25 -0
  144. data/sig/anthropic/models/error_response.rbs +13 -2
  145. data/sig/anthropic/models/usage.rbs +5 -0
  146. data/sig/anthropic/models.rbs +2 -0
  147. metadata +80 -2
data/lib/anthropic.rb CHANGED
@@ -67,6 +67,14 @@ require_relative "anthropic/models/base64_pdf_source"
67
67
  require_relative "anthropic/models/beta/beta_base64_image_source"
68
68
  require_relative "anthropic/models/beta/beta_base64_pdf_block"
69
69
  require_relative "anthropic/models/beta/beta_base64_pdf_source"
70
+ require_relative "anthropic/models/beta/beta_bash_code_execution_output_block"
71
+ require_relative "anthropic/models/beta/beta_bash_code_execution_output_block_param"
72
+ require_relative "anthropic/models/beta/beta_bash_code_execution_result_block"
73
+ require_relative "anthropic/models/beta/beta_bash_code_execution_result_block_param"
74
+ require_relative "anthropic/models/beta/beta_bash_code_execution_tool_result_block"
75
+ require_relative "anthropic/models/beta/beta_bash_code_execution_tool_result_block_param"
76
+ require_relative "anthropic/models/beta/beta_bash_code_execution_tool_result_error"
77
+ require_relative "anthropic/models/beta/beta_bash_code_execution_tool_result_error_param"
70
78
  require_relative "anthropic/models/beta/beta_cache_control_ephemeral"
71
79
  require_relative "anthropic/models/beta/beta_cache_creation"
72
80
  require_relative "anthropic/models/beta/beta_citation_char_location"
@@ -86,6 +94,7 @@ require_relative "anthropic/models/beta/beta_code_execution_output_block_param"
86
94
  require_relative "anthropic/models/beta/beta_code_execution_result_block"
87
95
  require_relative "anthropic/models/beta/beta_code_execution_result_block_param"
88
96
  require_relative "anthropic/models/beta/beta_code_execution_tool_20250522"
97
+ require_relative "anthropic/models/beta/beta_code_execution_tool_20250825"
89
98
  require_relative "anthropic/models/beta/beta_code_execution_tool_result_block"
90
99
  require_relative "anthropic/models/beta/beta_code_execution_tool_result_block_content"
91
100
  require_relative "anthropic/models/beta/beta_code_execution_tool_result_block_param"
@@ -138,6 +147,16 @@ require_relative "anthropic/models/beta/beta_text_block_param"
138
147
  require_relative "anthropic/models/beta/beta_text_citation"
139
148
  require_relative "anthropic/models/beta/beta_text_citation_param"
140
149
  require_relative "anthropic/models/beta/beta_text_delta"
150
+ require_relative "anthropic/models/beta/beta_text_editor_code_execution_create_result_block"
151
+ require_relative "anthropic/models/beta/beta_text_editor_code_execution_create_result_block_param"
152
+ require_relative "anthropic/models/beta/beta_text_editor_code_execution_str_replace_result_block"
153
+ require_relative "anthropic/models/beta/beta_text_editor_code_execution_str_replace_result_block_param"
154
+ require_relative "anthropic/models/beta/beta_text_editor_code_execution_tool_result_block"
155
+ require_relative "anthropic/models/beta/beta_text_editor_code_execution_tool_result_block_param"
156
+ require_relative "anthropic/models/beta/beta_text_editor_code_execution_tool_result_error"
157
+ require_relative "anthropic/models/beta/beta_text_editor_code_execution_tool_result_error_param"
158
+ require_relative "anthropic/models/beta/beta_text_editor_code_execution_view_result_block"
159
+ require_relative "anthropic/models/beta/beta_text_editor_code_execution_view_result_block_param"
141
160
  require_relative "anthropic/models/beta/beta_thinking_block"
142
161
  require_relative "anthropic/models/beta/beta_thinking_block_param"
143
162
  require_relative "anthropic/models/beta/beta_thinking_config_disabled"
@@ -214,6 +233,7 @@ require_relative "anthropic/models/beta_permission_error"
214
233
  require_relative "anthropic/models/beta_rate_limit_error"
215
234
  require_relative "anthropic/models/billing_error"
216
235
  require_relative "anthropic/models/cache_control_ephemeral"
236
+ require_relative "anthropic/models/cache_creation"
217
237
  require_relative "anthropic/models/citation_char_location"
218
238
  require_relative "anthropic/models/citation_char_location_param"
219
239
  require_relative "anthropic/models/citation_content_block_location"
@@ -338,3 +358,13 @@ require_relative "anthropic/resources/completions"
338
358
  require_relative "anthropic/resources/messages"
339
359
  require_relative "anthropic/resources/messages/batches"
340
360
  require_relative "anthropic/resources/models"
361
+ require_relative "anthropic/helpers/input_schema"
362
+ require_relative "anthropic/helpers/input_schema/property_mapping"
363
+ require_relative "anthropic/helpers/input_schema/json_schema_converter"
364
+ require_relative "anthropic/helpers/input_schema/base_model"
365
+ require_relative "anthropic/helpers/input_schema/array_of"
366
+ require_relative "anthropic/helpers/input_schema/boolean"
367
+ require_relative "anthropic/helpers/input_schema/enum_of"
368
+ require_relative "anthropic/helpers/input_schema/union_of"
369
+ require_relative "anthropic/helpers/input_schema/parsed_json"
370
+ require_relative "anthropic/input_schema"
@@ -59,10 +59,10 @@ module Anthropic
59
59
  end
60
60
 
61
61
  class APIConnectionError < Anthropic::Errors::APIError
62
- sig { void }
62
+ sig { returns(NilClass) }
63
63
  attr_accessor :status
64
64
 
65
- sig { void }
65
+ sig { returns(NilClass) }
66
66
  attr_accessor :body
67
67
 
68
68
  # @api private
@@ -0,0 +1,16 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Helpers
5
+ module InputSchema
6
+ class ArrayOf < Anthropic::Internal::Type::ArrayOf
7
+ include Anthropic::Helpers::InputSchema::JsonSchemaConverter
8
+
9
+ Elem = type_member(:out)
10
+
11
+ sig { returns(String) }
12
+ attr_reader :description
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Helpers
5
+ module InputSchema
6
+ # Represents a response from Anthropic's API where the model's output has been structured according to a schema predefined by the user.
7
+ #
8
+ # This class is specifically used when making requests with the `response_format` parameter set to use structured output (e.g., JSON).
9
+ #
10
+ # See {examples/input_schemas.rb} for a complete example of use
11
+ class BaseModel < Anthropic::Internal::Type::BaseModel
12
+ extend Anthropic::Helpers::InputSchema::JsonSchemaConverter
13
+
14
+ class << self
15
+ sig { params(doc: T.nilable(String)).void }
16
+ attr_writer :doc
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Helpers
5
+ module InputSchema
6
+ class Boolean < Anthropic::Internal::Type::Boolean
7
+ extend Anthropic::Helpers::InputSchema::JsonSchemaConverter
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,30 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Helpers
5
+ module InputSchema
6
+ # @example
7
+ # example = Anthropic::EnumOf[:foo, :bar, :zoo]
8
+ #
9
+ # @example
10
+ # example = Anthropic::EnumOf[1, 2, 3]
11
+ class EnumOf
12
+ include Anthropic::Internal::Type::Enum
13
+ include Anthropic::Helpers::InputSchema::JsonSchemaConverter
14
+
15
+ sig do
16
+ params(
17
+ values: T.any(NilClass, T::Boolean, Integer, Float, Symbol)
18
+ ).returns(T.attached_class)
19
+ end
20
+ def self.[](*values)
21
+ end
22
+
23
+ sig do
24
+ returns(T::Array[T.any(NilClass, T::Boolean, Integer, Float, Symbol)])
25
+ end
26
+ attr_reader :values
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,89 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Helpers
5
+ module InputSchema
6
+ JsonSchema = T.type_alias { Anthropic::Internal::AnyHash }
7
+
8
+ # To customize the JSON schema conversion for a type, implement the `JsonSchemaConverter` interface.
9
+ module JsonSchemaConverter
10
+ POINTER = T.let(Object.new.freeze, T.anything)
11
+ COUNTER = T.let(Object.new.freeze, T.anything)
12
+
13
+ Input =
14
+ T.type_alias do
15
+ T.any(
16
+ Anthropic::Helpers::InputSchema::JsonSchemaConverter,
17
+ T::Class[T.anything]
18
+ )
19
+ end
20
+ State =
21
+ T.type_alias do
22
+ { defs: T::Hash[Object, String], path: T::Array[String] }
23
+ end
24
+
25
+ # The exact JSON schema produced is subject to improvement between minor release versions.
26
+ sig do
27
+ params(
28
+ state: Anthropic::Helpers::InputSchema::JsonSchemaConverter::State
29
+ ).returns(Anthropic::Helpers::InputSchema::JsonSchema)
30
+ end
31
+ def to_json_schema_inner(state:)
32
+ end
33
+
34
+ # Internal helpers methods.
35
+ class << self
36
+ # @api private
37
+ sig do
38
+ params(schema: Anthropic::Helpers::InputSchema::JsonSchema).returns(
39
+ Anthropic::Helpers::InputSchema::JsonSchema
40
+ )
41
+ end
42
+ def to_nilable(schema)
43
+ end
44
+
45
+ # @api private
46
+ sig do
47
+ params(
48
+ schema: Anthropic::Helpers::InputSchema::JsonSchema,
49
+ meta: Anthropic::Internal::AnyHash
50
+ ).void
51
+ end
52
+ def assoc_meta!(schema, meta:)
53
+ end
54
+
55
+ # @api private
56
+ sig do
57
+ params(
58
+ state:
59
+ Anthropic::Helpers::InputSchema::JsonSchemaConverter::State,
60
+ type: Anthropic::Helpers::InputSchema::JsonSchemaConverter::Input,
61
+ blk: T.proc.returns(Anthropic::Helpers::InputSchema::JsonSchema)
62
+ ).void
63
+ end
64
+ def cache_def!(state, type:, &blk)
65
+ end
66
+
67
+ # @api private
68
+ sig do
69
+ params(
70
+ type: Anthropic::Helpers::InputSchema::JsonSchemaConverter::Input
71
+ ).returns(Anthropic::Helpers::InputSchema::JsonSchema)
72
+ end
73
+ def to_json_schema(type)
74
+ end
75
+
76
+ # @api private
77
+ sig do
78
+ params(
79
+ type: Anthropic::Helpers::InputSchema::JsonSchemaConverter::Input,
80
+ state: Anthropic::Helpers::InputSchema::JsonSchemaConverter::State
81
+ ).returns(Anthropic::Helpers::InputSchema::JsonSchema)
82
+ end
83
+ def to_json_schema_inner(type, state:)
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,23 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Helpers
5
+ module InputSchema
6
+ # @example
7
+ # example = Anthropic::UnionOf[Float, Anthropic::ArrayOf[Integer]]
8
+ class UnionOf
9
+ include Anthropic::Internal::Type::Union
10
+ include Anthropic::Helpers::InputSchema::JsonSchemaConverter
11
+
12
+ sig do
13
+ params(
14
+ variants:
15
+ Anthropic::Helpers::InputSchema::JsonSchemaConverter::Input
16
+ ).returns(T.attached_class)
17
+ end
18
+ def self.[](*variants)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,16 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Helpers
5
+ # Helpers for the structured output API.
6
+ #
7
+ # see https://platform.Anthropic.com/docs/guides/structured-outputs
8
+ # see https://json-schema.org
9
+ #
10
+ # Based on the DSL in {Anthropic::Internal::Type}, but currently only support the limited subset of JSON schema types used in structured output APIs.
11
+ #
12
+ # Supported types: {NilClass} {String} {Symbol} {Integer} {Float} {Anthropic::Boolean}, {Anthropic::EnumOf}, {Anthropic::UnionOf}, {Anthropic::ArrayOf}, {Anthropic::BaseModel}
13
+ module InputSchema
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ # typed: strong
2
+ # frozen_string_literal: true
3
+
4
+ module Anthropic
5
+ # Convenience aliases for input schema classes
6
+ InputSchema = Anthropic::Helpers::InputSchema
7
+ ArrayOf = Anthropic::Helpers::InputSchema::ArrayOf
8
+ BaseModel = Anthropic::Helpers::InputSchema::BaseModel
9
+ Boolean = Anthropic::Helpers::InputSchema::Boolean
10
+ EnumOf = Anthropic::Helpers::InputSchema::EnumOf
11
+ UnionOf = Anthropic::Helpers::InputSchema::UnionOf
12
+ end
@@ -0,0 +1,33 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaBashCodeExecutionOutputBlock = Beta::BetaBashCodeExecutionOutputBlock
6
+
7
+ module Beta
8
+ class BetaBashCodeExecutionOutputBlock < Anthropic::Internal::Type::BaseModel
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Anthropic::Beta::BetaBashCodeExecutionOutputBlock,
13
+ Anthropic::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ sig { returns(String) }
18
+ attr_accessor :file_id
19
+
20
+ sig { returns(Symbol) }
21
+ attr_accessor :type
22
+
23
+ sig { params(file_id: String, type: Symbol).returns(T.attached_class) }
24
+ def self.new(file_id:, type: :bash_code_execution_output)
25
+ end
26
+
27
+ sig { override.returns({ file_id: String, type: Symbol }) }
28
+ def to_hash
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,34 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaBashCodeExecutionOutputBlockParam =
6
+ Beta::BetaBashCodeExecutionOutputBlockParam
7
+
8
+ module Beta
9
+ class BetaBashCodeExecutionOutputBlockParam < Anthropic::Internal::Type::BaseModel
10
+ OrHash =
11
+ T.type_alias do
12
+ T.any(
13
+ Anthropic::Beta::BetaBashCodeExecutionOutputBlockParam,
14
+ Anthropic::Internal::AnyHash
15
+ )
16
+ end
17
+
18
+ sig { returns(String) }
19
+ attr_accessor :file_id
20
+
21
+ sig { returns(Symbol) }
22
+ attr_accessor :type
23
+
24
+ sig { params(file_id: String, type: Symbol).returns(T.attached_class) }
25
+ def self.new(file_id:, type: :bash_code_execution_output)
26
+ end
27
+
28
+ sig { override.returns({ file_id: String, type: Symbol }) }
29
+ def to_hash
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,72 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaBashCodeExecutionResultBlock = Beta::BetaBashCodeExecutionResultBlock
6
+
7
+ module Beta
8
+ class BetaBashCodeExecutionResultBlock < Anthropic::Internal::Type::BaseModel
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(
12
+ Anthropic::Beta::BetaBashCodeExecutionResultBlock,
13
+ Anthropic::Internal::AnyHash
14
+ )
15
+ end
16
+
17
+ sig do
18
+ returns(T::Array[Anthropic::Beta::BetaBashCodeExecutionOutputBlock])
19
+ end
20
+ attr_accessor :content
21
+
22
+ sig { returns(Integer) }
23
+ attr_accessor :return_code
24
+
25
+ sig { returns(String) }
26
+ attr_accessor :stderr
27
+
28
+ sig { returns(String) }
29
+ attr_accessor :stdout
30
+
31
+ sig { returns(Symbol) }
32
+ attr_accessor :type
33
+
34
+ sig do
35
+ params(
36
+ content:
37
+ T::Array[
38
+ Anthropic::Beta::BetaBashCodeExecutionOutputBlock::OrHash
39
+ ],
40
+ return_code: Integer,
41
+ stderr: String,
42
+ stdout: String,
43
+ type: Symbol
44
+ ).returns(T.attached_class)
45
+ end
46
+ def self.new(
47
+ content:,
48
+ return_code:,
49
+ stderr:,
50
+ stdout:,
51
+ type: :bash_code_execution_result
52
+ )
53
+ end
54
+
55
+ sig do
56
+ override.returns(
57
+ {
58
+ content:
59
+ T::Array[Anthropic::Beta::BetaBashCodeExecutionOutputBlock],
60
+ return_code: Integer,
61
+ stderr: String,
62
+ stdout: String,
63
+ type: Symbol
64
+ }
65
+ )
66
+ end
67
+ def to_hash
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,77 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaBashCodeExecutionResultBlockParam =
6
+ Beta::BetaBashCodeExecutionResultBlockParam
7
+
8
+ module Beta
9
+ class BetaBashCodeExecutionResultBlockParam < Anthropic::Internal::Type::BaseModel
10
+ OrHash =
11
+ T.type_alias do
12
+ T.any(
13
+ Anthropic::Beta::BetaBashCodeExecutionResultBlockParam,
14
+ Anthropic::Internal::AnyHash
15
+ )
16
+ end
17
+
18
+ sig do
19
+ returns(
20
+ T::Array[Anthropic::Beta::BetaBashCodeExecutionOutputBlockParam]
21
+ )
22
+ end
23
+ attr_accessor :content
24
+
25
+ sig { returns(Integer) }
26
+ attr_accessor :return_code
27
+
28
+ sig { returns(String) }
29
+ attr_accessor :stderr
30
+
31
+ sig { returns(String) }
32
+ attr_accessor :stdout
33
+
34
+ sig { returns(Symbol) }
35
+ attr_accessor :type
36
+
37
+ sig do
38
+ params(
39
+ content:
40
+ T::Array[
41
+ Anthropic::Beta::BetaBashCodeExecutionOutputBlockParam::OrHash
42
+ ],
43
+ return_code: Integer,
44
+ stderr: String,
45
+ stdout: String,
46
+ type: Symbol
47
+ ).returns(T.attached_class)
48
+ end
49
+ def self.new(
50
+ content:,
51
+ return_code:,
52
+ stderr:,
53
+ stdout:,
54
+ type: :bash_code_execution_result
55
+ )
56
+ end
57
+
58
+ sig do
59
+ override.returns(
60
+ {
61
+ content:
62
+ T::Array[
63
+ Anthropic::Beta::BetaBashCodeExecutionOutputBlockParam
64
+ ],
65
+ return_code: Integer,
66
+ stderr: String,
67
+ stdout: String,
68
+ type: Symbol
69
+ }
70
+ )
71
+ end
72
+ def to_hash
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,86 @@
1
+ # typed: strong
2
+
3
+ module Anthropic
4
+ module Models
5
+ BetaBashCodeExecutionToolResultBlock =
6
+ Beta::BetaBashCodeExecutionToolResultBlock
7
+
8
+ module Beta
9
+ class BetaBashCodeExecutionToolResultBlock < Anthropic::Internal::Type::BaseModel
10
+ OrHash =
11
+ T.type_alias do
12
+ T.any(
13
+ Anthropic::Beta::BetaBashCodeExecutionToolResultBlock,
14
+ Anthropic::Internal::AnyHash
15
+ )
16
+ end
17
+
18
+ sig do
19
+ returns(
20
+ Anthropic::Beta::BetaBashCodeExecutionToolResultBlock::Content::Variants
21
+ )
22
+ end
23
+ attr_accessor :content
24
+
25
+ sig { returns(String) }
26
+ attr_accessor :tool_use_id
27
+
28
+ sig { returns(Symbol) }
29
+ attr_accessor :type
30
+
31
+ sig do
32
+ params(
33
+ content:
34
+ T.any(
35
+ Anthropic::Beta::BetaBashCodeExecutionToolResultError::OrHash,
36
+ Anthropic::Beta::BetaBashCodeExecutionResultBlock::OrHash
37
+ ),
38
+ tool_use_id: String,
39
+ type: Symbol
40
+ ).returns(T.attached_class)
41
+ end
42
+ def self.new(
43
+ content:,
44
+ tool_use_id:,
45
+ type: :bash_code_execution_tool_result
46
+ )
47
+ end
48
+
49
+ sig do
50
+ override.returns(
51
+ {
52
+ content:
53
+ Anthropic::Beta::BetaBashCodeExecutionToolResultBlock::Content::Variants,
54
+ tool_use_id: String,
55
+ type: Symbol
56
+ }
57
+ )
58
+ end
59
+ def to_hash
60
+ end
61
+
62
+ module Content
63
+ extend Anthropic::Internal::Type::Union
64
+
65
+ Variants =
66
+ T.type_alias do
67
+ T.any(
68
+ Anthropic::Beta::BetaBashCodeExecutionToolResultError,
69
+ Anthropic::Beta::BetaBashCodeExecutionResultBlock
70
+ )
71
+ end
72
+
73
+ sig do
74
+ override.returns(
75
+ T::Array[
76
+ Anthropic::Beta::BetaBashCodeExecutionToolResultBlock::Content::Variants
77
+ ]
78
+ )
79
+ end
80
+ def self.variants
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end