anthropic 1.16.3 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +37 -0
- data/README.md +38 -10
- data/lib/anthropic/helpers/messages.rb +86 -1
- data/lib/anthropic/helpers/streaming/events.rb +13 -0
- data/lib/anthropic/helpers/streaming/message_stream.rb +65 -29
- data/lib/anthropic/internal/transport/pooled_net_requester.rb +1 -1
- data/lib/anthropic/models/beta/beta_code_execution_tool_20250522.rb +2 -1
- data/lib/anthropic/models/beta/beta_code_execution_tool_20250825.rb +2 -1
- data/lib/anthropic/models/beta/beta_compact_20260112_edit.rb +46 -0
- data/lib/anthropic/models/beta/beta_compaction_block.rb +33 -0
- data/lib/anthropic/models/beta/beta_compaction_block_param.rb +43 -0
- data/lib/anthropic/models/beta/beta_compaction_content_block_delta.rb +25 -0
- data/lib/anthropic/models/beta/beta_compaction_iteration_usage.rb +62 -0
- data/lib/anthropic/models/beta/beta_content_block.rb +8 -1
- data/lib/anthropic/models/beta/beta_content_block_param.rb +10 -1
- data/lib/anthropic/models/beta/beta_context_management_config.rb +8 -3
- data/lib/anthropic/models/beta/beta_iterations_usage.rb +28 -0
- data/lib/anthropic/models/beta/beta_memory_tool_20250818.rb +2 -1
- data/lib/anthropic/models/beta/beta_message.rb +2 -2
- data/lib/anthropic/models/beta/beta_message_delta_usage.rb +21 -1
- data/lib/anthropic/models/beta/beta_message_iteration_usage.rb +62 -0
- data/lib/anthropic/models/beta/beta_message_param.rb +3 -3
- data/lib/anthropic/models/beta/beta_output_config.rb +14 -1
- data/lib/anthropic/models/beta/beta_raw_content_block_delta.rb +3 -1
- data/lib/anthropic/models/beta/beta_raw_content_block_delta_event.rb +2 -2
- data/lib/anthropic/models/beta/beta_raw_content_block_start_event.rb +10 -3
- data/lib/anthropic/models/beta/beta_server_tool_use_block.rb +25 -25
- data/lib/anthropic/models/beta/beta_stop_reason.rb +1 -0
- data/lib/anthropic/models/beta/beta_thinking_config_adaptive.rb +19 -0
- data/lib/anthropic/models/beta/beta_thinking_config_param.rb +3 -1
- data/lib/anthropic/models/beta/beta_tool.rb +15 -2
- data/lib/anthropic/models/beta/beta_tool_bash_20241022.rb +2 -1
- data/lib/anthropic/models/beta/beta_tool_bash_20250124.rb +2 -1
- data/lib/anthropic/models/beta/beta_tool_computer_use_20241022.rb +2 -1
- data/lib/anthropic/models/beta/beta_tool_computer_use_20250124.rb +2 -1
- data/lib/anthropic/models/beta/beta_tool_computer_use_20251124.rb +2 -1
- data/lib/anthropic/models/beta/beta_tool_search_tool_bm25_20251119.rb +2 -1
- data/lib/anthropic/models/beta/beta_tool_search_tool_regex_20251119.rb +2 -1
- data/lib/anthropic/models/beta/beta_tool_text_editor_20241022.rb +2 -1
- data/lib/anthropic/models/beta/beta_tool_text_editor_20250124.rb +2 -1
- data/lib/anthropic/models/beta/beta_tool_text_editor_20250429.rb +2 -1
- data/lib/anthropic/models/beta/beta_tool_text_editor_20250728.rb +2 -1
- data/lib/anthropic/models/beta/beta_usage.rb +29 -1
- data/lib/anthropic/models/beta/beta_web_fetch_tool_20250910.rb +2 -1
- data/lib/anthropic/models/beta/beta_web_search_tool_20250305.rb +2 -1
- data/lib/anthropic/models/beta/beta_web_search_tool_result_error_code.rb +1 -0
- data/lib/anthropic/models/beta/message_count_tokens_params.rb +12 -7
- data/lib/anthropic/models/beta/message_create_params.rb +22 -8
- data/lib/anthropic/models/beta/messages/batch_create_params.rb +22 -8
- data/lib/anthropic/models/json_output_format.rb +23 -0
- data/lib/anthropic/models/message.rb +12 -0
- data/lib/anthropic/models/message_count_tokens_params.rb +11 -3
- data/lib/anthropic/models/message_create_params.rb +20 -3
- data/lib/anthropic/models/messages/batch_create_params.rb +20 -3
- data/lib/anthropic/models/model.rb +11 -0
- data/lib/anthropic/models/output_config.rb +43 -0
- data/lib/anthropic/models/text_block.rb +8 -0
- data/lib/anthropic/models/thinking_config_adaptive.rb +15 -0
- data/lib/anthropic/models/thinking_config_param.rb +3 -1
- data/lib/anthropic/models/tool.rb +21 -1
- data/lib/anthropic/models/tool_bash_20250124.rb +9 -1
- data/lib/anthropic/models/tool_text_editor_20250124.rb +9 -1
- data/lib/anthropic/models/tool_text_editor_20250429.rb +9 -1
- data/lib/anthropic/models/tool_text_editor_20250728.rb +9 -1
- data/lib/anthropic/models/usage.rb +9 -1
- data/lib/anthropic/models/web_search_tool_20250305.rb +9 -1
- data/lib/anthropic/models/web_search_tool_request_error.rb +1 -0
- data/lib/anthropic/models/web_search_tool_result_error.rb +1 -0
- data/lib/anthropic/models.rb +6 -0
- data/lib/anthropic/resources/beta/messages.rb +56 -19
- data/lib/anthropic/resources/messages.rb +40 -7
- data/lib/anthropic/version.rb +1 -1
- data/lib/anthropic.rb +11 -0
- data/rbi/anthropic/models/beta/beta_code_execution_tool_20250522.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_code_execution_tool_20250825.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_compact_20260112_edit.rbi +78 -0
- data/rbi/anthropic/models/beta/beta_compaction_block.rbi +47 -0
- data/rbi/anthropic/models/beta/beta_compaction_block_param.rbi +75 -0
- data/rbi/anthropic/models/beta/beta_compaction_content_block_delta.rbi +37 -0
- data/rbi/anthropic/models/beta/beta_compaction_iteration_usage.rbi +94 -0
- data/rbi/anthropic/models/beta/beta_content_block.rbi +2 -1
- data/rbi/anthropic/models/beta/beta_content_block_param.rbi +2 -1
- data/rbi/anthropic/models/beta/beta_context_management_config.rbi +12 -5
- data/rbi/anthropic/models/beta/beta_iterations_usage.rbi +39 -0
- data/rbi/anthropic/models/beta/beta_memory_tool_20250818.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_message.rbi +2 -1
- data/rbi/anthropic/models/beta/beta_message_delta_usage.rbi +39 -0
- data/rbi/anthropic/models/beta/beta_message_iteration_usage.rbi +94 -0
- data/rbi/anthropic/models/beta/beta_output_config.rbi +22 -3
- data/rbi/anthropic/models/beta/beta_raw_content_block_delta.rbi +2 -1
- data/rbi/anthropic/models/beta/beta_raw_content_block_delta_event.rbi +2 -1
- data/rbi/anthropic/models/beta/beta_raw_content_block_start_event.rbi +4 -2
- data/rbi/anthropic/models/beta/beta_server_tool_use_block.rbi +48 -36
- data/rbi/anthropic/models/beta/beta_stop_reason.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_thinking_config_adaptive.rbi +30 -0
- data/rbi/anthropic/models/beta/beta_thinking_config_param.rbi +2 -1
- data/rbi/anthropic/models/beta/beta_tool.rbi +18 -0
- data/rbi/anthropic/models/beta/beta_tool_bash_20241022.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_tool_bash_20250124.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_tool_computer_use_20241022.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_tool_computer_use_20250124.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_tool_computer_use_20251124.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_tool_search_tool_bm25_20251119.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_tool_search_tool_regex_20251119.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_tool_text_editor_20241022.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_tool_text_editor_20250124.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_tool_text_editor_20250429.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_tool_text_editor_20250728.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_usage.rbi +47 -0
- data/rbi/anthropic/models/beta/beta_web_fetch_tool_20250910.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_web_search_tool_20250305.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_web_search_tool_result_error_code.rbi +5 -0
- data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +20 -10
- data/rbi/anthropic/models/beta/message_create_params.rbi +30 -10
- data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +30 -10
- data/rbi/anthropic/models/json_output_format.rbi +37 -0
- data/rbi/anthropic/models/message.rbi +5 -0
- data/rbi/anthropic/models/message_count_tokens_params.rbi +19 -4
- data/rbi/anthropic/models/message_create_params.rbi +29 -4
- data/rbi/anthropic/models/messages/batch_create_params.rbi +29 -4
- data/rbi/anthropic/models/model.rbi +4 -0
- data/rbi/anthropic/models/output_config.rbi +74 -0
- data/rbi/anthropic/models/thinking_config_adaptive.rbi +23 -0
- data/rbi/anthropic/models/thinking_config_param.rbi +2 -1
- data/rbi/anthropic/models/tool.rbi +27 -0
- data/rbi/anthropic/models/tool_bash_20250124.rbi +12 -1
- data/rbi/anthropic/models/tool_text_editor_20250124.rbi +12 -1
- data/rbi/anthropic/models/tool_text_editor_20250429.rbi +12 -1
- data/rbi/anthropic/models/tool_text_editor_20250728.rbi +12 -1
- data/rbi/anthropic/models/usage.rbi +8 -0
- data/rbi/anthropic/models/web_search_tool_20250305.rbi +11 -0
- data/rbi/anthropic/models/web_search_tool_request_error.rbi +5 -0
- data/rbi/anthropic/models/web_search_tool_result_error.rbi +5 -0
- data/rbi/anthropic/models.rbi +6 -0
- data/rbi/anthropic/resources/beta/messages.rbi +35 -12
- data/rbi/anthropic/resources/messages.rbi +23 -3
- data/sig/anthropic/models/beta/beta_compact_20260112_edit.rbs +41 -0
- data/sig/anthropic/models/beta/beta_compaction_block.rbs +19 -0
- data/sig/anthropic/models/beta/beta_compaction_block_param.rbs +34 -0
- data/sig/anthropic/models/beta/beta_compaction_content_block_delta.rbs +20 -0
- data/sig/anthropic/models/beta/beta_compaction_iteration_usage.rbs +49 -0
- data/sig/anthropic/models/beta/beta_content_block.rbs +1 -0
- data/sig/anthropic/models/beta/beta_content_block_param.rbs +1 -0
- data/sig/anthropic/models/beta/beta_context_management_config.rbs +1 -0
- data/sig/anthropic/models/beta/beta_iterations_usage.rbs +22 -0
- data/sig/anthropic/models/beta/beta_message_delta_usage.rbs +5 -0
- data/sig/anthropic/models/beta/beta_message_iteration_usage.rbs +49 -0
- data/sig/anthropic/models/beta/beta_output_config.rbs +12 -4
- data/sig/anthropic/models/beta/beta_raw_content_block_delta.rbs +1 -0
- data/sig/anthropic/models/beta/beta_raw_content_block_start_event.rbs +1 -0
- data/sig/anthropic/models/beta/beta_server_tool_use_block.rbs +21 -17
- data/sig/anthropic/models/beta/beta_stop_reason.rbs +2 -0
- data/sig/anthropic/models/beta/beta_thinking_config_adaptive.rbs +17 -0
- data/sig/anthropic/models/beta/beta_thinking_config_param.rbs +1 -0
- data/sig/anthropic/models/beta/beta_tool.rbs +5 -0
- data/sig/anthropic/models/beta/beta_usage.rbs +10 -0
- data/sig/anthropic/models/beta/beta_web_search_tool_result_error_code.rbs +2 -0
- data/sig/anthropic/models/beta/message_create_params.rbs +5 -0
- data/sig/anthropic/models/beta/messages/batch_create_params.rbs +5 -0
- data/sig/anthropic/models/json_output_format.rbs +16 -0
- data/sig/anthropic/models/message_count_tokens_params.rbs +7 -0
- data/sig/anthropic/models/message_create_params.rbs +12 -0
- data/sig/anthropic/models/messages/batch_create_params.rbs +14 -0
- data/sig/anthropic/models/model.rbs +5 -1
- data/sig/anthropic/models/output_config.rbs +38 -0
- data/sig/anthropic/models/thinking_config_adaptive.rbs +13 -0
- data/sig/anthropic/models/thinking_config_param.rbs +3 -1
- data/sig/anthropic/models/tool.rbs +12 -0
- data/sig/anthropic/models/tool_bash_20250124.rbs +9 -2
- data/sig/anthropic/models/tool_text_editor_20250124.rbs +9 -2
- data/sig/anthropic/models/tool_text_editor_20250429.rbs +9 -2
- data/sig/anthropic/models/tool_text_editor_20250728.rbs +9 -2
- data/sig/anthropic/models/usage.rbs +5 -0
- data/sig/anthropic/models/web_search_tool_20250305.rbs +7 -0
- data/sig/anthropic/models/web_search_tool_request_error.rbs +2 -0
- data/sig/anthropic/models/web_search_tool_result_error.rbs +2 -0
- data/sig/anthropic/models.rbs +6 -0
- data/sig/anthropic/resources/beta/messages.rbs +2 -0
- data/sig/anthropic/resources/messages.rbs +5 -0
- metadata +49 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aa12265ad752f381a43cc10fd241f157049b40a092f8792f58c942d1d2523aeb
|
|
4
|
+
data.tar.gz: c3f5c151995f28bfca102ac4dca98e33c3f1144c6c2d9a20a864d092a1fb2304
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b155c6a753280b3219a33514bec5698ea303fd35e9d37166ca8de2af27d0708468f2c944100684e3fe56b6415e24d9ad279e5f2c8a1abadcb5c3fc793fc5b94d
|
|
7
|
+
data.tar.gz: 3be747abe016c87882b22921c29704e3b2808e18a6aaec060388414cd209f8b5a610c81024807c419a2942e5a56bfe31026d6da2b4f34dec2043a9349e95166d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.18.0 (2026-02-05)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v1.17.0...v1.18.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.17.0...v1.18.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** manual updates ([53027e2](https://github.com/anthropics/anthropic-sdk-ruby/commit/53027e2d56db596ca8a42558d848ebd22075a854))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **client:** always add content-length to post body, even when empty ([359dcee](https://github.com/anthropics/anthropic-sdk-ruby/commit/359dcee68a26733fe1ee884a393aed88fd28b05b))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Chores
|
|
18
|
+
|
|
19
|
+
* **ci:** remove claude-code-review workflow ([4d513ef](https://github.com/anthropics/anthropic-sdk-ruby/commit/4d513efcb8d074bd70efc4513bdcc5a0872e7171))
|
|
20
|
+
* **docs:** remove www prefix ([306cdf9](https://github.com/anthropics/anthropic-sdk-ruby/commit/306cdf9962dba36b35a83eaaa7e5be166fc5a35f))
|
|
21
|
+
|
|
22
|
+
## 1.17.0 (2026-01-29)
|
|
23
|
+
|
|
24
|
+
Full Changelog: [v1.16.3...v1.17.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.16.3...v1.17.0)
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
* **api:** add support for Structured Outputs in the Messages API ([06e1fd9](https://github.com/anthropics/anthropic-sdk-ruby/commit/06e1fd93f073462f887a933af1dbca17138980c7))
|
|
29
|
+
* **api:** migrate sending message format in output_config rather than output_format ([13ac36e](https://github.com/anthropics/anthropic-sdk-ruby/commit/13ac36e97e8898d46b802c540b7dba7272247108))
|
|
30
|
+
* **client:** migrate output config ([#784](https://github.com/anthropics/anthropic-sdk-ruby/issues/784)) ([d055b2b](https://github.com/anthropics/anthropic-sdk-ruby/commit/d055b2b172ad951cf6b20bea709c8bd3b4f345c6))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Chores
|
|
34
|
+
|
|
35
|
+
* add cgi gem as explicit dependency ([b9ef072](https://github.com/anthropics/anthropic-sdk-ruby/commit/b9ef072be4d8ecd4f12e90403183b0ced5cb360f))
|
|
36
|
+
* **client:** mark claude-3-5-haiku as deprecated ([2ed73fd](https://github.com/anthropics/anthropic-sdk-ruby/commit/2ed73fde07fa480ff55d67b47442deebb76bc1e5))
|
|
37
|
+
* **internal:** update `actions/checkout` version ([2f82126](https://github.com/anthropics/anthropic-sdk-ruby/commit/2f8212603e7a6b7a96afaa3cfd19a55a0853f49c))
|
|
38
|
+
* **internal:** use different example values for some enums ([13d8b68](https://github.com/anthropics/anthropic-sdk-ruby/commit/13d8b68d290c11497faed22e2eda1778187bf2ec))
|
|
39
|
+
|
|
3
40
|
## 1.16.3 (2026-01-05)
|
|
4
41
|
|
|
5
42
|
Full Changelog: [v1.16.2...v1.16.3](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.16.2...v1.16.3)
|
data/README.md
CHANGED
|
@@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
|
|
|
15
15
|
<!-- x-release-please-start-version -->
|
|
16
16
|
|
|
17
17
|
```ruby
|
|
18
|
-
gem "anthropic", "~> 1.
|
|
18
|
+
gem "anthropic", "~> 1.18.0"
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
<!-- x-release-please-end -->
|
|
@@ -39,7 +39,7 @@ anthropic = Anthropic::Client.new(
|
|
|
39
39
|
message = anthropic.messages.create(
|
|
40
40
|
max_tokens: 1024,
|
|
41
41
|
messages: [{role: "user", content: "Hello, Claude"}],
|
|
42
|
-
model:
|
|
42
|
+
model: "claude-sonnet-4-5-20250929"
|
|
43
43
|
)
|
|
44
44
|
|
|
45
45
|
puts(message.content)
|
|
@@ -53,7 +53,7 @@ We provide support for streaming responses using Server-Sent Events (SSE).
|
|
|
53
53
|
stream = anthropic.messages.stream(
|
|
54
54
|
max_tokens: 1024,
|
|
55
55
|
messages: [{role: "user", content: "Hello, Claude"}],
|
|
56
|
-
model:
|
|
56
|
+
model: "claude-sonnet-4-5-20250929"
|
|
57
57
|
)
|
|
58
58
|
|
|
59
59
|
stream.each do |message|
|
|
@@ -109,6 +109,34 @@ client.beta.messages.tool_runner(
|
|
|
109
109
|
).each_message { puts _1.content }
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
+
### Structured Outputs
|
|
113
|
+
|
|
114
|
+
Constrain Claude's responses to follow a specific JSON schema using the `output_config` parameter:
|
|
115
|
+
|
|
116
|
+
```ruby
|
|
117
|
+
class FamousNumber < Anthropic::BaseModel
|
|
118
|
+
required :value, Float
|
|
119
|
+
optional :reason, String, doc: "why is this number mathematically significant?"
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
class Output < Anthropic::BaseModel
|
|
123
|
+
required :numbers, Anthropic::ArrayOf[FamousNumber], min_length: 3, max_length: 5
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
message = anthropic.messages.create(
|
|
127
|
+
model: "claude-sonnet-4-5-20250929",
|
|
128
|
+
max_tokens: 1024,
|
|
129
|
+
messages: [{role: "user", content: "give me some famous numbers"}],
|
|
130
|
+
output_config: {format: Output}
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
# Access the parsed response
|
|
134
|
+
message.parsed_output
|
|
135
|
+
# => #<Output numbers=[#<FamousNumber value=3.14159... reason="Pi is...">...]>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
For streaming and more examples, see [helpers.md](helpers.md#structured-outputs).
|
|
139
|
+
|
|
112
140
|
### Pagination
|
|
113
141
|
|
|
114
142
|
List methods in the Anthropic API are paginated.
|
|
@@ -168,7 +196,7 @@ begin
|
|
|
168
196
|
message = anthropic.messages.create(
|
|
169
197
|
max_tokens: 1024,
|
|
170
198
|
messages: [{role: "user", content: "Hello, Claude"}],
|
|
171
|
-
model:
|
|
199
|
+
model: "claude-sonnet-4-5-20250929"
|
|
172
200
|
)
|
|
173
201
|
rescue Anthropic::Errors::APIConnectionError => e
|
|
174
202
|
puts("The server could not be reached")
|
|
@@ -215,7 +243,7 @@ anthropic = Anthropic::Client.new(
|
|
|
215
243
|
anthropic.messages.create(
|
|
216
244
|
max_tokens: 1024,
|
|
217
245
|
messages: [{role: "user", content: "Hello, Claude"}],
|
|
218
|
-
model:
|
|
246
|
+
model: "claude-sonnet-4-5-20250929",
|
|
219
247
|
request_options: {max_retries: 5}
|
|
220
248
|
)
|
|
221
249
|
```
|
|
@@ -234,7 +262,7 @@ anthropic = Anthropic::Client.new(
|
|
|
234
262
|
anthropic.messages.create(
|
|
235
263
|
max_tokens: 1024,
|
|
236
264
|
messages: [{role: "user", content: "Hello, Claude"}],
|
|
237
|
-
model:
|
|
265
|
+
model: "claude-sonnet-4-5-20250929",
|
|
238
266
|
request_options: {timeout: 5}
|
|
239
267
|
)
|
|
240
268
|
```
|
|
@@ -330,7 +358,7 @@ message =
|
|
|
330
358
|
anthropic.messages.create(
|
|
331
359
|
max_tokens: 1024,
|
|
332
360
|
messages: [{role: "user", content: "Hello, Claude"}],
|
|
333
|
-
model:
|
|
361
|
+
model: "claude-sonnet-4-5-20250929",
|
|
334
362
|
request_options: {
|
|
335
363
|
extra_query: {my_query_parameter: value},
|
|
336
364
|
extra_body: {my_body_parameter: value},
|
|
@@ -379,7 +407,7 @@ You can provide typesafe request parameters like so:
|
|
|
379
407
|
anthropic.messages.create(
|
|
380
408
|
max_tokens: 1024,
|
|
381
409
|
messages: [Anthropic::MessageParam.new(role: "user", content: "Hello, Claude")],
|
|
382
|
-
model:
|
|
410
|
+
model: "claude-sonnet-4-5-20250929"
|
|
383
411
|
)
|
|
384
412
|
```
|
|
385
413
|
|
|
@@ -390,14 +418,14 @@ Or, equivalently:
|
|
|
390
418
|
anthropic.messages.create(
|
|
391
419
|
max_tokens: 1024,
|
|
392
420
|
messages: [{role: "user", content: "Hello, Claude"}],
|
|
393
|
-
model:
|
|
421
|
+
model: "claude-sonnet-4-5-20250929"
|
|
394
422
|
)
|
|
395
423
|
|
|
396
424
|
# You can also splat a full Params class:
|
|
397
425
|
params = Anthropic::MessageCreateParams.new(
|
|
398
426
|
max_tokens: 1024,
|
|
399
427
|
messages: [Anthropic::MessageParam.new(role: "user", content: "Hello, Claude")],
|
|
400
|
-
model:
|
|
428
|
+
model: "claude-sonnet-4-5-20250929"
|
|
401
429
|
)
|
|
402
430
|
anthropic.messages.create(**params)
|
|
403
431
|
```
|
|
@@ -13,11 +13,26 @@ module Anthropic
|
|
|
13
13
|
#
|
|
14
14
|
# @param strict [Boolean, nil]
|
|
15
15
|
#
|
|
16
|
+
# @param is_beta [Boolean]
|
|
17
|
+
#
|
|
16
18
|
# @return [Hash{String=>Class}, Hash{String=>Class}]
|
|
17
|
-
def distill_input_schema_models!(data, strict:)
|
|
19
|
+
def distill_input_schema_models!(data, strict:, is_beta: false)
|
|
18
20
|
tools = {}
|
|
19
21
|
models = {}
|
|
20
22
|
|
|
23
|
+
# Check for invalid output_config type before pattern matching
|
|
24
|
+
if data.key?(:output_config) && !data[:output_config].is_a?(Hash)
|
|
25
|
+
raise ArgumentError,
|
|
26
|
+
"output_config must be a Hash, got #{data[:output_config].class}"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Check for conflicting output_format and output_config[:format] before pattern matching
|
|
30
|
+
if data.key?(:output_format) && data.dig(:output_config, :format)
|
|
31
|
+
raise ArgumentError,
|
|
32
|
+
"Both output_format and output_config[:format] were provided. " \
|
|
33
|
+
"Please use only output_config[:format] (output_format is deprecated)."
|
|
34
|
+
end
|
|
35
|
+
|
|
21
36
|
case data
|
|
22
37
|
in {tools: Array => tool_array}
|
|
23
38
|
mapped = tool_array.map do |tool|
|
|
@@ -54,12 +69,38 @@ module Anthropic
|
|
|
54
69
|
end
|
|
55
70
|
end
|
|
56
71
|
tool_array.replace(mapped)
|
|
72
|
+
# GA: output_config with BaseModel class as format
|
|
73
|
+
in {output_config: {format: Anthropic::Helpers::InputSchema::JsonSchemaConverter => model} => output_config}
|
|
74
|
+
name = model_name(model.name)
|
|
75
|
+
models.store(name, model)
|
|
76
|
+
schema = model.to_json_schema
|
|
77
|
+
Anthropic::Helpers::InputSchema::SupportedSchemas.transform_schema!(schema)
|
|
78
|
+
output_config.update(format: {type: :json_schema, schema:})
|
|
79
|
+
inject_structured_output_beta_header!(data) if is_beta
|
|
80
|
+
# GA: output_config.format.schema as BaseModel class
|
|
81
|
+
in {output_config: {format: {schema: Anthropic::Helpers::InputSchema::JsonSchemaConverter => model} => format_} => _output_config}
|
|
82
|
+
name = model_name(model.name)
|
|
83
|
+
models.store(name, model)
|
|
84
|
+
schema = model.to_json_schema
|
|
85
|
+
Anthropic::Helpers::InputSchema::SupportedSchemas.transform_schema!(schema)
|
|
86
|
+
format_.update(type: :json_schema, schema:)
|
|
87
|
+
inject_structured_output_beta_header!(data) if is_beta
|
|
88
|
+
# Beta: output_format as BaseModel class (deprecated)
|
|
57
89
|
in {output_format: Anthropic::Helpers::InputSchema::JsonSchemaConverter => model}
|
|
90
|
+
transform_output_format_to_output_config!(data, model:, models:, is_beta:)
|
|
91
|
+
# rubocop:disable Lint/DuplicateBranch
|
|
92
|
+
in {output_format: {schema: Anthropic::Helpers::InputSchema::JsonSchemaConverter => model}}
|
|
93
|
+
# This branch handles output_format: {schema: Model} vs output_format: Model above
|
|
94
|
+
transform_output_format_to_output_config!(data, model:, models:, is_beta:)
|
|
95
|
+
# rubocop:enable Lint/DuplicateBranch
|
|
96
|
+
in {output_config: {format: Anthropic::Helpers::InputSchema::JsonSchemaConverter => model}}
|
|
97
|
+
# New API: output_config.format with model class
|
|
58
98
|
name = model_name(model.name)
|
|
59
99
|
models.store(name, model)
|
|
60
100
|
schema = model.to_json_schema
|
|
61
101
|
Anthropic::Helpers::InputSchema::SupportedSchemas.transform_schema!(schema)
|
|
62
102
|
data.update(output_format: {type: :json_schema, schema: schema})
|
|
103
|
+
# Beta: output_format.schema as BaseModel class (deprecated)
|
|
63
104
|
in {output_format: {schema: Anthropic::Helpers::InputSchema::JsonSchemaConverter => model} => output_format}
|
|
64
105
|
name = model_name(model.name)
|
|
65
106
|
models.store(name, model)
|
|
@@ -108,6 +149,50 @@ module Anthropic
|
|
|
108
149
|
raw
|
|
109
150
|
end
|
|
110
151
|
|
|
152
|
+
# @api private
|
|
153
|
+
#
|
|
154
|
+
# Transform deprecated output_format to output_config.format
|
|
155
|
+
#
|
|
156
|
+
# @param data [Hash{Symbol=>Object}]
|
|
157
|
+
# @param model [Class]
|
|
158
|
+
# @param models [Hash{String=>Class}]
|
|
159
|
+
# @param is_beta [Boolean]
|
|
160
|
+
private def transform_output_format_to_output_config!(data, model:, models:, is_beta:)
|
|
161
|
+
warn(
|
|
162
|
+
"[DEPRECATION] output_format is deprecated. Use output_config[:format] instead.",
|
|
163
|
+
category: :deprecated
|
|
164
|
+
)
|
|
165
|
+
# Error if output_config exists but is not a hash
|
|
166
|
+
if data.key?(:output_config) && !data[:output_config].is_a?(Hash)
|
|
167
|
+
raise ArgumentError,
|
|
168
|
+
"output_config must be a Hash, got #{data[:output_config].class}"
|
|
169
|
+
end
|
|
170
|
+
# Error if both params are provided
|
|
171
|
+
if data&.dig(:output_config, :format)
|
|
172
|
+
raise ArgumentError,
|
|
173
|
+
"Both output_format and output_config[:format] were provided. " \
|
|
174
|
+
"Please use only output_config[:format] (output_format is deprecated)."
|
|
175
|
+
end
|
|
176
|
+
name = model_name(model.name)
|
|
177
|
+
models.store(name, model)
|
|
178
|
+
schema = model.to_json_schema
|
|
179
|
+
Anthropic::Helpers::InputSchema::SupportedSchemas.transform_schema!(schema)
|
|
180
|
+
output_config = data[:output_config].to_h
|
|
181
|
+
output_config.store(:format, type: :json_schema, schema: schema)
|
|
182
|
+
data.delete(:output_format)
|
|
183
|
+
data[:output_config] = output_config
|
|
184
|
+
inject_structured_output_beta_header!(data) if is_beta
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# @api private
|
|
188
|
+
#
|
|
189
|
+
# Inject the structured outputs beta header into the request data
|
|
190
|
+
#
|
|
191
|
+
# @param data [Hash{Symbol=>Object}]
|
|
192
|
+
private def inject_structured_output_beta_header!(data)
|
|
193
|
+
data[:betas] = data[:betas].to_a.dup.push("structured-outputs-2025-12-15").uniq
|
|
194
|
+
end
|
|
195
|
+
|
|
111
196
|
# @api private
|
|
112
197
|
#
|
|
113
198
|
# @param classname [String]
|
|
@@ -76,6 +76,19 @@ module Anthropic
|
|
|
76
76
|
required :signature, String
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
+
class CompactionEvent < Anthropic::Internal::Type::BaseModel
|
|
80
|
+
# @!attribute type
|
|
81
|
+
#
|
|
82
|
+
# @return [Symbol, :compaction]
|
|
83
|
+
required :type, const: :compaction
|
|
84
|
+
|
|
85
|
+
# @!attribute content
|
|
86
|
+
# The compacted content summary.
|
|
87
|
+
#
|
|
88
|
+
# @return [String, nil]
|
|
89
|
+
required :content, String, nil?: true
|
|
90
|
+
end
|
|
91
|
+
|
|
79
92
|
class InputJsonEvent < Anthropic::Internal::Type::BaseModel
|
|
80
93
|
# @!attribute type
|
|
81
94
|
#
|
|
@@ -63,7 +63,7 @@ module Anthropic
|
|
|
63
63
|
# @return [Anthropic::Models::Message, Anthropic::Models::Beta::BetaMessage]
|
|
64
64
|
def accumulated_message
|
|
65
65
|
until_done
|
|
66
|
-
|
|
66
|
+
parse_content_blocks!(@accumated_message_snapshot)
|
|
67
67
|
@accumated_message_snapshot
|
|
68
68
|
end
|
|
69
69
|
|
|
@@ -132,12 +132,18 @@ module Anthropic
|
|
|
132
132
|
content.thinking += delta.thinking
|
|
133
133
|
in Anthropic::Models::SignatureDelta | Anthropic::Models::BetaSignatureDelta if content.type == :thinking
|
|
134
134
|
content.signature = delta.signature
|
|
135
|
+
in Anthropic::Models::BetaCompactionContentBlockDelta if content.type == :compaction
|
|
136
|
+
content.content = delta.content
|
|
135
137
|
else
|
|
136
138
|
end
|
|
137
139
|
in Anthropic::Models::RawMessageDeltaEvent | Anthropic::Models::BetaRawMessageDeltaEvent
|
|
138
140
|
current_snapshot.stop_reason = event.delta.stop_reason
|
|
139
141
|
current_snapshot.stop_sequence = event.delta.stop_sequence
|
|
140
142
|
current_snapshot.usage.output_tokens = event.usage.output_tokens
|
|
143
|
+
|
|
144
|
+
if event.is_a?(Anthropic::Models::BetaRawMessageDeltaEvent) && !event.usage.iterations.nil?
|
|
145
|
+
current_snapshot.usage.iterations = event.usage.iterations
|
|
146
|
+
end
|
|
141
147
|
else
|
|
142
148
|
end
|
|
143
149
|
|
|
@@ -198,6 +204,11 @@ module Anthropic
|
|
|
198
204
|
type: :signature,
|
|
199
205
|
signature: content_block.signature
|
|
200
206
|
)
|
|
207
|
+
in Anthropic::Models::BetaCompactionContentBlockDelta if content_block.type == :compaction
|
|
208
|
+
events_to_yield << Anthropic::Streaming::CompactionEvent.new(
|
|
209
|
+
type: :compaction,
|
|
210
|
+
content: content_block.content
|
|
211
|
+
)
|
|
201
212
|
else
|
|
202
213
|
end
|
|
203
214
|
in Anthropic::Models::RawContentBlockStopEvent | Anthropic::Models::BetaRawContentBlockStopEvent
|
|
@@ -217,47 +228,72 @@ module Anthropic
|
|
|
217
228
|
|
|
218
229
|
# @api private
|
|
219
230
|
#
|
|
220
|
-
# Parse tool use blocks
|
|
231
|
+
# Parse tool use blocks and text blocks with structured output in the message.
|
|
221
232
|
#
|
|
222
233
|
# @param message [Anthropic::Models::Message] The message to parse
|
|
223
234
|
#
|
|
224
|
-
# @return [Anthropic::Models::Message] The message with parsed
|
|
225
|
-
private def
|
|
235
|
+
# @return [Anthropic::Models::Message] The message with parsed content
|
|
236
|
+
private def parse_content_blocks!(message)
|
|
226
237
|
return message unless message&.content
|
|
227
238
|
|
|
228
239
|
# rubocop:disable Metrics/BlockLength
|
|
229
240
|
message.content.each_with_index do |content, index|
|
|
230
|
-
|
|
241
|
+
case content.type
|
|
242
|
+
when :tool_use
|
|
243
|
+
next unless (tool = @tools[content.name])
|
|
231
244
|
|
|
232
|
-
|
|
245
|
+
parsed =
|
|
246
|
+
begin
|
|
247
|
+
parsed_input = if content.input.is_a?(String)
|
|
248
|
+
JSON.parse(content.input, symbolize_names: true)
|
|
249
|
+
else
|
|
250
|
+
content.input
|
|
251
|
+
end
|
|
233
252
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
253
|
+
Anthropic::Internal::Type::Converter.coerce(tool, parsed_input)
|
|
254
|
+
rescue StandardError => e
|
|
255
|
+
e
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
cls =
|
|
259
|
+
case content
|
|
260
|
+
in Anthropic::ContentBlock
|
|
261
|
+
Anthropic::Models::ToolUseBlock
|
|
238
262
|
else
|
|
239
|
-
|
|
263
|
+
Anthropic::Models::BetaToolUseBlock
|
|
240
264
|
end
|
|
265
|
+
message.content[index] = cls.new(
|
|
266
|
+
id: content.id,
|
|
267
|
+
input: content.input,
|
|
268
|
+
name: content.name,
|
|
269
|
+
type: content.type,
|
|
270
|
+
parsed: parsed
|
|
271
|
+
)
|
|
272
|
+
when :text
|
|
273
|
+
next unless (model = @models.first&.last)
|
|
241
274
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
275
|
+
parsed =
|
|
276
|
+
begin
|
|
277
|
+
json = JSON.parse(content.text, symbolize_names: true)
|
|
278
|
+
Anthropic::Internal::Type::Converter.coerce(model, json)
|
|
279
|
+
rescue StandardError => e
|
|
280
|
+
{error: e.message}
|
|
281
|
+
end
|
|
246
282
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
283
|
+
cls =
|
|
284
|
+
case content
|
|
285
|
+
in Anthropic::ContentBlock
|
|
286
|
+
Anthropic::Models::TextBlock
|
|
287
|
+
else
|
|
288
|
+
Anthropic::Models::BetaTextBlock
|
|
289
|
+
end
|
|
290
|
+
message.content[index] = cls.new(
|
|
291
|
+
citations: content.citations,
|
|
292
|
+
text: content.text,
|
|
293
|
+
type: content.type,
|
|
294
|
+
parsed: parsed
|
|
295
|
+
)
|
|
296
|
+
end
|
|
261
297
|
end
|
|
262
298
|
# rubocop:enable Metrics/BlockLength
|
|
263
299
|
|
|
@@ -75,7 +75,7 @@ module Anthropic
|
|
|
75
75
|
|
|
76
76
|
case body
|
|
77
77
|
in nil
|
|
78
|
-
|
|
78
|
+
req["content-length"] ||= 0 unless req["transfer-encoding"]
|
|
79
79
|
in String
|
|
80
80
|
req["content-length"] ||= body.bytesize.to_s unless req["transfer-encoding"]
|
|
81
81
|
req.body_stream = Anthropic::Internal::Util::ReadIOAdapter.new(body, &blk)
|
|
@@ -37,6 +37,7 @@ module Anthropic
|
|
|
37
37
|
optional :defer_loading, Anthropic::Internal::Type::Boolean
|
|
38
38
|
|
|
39
39
|
# @!attribute strict
|
|
40
|
+
# When true, guarantees schema validation on tool names and inputs
|
|
40
41
|
#
|
|
41
42
|
# @return [Boolean, nil]
|
|
42
43
|
optional :strict, Anthropic::Internal::Type::Boolean
|
|
@@ -51,7 +52,7 @@ module Anthropic
|
|
|
51
52
|
#
|
|
52
53
|
# @param defer_loading [Boolean] If true, tool will not be included in initial system prompt. Only loaded when re
|
|
53
54
|
#
|
|
54
|
-
# @param strict [Boolean]
|
|
55
|
+
# @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
|
|
55
56
|
#
|
|
56
57
|
# @param name [Symbol, :code_execution] Name of the tool.
|
|
57
58
|
#
|
|
@@ -37,6 +37,7 @@ module Anthropic
|
|
|
37
37
|
optional :defer_loading, Anthropic::Internal::Type::Boolean
|
|
38
38
|
|
|
39
39
|
# @!attribute strict
|
|
40
|
+
# When true, guarantees schema validation on tool names and inputs
|
|
40
41
|
#
|
|
41
42
|
# @return [Boolean, nil]
|
|
42
43
|
optional :strict, Anthropic::Internal::Type::Boolean
|
|
@@ -51,7 +52,7 @@ module Anthropic
|
|
|
51
52
|
#
|
|
52
53
|
# @param defer_loading [Boolean] If true, tool will not be included in initial system prompt. Only loaded when re
|
|
53
54
|
#
|
|
54
|
-
# @param strict [Boolean]
|
|
55
|
+
# @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
|
|
55
56
|
#
|
|
56
57
|
# @param name [Symbol, :code_execution] Name of the tool.
|
|
57
58
|
#
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Anthropic
|
|
4
|
+
module Models
|
|
5
|
+
module Beta
|
|
6
|
+
class BetaCompact20260112Edit < Anthropic::Internal::Type::BaseModel
|
|
7
|
+
# @!attribute type
|
|
8
|
+
#
|
|
9
|
+
# @return [Symbol, :compact_20260112]
|
|
10
|
+
required :type, const: :compact_20260112
|
|
11
|
+
|
|
12
|
+
# @!attribute instructions
|
|
13
|
+
# Additional instructions for summarization.
|
|
14
|
+
#
|
|
15
|
+
# @return [String, nil]
|
|
16
|
+
optional :instructions, String, nil?: true
|
|
17
|
+
|
|
18
|
+
# @!attribute pause_after_compaction
|
|
19
|
+
# Whether to pause after compaction and return the compaction block to the user.
|
|
20
|
+
#
|
|
21
|
+
# @return [Boolean, nil]
|
|
22
|
+
optional :pause_after_compaction, Anthropic::Internal::Type::Boolean
|
|
23
|
+
|
|
24
|
+
# @!attribute trigger
|
|
25
|
+
# When to trigger compaction. Defaults to 150000 input tokens.
|
|
26
|
+
#
|
|
27
|
+
# @return [Anthropic::Models::Beta::BetaInputTokensTrigger, nil]
|
|
28
|
+
optional :trigger, -> { Anthropic::Beta::BetaInputTokensTrigger }, nil?: true
|
|
29
|
+
|
|
30
|
+
# @!method initialize(instructions: nil, pause_after_compaction: nil, trigger: nil, type: :compact_20260112)
|
|
31
|
+
# Automatically compact older context when reaching the configured trigger
|
|
32
|
+
# threshold.
|
|
33
|
+
#
|
|
34
|
+
# @param instructions [String, nil] Additional instructions for summarization.
|
|
35
|
+
#
|
|
36
|
+
# @param pause_after_compaction [Boolean] Whether to pause after compaction and return the compaction block to the user.
|
|
37
|
+
#
|
|
38
|
+
# @param trigger [Anthropic::Models::Beta::BetaInputTokensTrigger, nil] When to trigger compaction. Defaults to 150000 input tokens.
|
|
39
|
+
#
|
|
40
|
+
# @param type [Symbol, :compact_20260112]
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
BetaCompact20260112Edit = Beta::BetaCompact20260112Edit
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Anthropic
|
|
4
|
+
module Models
|
|
5
|
+
module Beta
|
|
6
|
+
class BetaCompactionBlock < Anthropic::Internal::Type::BaseModel
|
|
7
|
+
# @!attribute content
|
|
8
|
+
# Summary of compacted content, or null if compaction failed
|
|
9
|
+
#
|
|
10
|
+
# @return [String, nil]
|
|
11
|
+
required :content, String, nil?: true
|
|
12
|
+
|
|
13
|
+
# @!attribute type
|
|
14
|
+
#
|
|
15
|
+
# @return [Symbol, :compaction]
|
|
16
|
+
required :type, const: :compaction
|
|
17
|
+
|
|
18
|
+
# @!method initialize(content:, type: :compaction)
|
|
19
|
+
# A compaction block returned when autocompact is triggered.
|
|
20
|
+
#
|
|
21
|
+
# When content is None, it indicates the compaction failed to produce a valid
|
|
22
|
+
# summary (e.g., malformed output from the model). Clients may round-trip
|
|
23
|
+
# compaction blocks with null content; the server treats them as no-ops.
|
|
24
|
+
#
|
|
25
|
+
# @param content [String, nil] Summary of compacted content, or null if compaction failed
|
|
26
|
+
#
|
|
27
|
+
# @param type [Symbol, :compaction]
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
BetaCompactionBlock = Beta::BetaCompactionBlock
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Anthropic
|
|
4
|
+
module Models
|
|
5
|
+
module Beta
|
|
6
|
+
class BetaCompactionBlockParam < Anthropic::Internal::Type::BaseModel
|
|
7
|
+
# @!attribute content
|
|
8
|
+
# Summary of previously compacted content, or null if compaction failed
|
|
9
|
+
#
|
|
10
|
+
# @return [String, nil]
|
|
11
|
+
required :content, String, nil?: true
|
|
12
|
+
|
|
13
|
+
# @!attribute type
|
|
14
|
+
#
|
|
15
|
+
# @return [Symbol, :compaction]
|
|
16
|
+
required :type, const: :compaction
|
|
17
|
+
|
|
18
|
+
# @!attribute cache_control
|
|
19
|
+
# Create a cache control breakpoint at this content block.
|
|
20
|
+
#
|
|
21
|
+
# @return [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil]
|
|
22
|
+
optional :cache_control, -> { Anthropic::Beta::BetaCacheControlEphemeral }, nil?: true
|
|
23
|
+
|
|
24
|
+
# @!method initialize(content:, cache_control: nil, type: :compaction)
|
|
25
|
+
# A compaction block containing summary of previous context.
|
|
26
|
+
#
|
|
27
|
+
# Users should round-trip these blocks from responses to subsequent requests to
|
|
28
|
+
# maintain context across compaction boundaries.
|
|
29
|
+
#
|
|
30
|
+
# When content is None, the block represents a failed compaction. The server
|
|
31
|
+
# treats these as no-ops. Empty string content is not allowed.
|
|
32
|
+
#
|
|
33
|
+
# @param content [String, nil] Summary of previously compacted content, or null if compaction failed
|
|
34
|
+
#
|
|
35
|
+
# @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
|
|
36
|
+
#
|
|
37
|
+
# @param type [Symbol, :compaction]
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
BetaCompactionBlockParam = Beta::BetaCompactionBlockParam
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Anthropic
|
|
4
|
+
module Models
|
|
5
|
+
module Beta
|
|
6
|
+
class BetaCompactionContentBlockDelta < Anthropic::Internal::Type::BaseModel
|
|
7
|
+
# @!attribute content
|
|
8
|
+
#
|
|
9
|
+
# @return [String, nil]
|
|
10
|
+
required :content, String, nil?: true
|
|
11
|
+
|
|
12
|
+
# @!attribute type
|
|
13
|
+
#
|
|
14
|
+
# @return [Symbol, :compaction_delta]
|
|
15
|
+
required :type, const: :compaction_delta
|
|
16
|
+
|
|
17
|
+
# @!method initialize(content:, type: :compaction_delta)
|
|
18
|
+
# @param content [String, nil]
|
|
19
|
+
# @param type [Symbol, :compaction_delta]
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
BetaCompactionContentBlockDelta = Beta::BetaCompactionContentBlockDelta
|
|
24
|
+
end
|
|
25
|
+
end
|