anthropic 1.7.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 (134) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -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/error_response.rb +7 -1
  53. data/lib/anthropic/models/message_count_tokens_params.rb +1 -24
  54. data/lib/anthropic/models/message_create_params.rb +1 -24
  55. data/lib/anthropic/models/messages/batch_create_params.rb +2 -28
  56. data/lib/anthropic/models/tool_use_block.rb +8 -0
  57. data/lib/anthropic/resources/beta/messages.rb +3 -3
  58. data/lib/anthropic/resources/messages.rb +85 -1
  59. data/lib/anthropic/version.rb +1 -1
  60. data/lib/anthropic.rb +29 -0
  61. data/rbi/anthropic/errors.rbi +2 -2
  62. data/rbi/anthropic/helpers/input_schema/array_of.rbi +16 -0
  63. data/rbi/anthropic/helpers/input_schema/base_model.rbi +21 -0
  64. data/rbi/anthropic/helpers/input_schema/boolean.rbi +11 -0
  65. data/rbi/anthropic/helpers/input_schema/enum_of.rbi +30 -0
  66. data/rbi/anthropic/helpers/input_schema/json_schema_converter.rbi +89 -0
  67. data/rbi/anthropic/helpers/input_schema/union_of.rbi +23 -0
  68. data/rbi/anthropic/helpers/structured_output.rbi +16 -0
  69. data/rbi/anthropic/input_schema.rbi +12 -0
  70. data/rbi/anthropic/models/beta/beta_bash_code_execution_output_block.rbi +33 -0
  71. data/rbi/anthropic/models/beta/beta_bash_code_execution_output_block_param.rbi +34 -0
  72. data/rbi/anthropic/models/beta/beta_bash_code_execution_result_block.rbi +72 -0
  73. data/rbi/anthropic/models/beta/beta_bash_code_execution_result_block_param.rbi +77 -0
  74. data/rbi/anthropic/models/beta/beta_bash_code_execution_tool_result_block.rbi +86 -0
  75. data/rbi/anthropic/models/beta/beta_bash_code_execution_tool_result_block_param.rbi +110 -0
  76. data/rbi/anthropic/models/beta/beta_bash_code_execution_tool_result_error.rbi +101 -0
  77. data/rbi/anthropic/models/beta/beta_bash_code_execution_tool_result_error_param.rbi +101 -0
  78. data/rbi/anthropic/models/beta/beta_code_execution_tool_20250825.rbi +72 -0
  79. data/rbi/anthropic/models/beta/beta_content_block.rbi +2 -0
  80. data/rbi/anthropic/models/beta/beta_content_block_param.rbi +2 -0
  81. data/rbi/anthropic/models/beta/beta_message.rbi +2 -0
  82. data/rbi/anthropic/models/beta/beta_raw_content_block_start_event.rbi +4 -0
  83. data/rbi/anthropic/models/beta/beta_server_tool_use_block.rbi +10 -0
  84. data/rbi/anthropic/models/beta/beta_server_tool_use_block_param.rbi +10 -0
  85. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_create_result_block.rbi +41 -0
  86. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_create_result_block_param.rbi +41 -0
  87. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_str_replace_result_block.rbi +73 -0
  88. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_str_replace_result_block_param.rbi +73 -0
  89. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_tool_result_block.rbi +90 -0
  90. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_tool_result_block_param.rbi +118 -0
  91. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_tool_result_error.rbi +110 -0
  92. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_tool_result_error_param.rbi +110 -0
  93. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_view_result_block.rbi +118 -0
  94. data/rbi/anthropic/models/beta/beta_text_editor_code_execution_view_result_block_param.rbi +118 -0
  95. data/rbi/anthropic/models/beta/beta_tool_union.rbi +1 -0
  96. data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +7 -48
  97. data/rbi/anthropic/models/beta/message_create_params.rbi +6 -48
  98. data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +6 -48
  99. data/rbi/anthropic/models/beta_error_response.rbi +10 -2
  100. data/rbi/anthropic/models/error_response.rbi +10 -2
  101. data/rbi/anthropic/models/message_count_tokens_params.rbi +2 -48
  102. data/rbi/anthropic/models/message_create_params.rbi +2 -48
  103. data/rbi/anthropic/models/messages/batch_create_params.rbi +2 -48
  104. data/rbi/anthropic/resources/beta/messages.rbi +6 -72
  105. data/rbi/anthropic/resources/messages.rbi +3 -72
  106. data/sig/anthropic/models/beta/beta_bash_code_execution_output_block.rbs +23 -0
  107. data/sig/anthropic/models/beta/beta_bash_code_execution_output_block_param.rbs +23 -0
  108. data/sig/anthropic/models/beta/beta_bash_code_execution_result_block.rbs +44 -0
  109. data/sig/anthropic/models/beta/beta_bash_code_execution_result_block_param.rbs +44 -0
  110. data/sig/anthropic/models/beta/beta_bash_code_execution_tool_result_block.rbs +44 -0
  111. data/sig/anthropic/models/beta/beta_bash_code_execution_tool_result_block_param.rbs +49 -0
  112. data/sig/anthropic/models/beta/beta_bash_code_execution_tool_result_error.rbs +48 -0
  113. data/sig/anthropic/models/beta/beta_bash_code_execution_tool_result_error_param.rbs +48 -0
  114. data/sig/anthropic/models/beta/beta_code_execution_tool_20250825.rbs +34 -0
  115. data/sig/anthropic/models/beta/beta_content_block.rbs +2 -0
  116. data/sig/anthropic/models/beta/beta_content_block_param.rbs +2 -0
  117. data/sig/anthropic/models/beta/beta_raw_content_block_start_event.rbs +2 -0
  118. data/sig/anthropic/models/beta/beta_server_tool_use_block.rbs +7 -1
  119. data/sig/anthropic/models/beta/beta_server_tool_use_block_param.rbs +7 -1
  120. data/sig/anthropic/models/beta/beta_text_editor_code_execution_create_result_block.rbs +29 -0
  121. data/sig/anthropic/models/beta/beta_text_editor_code_execution_create_result_block_param.rbs +29 -0
  122. data/sig/anthropic/models/beta/beta_text_editor_code_execution_str_replace_result_block.rbs +49 -0
  123. data/sig/anthropic/models/beta/beta_text_editor_code_execution_str_replace_result_block_param.rbs +49 -0
  124. data/sig/anthropic/models/beta/beta_text_editor_code_execution_tool_result_block.rbs +46 -0
  125. data/sig/anthropic/models/beta/beta_text_editor_code_execution_tool_result_block_param.rbs +51 -0
  126. data/sig/anthropic/models/beta/beta_text_editor_code_execution_tool_result_error.rbs +53 -0
  127. data/sig/anthropic/models/beta/beta_text_editor_code_execution_tool_result_error_param.rbs +53 -0
  128. data/sig/anthropic/models/beta/beta_text_editor_code_execution_view_result_block.rbs +61 -0
  129. data/sig/anthropic/models/beta/beta_text_editor_code_execution_view_result_block_param.rbs +61 -0
  130. data/sig/anthropic/models/beta/beta_tool_union.rbs +1 -0
  131. data/sig/anthropic/models/beta/message_count_tokens_params.rbs +1 -0
  132. data/sig/anthropic/models/beta_error_response.rbs +13 -2
  133. data/sig/anthropic/models/error_response.rbs +13 -2
  134. metadata +77 -2
@@ -80,30 +80,7 @@ module Anthropic
80
80
  # { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
81
81
  # ```
82
82
  #
83
- # Starting with Claude 3 models, you can also send image content blocks:
84
- #
85
- # ```json
86
- # {
87
- # "role": "user",
88
- # "content": [
89
- # {
90
- # "type": "image",
91
- # "source": {
92
- # "type": "base64",
93
- # "media_type": "image/jpeg",
94
- # "data": "/9j/4AAQSkZJRg..."
95
- # }
96
- # },
97
- # { "type": "text", "text": "What is in this image?" }
98
- # ]
99
- # }
100
- # ```
101
- #
102
- # We currently support the `base64` source type for images, and the `image/jpeg`,
103
- # `image/png`, `image/gif`, and `image/webp` media types.
104
- #
105
- # See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
106
- # more input examples.
83
+ # See [input examples](https://docs.anthropic.com/en/api/messages-examples).
107
84
  #
108
85
  # Note that if you want to include a
109
86
  # [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
@@ -287,7 +264,7 @@ module Anthropic
287
264
  #
288
265
  # See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
289
266
  #
290
- # @return [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305>, nil]
267
+ # @return [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaCodeExecutionTool20250825, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305>, nil]
291
268
  optional :tools, -> { Anthropic::Internal::Type::ArrayOf[union: Anthropic::Beta::BetaToolUnion] }
292
269
 
293
270
  # @!attribute top_k
@@ -350,7 +327,7 @@ module Anthropic
350
327
  #
351
328
  # @param tool_choice [Anthropic::Models::Beta::BetaToolChoiceAuto, Anthropic::Models::Beta::BetaToolChoiceAny, Anthropic::Models::Beta::BetaToolChoiceTool, Anthropic::Models::Beta::BetaToolChoiceNone] How the model should use the provided tools. The model can use a specific tool,
352
329
  #
353
- # @param tools [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305>] Definitions of tools that the model may use.
330
+ # @param tools [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaCodeExecutionTool20250825, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305>] Definitions of tools that the model may use.
354
331
  #
355
332
  # @param top_k [Integer] Only sample from the top K options for each subsequent token.
356
333
  #
@@ -15,9 +15,7 @@ module Anthropic
15
15
  #
16
16
  # @return [Array<Anthropic::Models::Beta::Messages::BatchCreateParams::Request>]
17
17
  required :requests,
18
- -> {
19
- Anthropic::Internal::Type::ArrayOf[Anthropic::Beta::Messages::BatchCreateParams::Request]
20
- }
18
+ -> { Anthropic::Internal::Type::ArrayOf[Anthropic::Beta::Messages::BatchCreateParams::Request] }
21
19
 
22
20
  # @!attribute betas
23
21
  # Optional header to specify the beta version(s) you want to use.
@@ -135,30 +133,7 @@ module Anthropic
135
133
  # { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
136
134
  # ```
137
135
  #
138
- # Starting with Claude 3 models, you can also send image content blocks:
139
- #
140
- # ```json
141
- # {
142
- # "role": "user",
143
- # "content": [
144
- # {
145
- # "type": "image",
146
- # "source": {
147
- # "type": "base64",
148
- # "media_type": "image/jpeg",
149
- # "data": "/9j/4AAQSkZJRg..."
150
- # }
151
- # },
152
- # { "type": "text", "text": "What is in this image?" }
153
- # ]
154
- # }
155
- # ```
156
- #
157
- # We currently support the `base64` source type for images, and the `image/jpeg`,
158
- # `image/png`, `image/gif`, and `image/webp` media types.
159
- #
160
- # See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
161
- # more input examples.
136
+ # See [input examples](https://docs.anthropic.com/en/api/messages-examples).
162
137
  #
163
138
  # Note that if you want to include a
164
139
  # [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
@@ -189,9 +164,7 @@ module Anthropic
189
164
  #
190
165
  # @return [Array<Anthropic::Models::Beta::BetaRequestMCPServerURLDefinition>, nil]
191
166
  optional :mcp_servers,
192
- -> {
193
- Anthropic::Internal::Type::ArrayOf[Anthropic::Beta::BetaRequestMCPServerURLDefinition]
194
- }
167
+ -> { Anthropic::Internal::Type::ArrayOf[Anthropic::Beta::BetaRequestMCPServerURLDefinition] }
195
168
 
196
169
  # @!attribute metadata
197
170
  # An object describing metadata about the request.
@@ -356,11 +329,8 @@ module Anthropic
356
329
  #
357
330
  # See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
358
331
  #
359
- # @return [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305>, nil]
360
- optional :tools,
361
- -> {
362
- Anthropic::Internal::Type::ArrayOf[union: Anthropic::Beta::BetaToolUnion]
363
- }
332
+ # @return [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaCodeExecutionTool20250825, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305>, nil]
333
+ optional :tools, -> { Anthropic::Internal::Type::ArrayOf[union: Anthropic::Beta::BetaToolUnion] }
364
334
 
365
335
  # @!attribute top_k
366
336
  # Only sample from the top K options for each subsequent token.
@@ -424,7 +394,7 @@ module Anthropic
424
394
  #
425
395
  # @param tool_choice [Anthropic::Models::Beta::BetaToolChoiceAuto, Anthropic::Models::Beta::BetaToolChoiceAny, Anthropic::Models::Beta::BetaToolChoiceTool, Anthropic::Models::Beta::BetaToolChoiceNone] How the model should use the provided tools. The model can use a specific tool,
426
396
  #
427
- # @param tools [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305>] Definitions of tools that the model may use.
397
+ # @param tools [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaCodeExecutionTool20250825, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305>] Definitions of tools that the model may use.
428
398
  #
429
399
  # @param top_k [Integer] Only sample from the top K options for each subsequent token.
430
400
  #
@@ -56,10 +56,7 @@ module Anthropic
56
56
  # Processing status of the Message Batch.
57
57
  #
58
58
  # @return [Symbol, Anthropic::Models::Beta::Messages::BetaMessageBatch::ProcessingStatus]
59
- required :processing_status,
60
- enum: -> {
61
- Anthropic::Beta::Messages::BetaMessageBatch::ProcessingStatus
62
- }
59
+ required :processing_status, enum: -> { Anthropic::Beta::Messages::BetaMessageBatch::ProcessingStatus }
63
60
 
64
61
  # @!attribute request_counts
65
62
  # Tallies requests within the Message Batch, categorized by their status.
@@ -8,13 +8,19 @@ module Anthropic
8
8
  # @return [Anthropic::Models::BetaInvalidRequestError, Anthropic::Models::BetaAuthenticationError, Anthropic::Models::BetaBillingError, Anthropic::Models::BetaPermissionError, Anthropic::Models::BetaNotFoundError, Anthropic::Models::BetaRateLimitError, Anthropic::Models::BetaGatewayTimeoutError, Anthropic::Models::BetaAPIError, Anthropic::Models::BetaOverloadedError]
9
9
  required :error, union: -> { Anthropic::BetaError }
10
10
 
11
+ # @!attribute request_id
12
+ #
13
+ # @return [String, nil]
14
+ required :request_id, String, nil?: true
15
+
11
16
  # @!attribute type
12
17
  #
13
18
  # @return [Symbol, :error]
14
19
  required :type, const: :error
15
20
 
16
- # @!method initialize(error:, type: :error)
21
+ # @!method initialize(error:, request_id:, type: :error)
17
22
  # @param error [Anthropic::Models::BetaInvalidRequestError, Anthropic::Models::BetaAuthenticationError, Anthropic::Models::BetaBillingError, Anthropic::Models::BetaPermissionError, Anthropic::Models::BetaNotFoundError, Anthropic::Models::BetaRateLimitError, Anthropic::Models::BetaGatewayTimeoutError, Anthropic::Models::BetaAPIError, Anthropic::Models::BetaOverloadedError]
23
+ # @param request_id [String, nil]
18
24
  # @param type [Symbol, :error]
19
25
  end
20
26
  end
@@ -8,13 +8,19 @@ module Anthropic
8
8
  # @return [Anthropic::Models::InvalidRequestError, Anthropic::Models::AuthenticationError, Anthropic::Models::BillingError, Anthropic::Models::PermissionError, Anthropic::Models::NotFoundError, Anthropic::Models::RateLimitError, Anthropic::Models::GatewayTimeoutError, Anthropic::Models::APIErrorObject, Anthropic::Models::OverloadedError]
9
9
  required :error, union: -> { Anthropic::ErrorObject }
10
10
 
11
+ # @!attribute request_id
12
+ #
13
+ # @return [String, nil]
14
+ required :request_id, String, nil?: true
15
+
11
16
  # @!attribute type
12
17
  #
13
18
  # @return [Symbol, :error]
14
19
  required :type, const: :error
15
20
 
16
- # @!method initialize(error:, type: :error)
21
+ # @!method initialize(error:, request_id:, type: :error)
17
22
  # @param error [Anthropic::Models::InvalidRequestError, Anthropic::Models::AuthenticationError, Anthropic::Models::BillingError, Anthropic::Models::PermissionError, Anthropic::Models::NotFoundError, Anthropic::Models::RateLimitError, Anthropic::Models::GatewayTimeoutError, Anthropic::Models::APIErrorObject, Anthropic::Models::OverloadedError]
23
+ # @param request_id [String, nil]
18
24
  # @param type [Symbol, :error]
19
25
  end
20
26
  end
@@ -65,30 +65,7 @@ module Anthropic
65
65
  # { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
66
66
  # ```
67
67
  #
68
- # Starting with Claude 3 models, you can also send image content blocks:
69
- #
70
- # ```json
71
- # {
72
- # "role": "user",
73
- # "content": [
74
- # {
75
- # "type": "image",
76
- # "source": {
77
- # "type": "base64",
78
- # "media_type": "image/jpeg",
79
- # "data": "/9j/4AAQSkZJRg..."
80
- # }
81
- # },
82
- # { "type": "text", "text": "What is in this image?" }
83
- # ]
84
- # }
85
- # ```
86
- #
87
- # We currently support the `base64` source type for images, and the `image/jpeg`,
88
- # `image/png`, `image/gif`, and `image/webp` media types.
89
- #
90
- # See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
91
- # more input examples.
68
+ # See [input examples](https://docs.anthropic.com/en/api/messages-examples).
92
69
  #
93
70
  # Note that if you want to include a
94
71
  # [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
@@ -79,30 +79,7 @@ module Anthropic
79
79
  # { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
80
80
  # ```
81
81
  #
82
- # Starting with Claude 3 models, you can also send image content blocks:
83
- #
84
- # ```json
85
- # {
86
- # "role": "user",
87
- # "content": [
88
- # {
89
- # "type": "image",
90
- # "source": {
91
- # "type": "base64",
92
- # "media_type": "image/jpeg",
93
- # "data": "/9j/4AAQSkZJRg..."
94
- # }
95
- # },
96
- # { "type": "text", "text": "What is in this image?" }
97
- # ]
98
- # }
99
- # ```
100
- #
101
- # We currently support the `base64` source type for images, and the `image/jpeg`,
102
- # `image/png`, `image/gif`, and `image/webp` media types.
103
- #
104
- # See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
105
- # more input examples.
82
+ # See [input examples](https://docs.anthropic.com/en/api/messages-examples).
106
83
  #
107
84
  # Note that if you want to include a
108
85
  # [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
@@ -123,30 +123,7 @@ module Anthropic
123
123
  # { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
124
124
  # ```
125
125
  #
126
- # Starting with Claude 3 models, you can also send image content blocks:
127
- #
128
- # ```json
129
- # {
130
- # "role": "user",
131
- # "content": [
132
- # {
133
- # "type": "image",
134
- # "source": {
135
- # "type": "base64",
136
- # "media_type": "image/jpeg",
137
- # "data": "/9j/4AAQSkZJRg..."
138
- # }
139
- # },
140
- # { "type": "text", "text": "What is in this image?" }
141
- # ]
142
- # }
143
- # ```
144
- #
145
- # We currently support the `base64` source type for images, and the `image/jpeg`,
146
- # `image/png`, `image/gif`, and `image/webp` media types.
147
- #
148
- # See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
149
- # more input examples.
126
+ # See [input examples](https://docs.anthropic.com/en/api/messages-examples).
150
127
  #
151
128
  # Note that if you want to include a
152
129
  # [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
@@ -180,10 +157,7 @@ module Anthropic
180
157
  # [service-tiers](https://docs.anthropic.com/en/api/service-tiers) for details.
181
158
  #
182
159
  # @return [Symbol, Anthropic::Models::Messages::BatchCreateParams::Request::Params::ServiceTier, nil]
183
- optional :service_tier,
184
- enum: -> {
185
- Anthropic::Messages::BatchCreateParams::Request::Params::ServiceTier
186
- }
160
+ optional :service_tier, enum: -> { Anthropic::Messages::BatchCreateParams::Request::Params::ServiceTier }
187
161
 
188
162
  # @!attribute stop_sequences
189
163
  # Custom text sequences that will cause the model to stop generating.
@@ -29,6 +29,14 @@ module Anthropic
29
29
  # Used by streaming helpers to reconstruct complete JSON input from deltas.
30
30
  optional :json_buf, String
31
31
 
32
+ response_only do
33
+ # @api public
34
+ #
35
+ # Parsed input data coerced to the tool's input schema model.
36
+ # Only present when tools are defined using the InputSchema DSL.
37
+ optional :parsed, Anthropic::Internal::Type::Unknown
38
+ end
39
+
32
40
  # @!method initialize(id:, input:, name:, type: :tool_use)
33
41
  # @param id [String]
34
42
  # @param input [Object]
@@ -46,7 +46,7 @@ module Anthropic
46
46
  #
47
47
  # @param tool_choice [Anthropic::Models::Beta::BetaToolChoiceAuto, Anthropic::Models::Beta::BetaToolChoiceAny, Anthropic::Models::Beta::BetaToolChoiceTool, Anthropic::Models::Beta::BetaToolChoiceNone] Body param: How the model should use the provided tools. The model can use a spe
48
48
  #
49
- # @param tools [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305>] Body param: Definitions of tools that the model may use.
49
+ # @param tools [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaCodeExecutionTool20250825, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305>] Body param: Definitions of tools that the model may use.
50
50
  #
51
51
  # @param top_k [Integer] Body param: Only sample from the top K options for each subsequent token.
52
52
  #
@@ -128,7 +128,7 @@ module Anthropic
128
128
  #
129
129
  # @param tool_choice [Anthropic::Models::Beta::BetaToolChoiceAuto, Anthropic::Models::Beta::BetaToolChoiceAny, Anthropic::Models::Beta::BetaToolChoiceTool, Anthropic::Models::Beta::BetaToolChoiceNone] Body param: How the model should use the provided tools. The model can use a spe
130
130
  #
131
- # @param tools [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305>] Body param: Definitions of tools that the model may use.
131
+ # @param tools [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaCodeExecutionTool20250825, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305>] Body param: Definitions of tools that the model may use.
132
132
  #
133
133
  # @param top_k [Integer] Body param: Only sample from the top K options for each subsequent token.
134
134
  #
@@ -259,7 +259,7 @@ module Anthropic
259
259
  #
260
260
  # @param tool_choice [Anthropic::Models::Beta::BetaToolChoiceAuto, Anthropic::Models::Beta::BetaToolChoiceAny, Anthropic::Models::Beta::BetaToolChoiceTool, Anthropic::Models::Beta::BetaToolChoiceNone] Body param: How the model should use the provided tools. The model can use a spe
261
261
  #
262
- # @param tools [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305>] Body param: Definitions of tools that the model may use.
262
+ # @param tools [Array<Anthropic::Models::Beta::BetaTool, Anthropic::Models::Beta::BetaToolBash20241022, Anthropic::Models::Beta::BetaToolBash20250124, Anthropic::Models::Beta::BetaCodeExecutionTool20250522, Anthropic::Models::Beta::BetaCodeExecutionTool20250825, Anthropic::Models::Beta::BetaToolComputerUse20241022, Anthropic::Models::Beta::BetaToolComputerUse20250124, Anthropic::Models::Beta::BetaToolTextEditor20241022, Anthropic::Models::Beta::BetaToolTextEditor20250124, Anthropic::Models::Beta::BetaToolTextEditor20250429, Anthropic::Models::Beta::BetaToolTextEditor20250728, Anthropic::Models::Beta::BetaWebSearchTool20250305>] Body param: Definitions of tools that the model may use.
263
263
  #
264
264
  # @param betas [Array<String, Symbol, Anthropic::Models::AnthropicBeta>] Header param: Optional header to specify the beta version(s) you want to use.
265
265
  #
@@ -59,6 +59,12 @@ module Anthropic
59
59
  raise ArgumentError.new(message)
60
60
  end
61
61
 
62
+ tool_models = get_structured_output_models(parsed)
63
+
64
+ unwrap = if tool_models.any?
65
+ ->(raw) { parse_structured_outputs!(raw, tool_models) }
66
+ end
67
+
62
68
  if options.empty? && @client.timeout == Anthropic::Client::DEFAULT_TIMEOUT_IN_SECONDS
63
69
  model = parsed[:model].to_sym
64
70
  max_tokens = parsed[:max_tokens].to_i
@@ -76,6 +82,7 @@ module Anthropic
76
82
  path: "v1/messages",
77
83
  body: parsed,
78
84
  model: Anthropic::Message,
85
+ unwrap: unwrap,
79
86
  options: options
80
87
  )
81
88
  end
@@ -133,6 +140,9 @@ module Anthropic
133
140
  raise ArgumentError.new(message)
134
141
  end
135
142
  parsed.store(:stream, true)
143
+
144
+ tool_models = get_structured_output_models(parsed)
145
+
136
146
  raw_stream = @client.request(
137
147
  method: :post,
138
148
  path: "v1/messages",
@@ -142,7 +152,10 @@ module Anthropic
142
152
  model: Anthropic::Models::RawMessageStreamEvent,
143
153
  options: options
144
154
  )
145
- Anthropic::Streaming::MessageStream.new(raw_stream: raw_stream)
155
+ Anthropic::Streaming::MessageStream.new(
156
+ raw_stream: raw_stream,
157
+ tool_models: tool_models
158
+ )
146
159
  end
147
160
 
148
161
  # See {Anthropic::Resources::Messages#create} for non-streaming counterpart.
@@ -257,6 +270,77 @@ module Anthropic
257
270
  @client = client
258
271
  @batches = Anthropic::Resources::Messages::Batches.new(client: client)
259
272
  end
273
+
274
+ private
275
+
276
+ # Extract tool models from the request and convert them to JSON Schema
277
+ # Returns a hash mapping tool name to Ruby model.
278
+ def get_structured_output_models(parsed)
279
+ tool_models = {}
280
+
281
+ case parsed
282
+ in {tools: Array => tools}
283
+ mapped = tools.map do |tool|
284
+ case tool
285
+ # Direct tool class:
286
+ in Anthropic::Helpers::InputSchema::JsonSchemaConverter
287
+ name = tool.name.split("::").last
288
+ description = extract_class_description(tool)
289
+ tool_models.store(name, tool)
290
+ {
291
+ name: name,
292
+ description: description,
293
+ input_schema: tool.to_json_schema
294
+ }
295
+ # Tool with explicit name/description and BaseModel as input_schema:
296
+ in {name: String => name,
297
+ input_schema: Anthropic::Helpers::InputSchema::JsonSchemaConverter => model,
298
+ **rest}
299
+ tool_models.store(name, model)
300
+ rest.merge(
301
+ name: name,
302
+ input_schema: model.to_json_schema
303
+ )
304
+ else
305
+ # Any other format (pass through unchanged)
306
+ # This includes raw JSON schemas and any other tool definitions.
307
+ tool
308
+ end
309
+ end
310
+ tools.replace(mapped)
311
+ else
312
+ end
313
+
314
+ tool_models
315
+ end
316
+
317
+ # Extract class description from a BaseModel class
318
+ def extract_class_description(klass)
319
+ klass.respond_to?(:doc_string) ? klass.doc_string : nil
320
+ end
321
+
322
+ def parse_structured_outputs!(raw, tool_models)
323
+ return raw if tool_models.empty?
324
+
325
+ raw[:content]&.each do |content|
326
+ next unless content[:type] == "tool_use"
327
+
328
+ model = tool_models[content[:name]]
329
+ next unless model
330
+
331
+ begin
332
+ parsed_input = content[:input]
333
+
334
+ coerced = Anthropic::Internal::Type::Converter.coerce(model, parsed_input)
335
+
336
+ content.store(:parsed, coerced)
337
+ rescue StandardError => e
338
+ content.store(:parsed, {error: e.message})
339
+ end
340
+ end
341
+
342
+ raw
343
+ end
260
344
  end
261
345
  end
262
346
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Anthropic
4
- VERSION = "1.7.0"
4
+ VERSION = "1.8.0"
5
5
  end
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"
@@ -339,3 +358,13 @@ require_relative "anthropic/resources/completions"
339
358
  require_relative "anthropic/resources/messages"
340
359
  require_relative "anthropic/resources/messages/batches"
341
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