anthropic 1.2.0 → 1.4.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 +41 -0
- data/README.md +1 -1
- data/lib/anthropic/client.rb +5 -2
- data/lib/anthropic/internal/transport/base_client.rb +1 -1
- data/lib/anthropic/models/beta/beta_citation_char_location.rb +7 -1
- data/lib/anthropic/models/beta/beta_citation_content_block_location.rb +7 -1
- data/lib/anthropic/models/beta/beta_citation_page_location.rb +7 -1
- data/lib/anthropic/models/beta/beta_tool_text_editor_20250728.rb +49 -0
- data/lib/anthropic/models/beta/beta_tool_union.rb +3 -1
- data/lib/anthropic/models/beta/message_count_tokens_params.rb +5 -3
- data/lib/anthropic/models/beta/message_create_params.rb +2 -2
- data/lib/anthropic/models/beta/messages/batch_create_params.rb +2 -2
- data/lib/anthropic/models/citation_char_location.rb +7 -1
- data/lib/anthropic/models/citation_content_block_location.rb +7 -1
- data/lib/anthropic/models/citation_page_location.rb +7 -1
- data/lib/anthropic/models/message_count_tokens_params.rb +2 -2
- data/lib/anthropic/models/message_count_tokens_tool.rb +4 -34
- data/lib/anthropic/models/message_create_params.rb +2 -2
- data/lib/anthropic/models/messages/batch_create_params.rb +2 -2
- data/lib/anthropic/models/model.rb +5 -22
- data/lib/anthropic/models/tool_text_editor_20250429.rb +36 -0
- data/lib/anthropic/models/tool_text_editor_20250728.rb +45 -0
- data/lib/anthropic/models/tool_union.rb +4 -33
- data/lib/anthropic/models.rb +4 -0
- data/lib/anthropic/resources/beta/messages.rb +70 -3
- data/lib/anthropic/resources/messages.rb +3 -3
- data/lib/anthropic/version.rb +1 -1
- data/lib/anthropic.rb +3 -0
- data/rbi/anthropic/helpers/bedrock/client.rbi +17 -6
- data/rbi/anthropic/helpers/streaming/events.rbi +12 -2
- data/rbi/anthropic/helpers/streaming/message_stream.rbi +48 -34
- data/rbi/anthropic/helpers/vertex/client.rbi +17 -6
- data/rbi/anthropic/internal/transport/base_client.rbi +1 -1
- data/rbi/anthropic/models/beta/beta_citation_char_location.rbi +6 -0
- data/rbi/anthropic/models/beta/beta_citation_content_block_location.rbi +6 -0
- data/rbi/anthropic/models/beta/beta_citation_page_location.rbi +6 -0
- data/rbi/anthropic/models/beta/beta_tool_text_editor_20250728.rbi +82 -0
- data/rbi/anthropic/models/beta/beta_tool_union.rbi +1 -0
- data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +5 -0
- data/rbi/anthropic/models/beta/message_create_params.rbi +4 -0
- data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +4 -0
- data/rbi/anthropic/models/citation_char_location.rbi +6 -0
- data/rbi/anthropic/models/citation_content_block_location.rbi +6 -0
- data/rbi/anthropic/models/citation_page_location.rbi +6 -0
- data/rbi/anthropic/models/message_count_tokens_params.rbi +8 -4
- data/rbi/anthropic/models/message_count_tokens_tool.rbi +2 -61
- data/rbi/anthropic/models/message_create_params.rbi +8 -4
- data/rbi/anthropic/models/messages/batch_create_params.rbi +8 -4
- data/rbi/anthropic/models/model.rbi +4 -8
- data/rbi/anthropic/models/tool_text_editor_20250429.rbi +62 -0
- data/rbi/anthropic/models/tool_text_editor_20250728.rbi +72 -0
- data/rbi/anthropic/models/tool_union.rbi +2 -61
- data/rbi/anthropic/models.rbi +4 -0
- data/rbi/anthropic/resources/beta/messages.rbi +3 -0
- data/rbi/anthropic/resources/messages.rbi +53 -28
- data/sig/anthropic/helpers/streaming/events.rbs +30 -32
- data/sig/anthropic/helpers/streaming/message_stream.rbs +4 -2
- data/sig/anthropic/internal/transport/base_client.rbs +1 -1
- data/sig/anthropic/models/beta/beta_citation_char_location.rbs +5 -0
- data/sig/anthropic/models/beta/beta_citation_content_block_location.rbs +5 -0
- data/sig/anthropic/models/beta/beta_citation_page_location.rbs +5 -0
- data/sig/anthropic/models/beta/beta_tool_text_editor_20250728.rbs +39 -0
- data/sig/anthropic/models/beta/beta_tool_union.rbs +1 -0
- data/sig/anthropic/models/beta/message_count_tokens_params.rbs +1 -0
- data/sig/anthropic/models/citation_char_location.rbs +5 -0
- data/sig/anthropic/models/citation_content_block_location.rbs +5 -0
- data/sig/anthropic/models/citation_page_location.rbs +5 -0
- data/sig/anthropic/models/message_count_tokens_tool.rbs +2 -28
- data/sig/anthropic/models/model.rbs +4 -10
- data/sig/anthropic/models/tool_text_editor_20250429.rbs +30 -0
- data/sig/anthropic/models/tool_text_editor_20250728.rbs +35 -0
- data/sig/anthropic/models/tool_union.rbs +2 -28
- data/sig/anthropic/models.rbs +4 -0
- metadata +11 -2
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Anthropic
|
4
|
+
module Models
|
5
|
+
class ToolTextEditor20250728 < Anthropic::Internal::Type::BaseModel
|
6
|
+
# @!attribute name
|
7
|
+
# Name of the tool.
|
8
|
+
#
|
9
|
+
# This is how the tool will be called by the model and in `tool_use` blocks.
|
10
|
+
#
|
11
|
+
# @return [Symbol, :str_replace_based_edit_tool]
|
12
|
+
required :name, const: :str_replace_based_edit_tool
|
13
|
+
|
14
|
+
# @!attribute type
|
15
|
+
#
|
16
|
+
# @return [Symbol, :text_editor_20250728]
|
17
|
+
required :type, const: :text_editor_20250728
|
18
|
+
|
19
|
+
# @!attribute cache_control
|
20
|
+
# Create a cache control breakpoint at this content block.
|
21
|
+
#
|
22
|
+
# @return [Anthropic::Models::CacheControlEphemeral, nil]
|
23
|
+
optional :cache_control, -> { Anthropic::CacheControlEphemeral }, nil?: true
|
24
|
+
|
25
|
+
# @!attribute max_characters
|
26
|
+
# Maximum number of characters to display when viewing a file. If not specified,
|
27
|
+
# defaults to displaying the full file.
|
28
|
+
#
|
29
|
+
# @return [Integer, nil]
|
30
|
+
optional :max_characters, Integer, nil?: true
|
31
|
+
|
32
|
+
# @!method initialize(cache_control: nil, max_characters: nil, name: :str_replace_based_edit_tool, type: :text_editor_20250728)
|
33
|
+
# Some parameter documentations has been truncated, see
|
34
|
+
# {Anthropic::Models::ToolTextEditor20250728} for more details.
|
35
|
+
#
|
36
|
+
# @param cache_control [Anthropic::Models::CacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
|
37
|
+
#
|
38
|
+
# @param max_characters [Integer, nil] Maximum number of characters to display when viewing a file. If not specified, d
|
39
|
+
#
|
40
|
+
# @param name [Symbol, :str_replace_based_edit_tool] Name of the tool.
|
41
|
+
#
|
42
|
+
# @param type [Symbol, :text_editor_20250728]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -11,43 +11,14 @@ module Anthropic
|
|
11
11
|
|
12
12
|
variant -> { Anthropic::ToolTextEditor20250124 }
|
13
13
|
|
14
|
-
variant -> { Anthropic::
|
14
|
+
variant -> { Anthropic::ToolTextEditor20250429 }
|
15
15
|
|
16
|
-
variant -> { Anthropic::
|
16
|
+
variant -> { Anthropic::ToolTextEditor20250728 }
|
17
17
|
|
18
|
-
|
19
|
-
# @!attribute name
|
20
|
-
# Name of the tool.
|
21
|
-
#
|
22
|
-
# This is how the tool will be called by the model and in `tool_use` blocks.
|
23
|
-
#
|
24
|
-
# @return [Symbol, :str_replace_based_edit_tool]
|
25
|
-
required :name, const: :str_replace_based_edit_tool
|
26
|
-
|
27
|
-
# @!attribute type
|
28
|
-
#
|
29
|
-
# @return [Symbol, :text_editor_20250429]
|
30
|
-
required :type, const: :text_editor_20250429
|
31
|
-
|
32
|
-
# @!attribute cache_control
|
33
|
-
# Create a cache control breakpoint at this content block.
|
34
|
-
#
|
35
|
-
# @return [Anthropic::Models::CacheControlEphemeral, nil]
|
36
|
-
optional :cache_control, -> { Anthropic::CacheControlEphemeral }, nil?: true
|
37
|
-
|
38
|
-
# @!method initialize(cache_control: nil, name: :str_replace_based_edit_tool, type: :text_editor_20250429)
|
39
|
-
# Some parameter documentations has been truncated, see
|
40
|
-
# {Anthropic::Models::ToolUnion::TextEditor20250429} for more details.
|
41
|
-
#
|
42
|
-
# @param cache_control [Anthropic::Models::CacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
|
43
|
-
#
|
44
|
-
# @param name [Symbol, :str_replace_based_edit_tool] Name of the tool.
|
45
|
-
#
|
46
|
-
# @param type [Symbol, :text_editor_20250429]
|
47
|
-
end
|
18
|
+
variant -> { Anthropic::WebSearchTool20250305 }
|
48
19
|
|
49
20
|
# @!method self.variants
|
50
|
-
# @return [Array(Anthropic::Models::Tool, Anthropic::Models::ToolBash20250124, Anthropic::Models::ToolTextEditor20250124, Anthropic::Models::
|
21
|
+
# @return [Array(Anthropic::Models::Tool, Anthropic::Models::ToolBash20250124, Anthropic::Models::ToolTextEditor20250124, Anthropic::Models::ToolTextEditor20250429, Anthropic::Models::ToolTextEditor20250728, Anthropic::Models::WebSearchTool20250305)]
|
51
22
|
end
|
52
23
|
end
|
53
24
|
end
|
data/lib/anthropic/models.rb
CHANGED
@@ -229,6 +229,10 @@ module Anthropic
|
|
229
229
|
|
230
230
|
ToolTextEditor20250124 = Anthropic::Models::ToolTextEditor20250124
|
231
231
|
|
232
|
+
ToolTextEditor20250429 = Anthropic::Models::ToolTextEditor20250429
|
233
|
+
|
234
|
+
ToolTextEditor20250728 = Anthropic::Models::ToolTextEditor20250728
|
235
|
+
|
232
236
|
ToolUnion = Anthropic::Models::ToolUnion
|
233
237
|
|
234
238
|
ToolUseBlock = Anthropic::Models::ToolUseBlock
|
@@ -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::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::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
|
#
|
@@ -89,7 +89,74 @@ module Anthropic
|
|
89
89
|
)
|
90
90
|
end
|
91
91
|
|
92
|
-
|
92
|
+
# See {Anthropic::Resources::Beta::Messages#create} for non-streaming counterpart.
|
93
|
+
#
|
94
|
+
# Some parameter documentations has been truncated, see
|
95
|
+
# {Anthropic::Models::Beta::MessageCreateParams} for more details.
|
96
|
+
#
|
97
|
+
# Send a structured list of input messages with text and/or image content, and the
|
98
|
+
# model will generate the next message in the conversation.
|
99
|
+
#
|
100
|
+
# The Messages API can be used for either single queries or stateless multi-turn
|
101
|
+
# conversations.
|
102
|
+
#
|
103
|
+
# Learn more about the Messages API in our [user guide](/en/docs/initial-setup)
|
104
|
+
#
|
105
|
+
# @overload stream_raw(max_tokens:, messages:, model:, container: nil, mcp_servers: nil, metadata: nil, service_tier: nil, stop_sequences: nil, system_: nil, temperature: nil, thinking: nil, tool_choice: nil, tools: nil, top_k: nil, top_p: nil, betas: nil, request_options: {})
|
106
|
+
#
|
107
|
+
# @param max_tokens [Integer] Body param: The maximum number of tokens to generate before stopping.
|
108
|
+
#
|
109
|
+
# @param messages [Array<Anthropic::Models::Beta::BetaMessageParam>] Body param: Input messages.
|
110
|
+
#
|
111
|
+
# @param model [Symbol, String, Anthropic::Models::Model] Body param: The model that will complete your prompt.\n\nSee [models](https://do
|
112
|
+
#
|
113
|
+
# @param container [String, nil] Body param: Container identifier for reuse across requests.
|
114
|
+
#
|
115
|
+
# @param mcp_servers [Array<Anthropic::Models::Beta::BetaRequestMCPServerURLDefinition>] Body param: MCP servers to be utilized in this request
|
116
|
+
#
|
117
|
+
# @param metadata [Anthropic::Models::Beta::BetaMetadata] Body param: An object describing metadata about the request.
|
118
|
+
#
|
119
|
+
# @param service_tier [Symbol, Anthropic::Models::Beta::MessageCreateParams::ServiceTier] Body param: Determines whether to use priority capacity (if available) or standa
|
120
|
+
#
|
121
|
+
# @param stop_sequences [Array<String>] Body param: Custom text sequences that will cause the model to stop generating.
|
122
|
+
#
|
123
|
+
# @param system_ [String, Array<Anthropic::Models::Beta::BetaTextBlockParam>] Body param: System prompt.
|
124
|
+
#
|
125
|
+
# @param temperature [Float] Body param: Amount of randomness injected into the response.
|
126
|
+
#
|
127
|
+
# @param thinking [Anthropic::Models::Beta::BetaThinkingConfigEnabled, Anthropic::Models::Beta::BetaThinkingConfigDisabled] Body param: Configuration for enabling Claude's extended thinking.
|
128
|
+
#
|
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
|
+
#
|
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.
|
132
|
+
#
|
133
|
+
# @param top_k [Integer] Body param: Only sample from the top K options for each subsequent token.
|
134
|
+
#
|
135
|
+
# @param top_p [Float] Body param: Use nucleus sampling.
|
136
|
+
#
|
137
|
+
# @param betas [Array<String, Symbol, Anthropic::Models::AnthropicBeta>] Header param: Optional header to specify the beta version(s) you want to use.
|
138
|
+
#
|
139
|
+
# @param request_options [Anthropic::RequestOptions, Hash{Symbol=>Object}, nil]
|
140
|
+
#
|
141
|
+
# @return [Anthropic::Internal::Stream<Anthropic::Models::Beta::BetaRawMessageStartEvent, Anthropic::Models::Beta::BetaRawMessageDeltaEvent, Anthropic::Models::Beta::BetaRawMessageStopEvent, Anthropic::Models::Beta::BetaRawContentBlockStartEvent, Anthropic::Models::Beta::BetaRawContentBlockDeltaEvent, Anthropic::Models::Beta::BetaRawContentBlockStopEvent>]
|
142
|
+
#
|
143
|
+
# @see Anthropic::Models::Beta::MessageCreateParams
|
144
|
+
def stream(params)
|
145
|
+
parsed, options = Anthropic::Models::Beta::MessageCreateParams.dump_request(params)
|
146
|
+
unless parsed.fetch(:stream, true)
|
147
|
+
message = "Please use `#create` for the non-streaming use case."
|
148
|
+
raise ArgumentError.new(message)
|
149
|
+
end
|
150
|
+
parsed.store(:stream, true)
|
151
|
+
raw_stream = @client.request(
|
152
|
+
method: :post,
|
153
|
+
path: "v1/messages?beta=true",
|
154
|
+
headers: {"accept" => "text/event-stream"},
|
155
|
+
body: parsed,
|
156
|
+
stream: Anthropic::Internal::Stream,
|
157
|
+
model: Anthropic::Beta::BetaRawMessageStreamEvent,
|
158
|
+
options: options
|
159
|
+
)
|
93
160
|
Anthropic::Streaming::MessageStream.new(raw_stream: raw_stream)
|
94
161
|
end
|
95
162
|
|
@@ -192,7 +259,7 @@ module Anthropic
|
|
192
259
|
#
|
193
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
|
194
261
|
#
|
195
|
-
# @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::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::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.
|
196
263
|
#
|
197
264
|
# @param betas [Array<String, Symbol, Anthropic::Models::AnthropicBeta>] Header param: Optional header to specify the beta version(s) you want to use.
|
198
265
|
#
|
@@ -41,7 +41,7 @@ module Anthropic
|
|
41
41
|
#
|
42
42
|
# @param tool_choice [Anthropic::Models::ToolChoiceAuto, Anthropic::Models::ToolChoiceAny, Anthropic::Models::ToolChoiceTool, Anthropic::Models::ToolChoiceNone] How the model should use the provided tools. The model can use a specific tool,
|
43
43
|
#
|
44
|
-
# @param tools [Array<Anthropic::Models::Tool, Anthropic::Models::ToolBash20250124, Anthropic::Models::ToolTextEditor20250124, Anthropic::Models::
|
44
|
+
# @param tools [Array<Anthropic::Models::Tool, Anthropic::Models::ToolBash20250124, Anthropic::Models::ToolTextEditor20250124, Anthropic::Models::ToolTextEditor20250429, Anthropic::Models::ToolTextEditor20250728, Anthropic::Models::WebSearchTool20250305>] Definitions of tools that the model may use.
|
45
45
|
#
|
46
46
|
# @param top_k [Integer] Only sample from the top K options for each subsequent token.
|
47
47
|
#
|
@@ -180,7 +180,7 @@ module Anthropic
|
|
180
180
|
#
|
181
181
|
# @param tool_choice [Anthropic::Models::ToolChoiceAuto, Anthropic::Models::ToolChoiceAny, Anthropic::Models::ToolChoiceTool, Anthropic::Models::ToolChoiceNone] How the model should use the provided tools. The model can use a specific tool,
|
182
182
|
#
|
183
|
-
# @param tools [Array<Anthropic::Models::Tool, Anthropic::Models::ToolBash20250124, Anthropic::Models::ToolTextEditor20250124, Anthropic::Models::
|
183
|
+
# @param tools [Array<Anthropic::Models::Tool, Anthropic::Models::ToolBash20250124, Anthropic::Models::ToolTextEditor20250124, Anthropic::Models::ToolTextEditor20250429, Anthropic::Models::ToolTextEditor20250728, Anthropic::Models::WebSearchTool20250305>] Definitions of tools that the model may use.
|
184
184
|
#
|
185
185
|
# @param top_k [Integer] Only sample from the top K options for each subsequent token.
|
186
186
|
#
|
@@ -232,7 +232,7 @@ module Anthropic
|
|
232
232
|
#
|
233
233
|
# @param tool_choice [Anthropic::Models::ToolChoiceAuto, Anthropic::Models::ToolChoiceAny, Anthropic::Models::ToolChoiceTool, Anthropic::Models::ToolChoiceNone] How the model should use the provided tools. The model can use a specific tool,
|
234
234
|
#
|
235
|
-
# @param tools [Array<Anthropic::Models::Tool, Anthropic::Models::ToolBash20250124, Anthropic::Models::ToolTextEditor20250124, Anthropic::Models::
|
235
|
+
# @param tools [Array<Anthropic::Models::Tool, Anthropic::Models::ToolBash20250124, Anthropic::Models::ToolTextEditor20250124, Anthropic::Models::ToolTextEditor20250429, Anthropic::Models::ToolTextEditor20250728, Anthropic::Models::WebSearchTool20250305>] Definitions of tools that the model may use.
|
236
236
|
#
|
237
237
|
# @param request_options [Anthropic::RequestOptions, Hash{Symbol=>Object}, nil]
|
238
238
|
#
|
data/lib/anthropic/version.rb
CHANGED
data/lib/anthropic.rb
CHANGED
@@ -158,6 +158,7 @@ require_relative "anthropic/models/beta/beta_tool_result_block_param"
|
|
158
158
|
require_relative "anthropic/models/beta/beta_tool_text_editor_20241022"
|
159
159
|
require_relative "anthropic/models/beta/beta_tool_text_editor_20250124"
|
160
160
|
require_relative "anthropic/models/beta/beta_tool_text_editor_20250429"
|
161
|
+
require_relative "anthropic/models/beta/beta_tool_text_editor_20250728"
|
161
162
|
require_relative "anthropic/models/beta/beta_tool_union"
|
162
163
|
require_relative "anthropic/models/beta/beta_tool_use_block"
|
163
164
|
require_relative "anthropic/models/beta/beta_tool_use_block_param"
|
@@ -303,6 +304,8 @@ require_relative "anthropic/models/tool_choice_none"
|
|
303
304
|
require_relative "anthropic/models/tool_choice_tool"
|
304
305
|
require_relative "anthropic/models/tool_result_block_param"
|
305
306
|
require_relative "anthropic/models/tool_text_editor_20250124"
|
307
|
+
require_relative "anthropic/models/tool_text_editor_20250429"
|
308
|
+
require_relative "anthropic/models/tool_text_editor_20250728"
|
306
309
|
require_relative "anthropic/models/tool_union"
|
307
310
|
require_relative "anthropic/models/tool_use_block"
|
308
311
|
require_relative "anthropic/models/tool_use_block_param"
|
@@ -21,10 +21,15 @@ module Anthropic
|
|
21
21
|
# @api private
|
22
22
|
sig do
|
23
23
|
override
|
24
|
-
.params(
|
24
|
+
.params(
|
25
|
+
req:
|
26
|
+
Anthropic::Internal::Transport::BaseClient::RequestComponents,
|
27
|
+
opts: Anthropic::Internal::AnyHash
|
28
|
+
)
|
25
29
|
.returns(Anthropic::Internal::Transport::BaseClient::RequestInput)
|
26
30
|
end
|
27
|
-
private def build_request(req, opts)
|
31
|
+
private def build_request(req, opts)
|
32
|
+
end
|
28
33
|
|
29
34
|
sig do
|
30
35
|
params(
|
@@ -45,10 +50,15 @@ module Anthropic
|
|
45
50
|
end
|
46
51
|
|
47
52
|
sig do
|
48
|
-
params(
|
49
|
-
|
53
|
+
params(
|
54
|
+
request_components:
|
55
|
+
Anthropic::Internal::Transport::BaseClient::RequestComponents
|
56
|
+
).returns(
|
57
|
+
Anthropic::Internal::Transport::BaseClient::RequestComponents
|
58
|
+
)
|
59
|
+
end
|
60
|
+
private def fit_req_to_bedrock_specs!(request_components)
|
50
61
|
end
|
51
|
-
private def fit_req_to_bedrock_specs!(request_components) end
|
52
62
|
|
53
63
|
sig do
|
54
64
|
params(
|
@@ -75,7 +85,8 @@ module Anthropic
|
|
75
85
|
aws_secret_key: nil,
|
76
86
|
aws_session_token: nil,
|
77
87
|
aws_profile: nil
|
78
|
-
)
|
88
|
+
)
|
89
|
+
end
|
79
90
|
end
|
80
91
|
end
|
81
92
|
end
|
@@ -61,7 +61,11 @@ module Anthropic
|
|
61
61
|
sig { returns(Anthropic::Models::Message) }
|
62
62
|
attr_accessor :message
|
63
63
|
|
64
|
-
sig
|
64
|
+
sig do
|
65
|
+
params(message: Anthropic::Models::Message, type: Symbol).returns(
|
66
|
+
T.attached_class
|
67
|
+
)
|
68
|
+
end
|
65
69
|
def self.new(message:, type: :message_stop)
|
66
70
|
end
|
67
71
|
end
|
@@ -76,7 +80,13 @@ module Anthropic
|
|
76
80
|
sig { returns(Anthropic::Models::ContentBlock) }
|
77
81
|
attr_accessor :content_block
|
78
82
|
|
79
|
-
sig
|
83
|
+
sig do
|
84
|
+
params(
|
85
|
+
index: Integer,
|
86
|
+
content_block: Anthropic::Models::ContentBlock,
|
87
|
+
type: Symbol
|
88
|
+
).returns(T.attached_class)
|
89
|
+
end
|
80
90
|
def self.new(index:, content_block:, type: :content_block_stop)
|
81
91
|
end
|
82
92
|
end
|
@@ -3,56 +3,70 @@
|
|
3
3
|
module Anthropic
|
4
4
|
module Helpers
|
5
5
|
module Streaming
|
6
|
-
RawMessageEvent =
|
7
|
-
T.
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
RawMessageEvent =
|
7
|
+
T.type_alias do
|
8
|
+
T.any(
|
9
|
+
Anthropic::Models::RawMessageStartEvent,
|
10
|
+
Anthropic::Models::RawMessageDeltaEvent,
|
11
|
+
Anthropic::Models::RawMessageStopEvent,
|
12
|
+
Anthropic::Models::RawContentBlockStartEvent,
|
13
|
+
Anthropic::Models::RawContentBlockDeltaEvent,
|
14
|
+
Anthropic::Models::RawContentBlockStopEvent
|
15
|
+
)
|
16
|
+
end
|
16
17
|
|
17
|
-
StreamEvent =
|
18
|
-
T.
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
18
|
+
StreamEvent =
|
19
|
+
T.type_alias do
|
20
|
+
T.any(
|
21
|
+
Anthropic::Streaming::RawMessageEvent,
|
22
|
+
Anthropic::Streaming::TextEvent,
|
23
|
+
Anthropic::Streaming::CitationEvent,
|
24
|
+
Anthropic::Streaming::ThinkingEvent,
|
25
|
+
Anthropic::Streaming::SignatureEvent,
|
26
|
+
Anthropic::Streaming::InputJsonEvent,
|
27
|
+
Anthropic::Streaming::MessageStopEvent,
|
28
|
+
Anthropic::Streaming::ContentBlockStopEvent
|
29
|
+
)
|
30
|
+
end
|
29
31
|
|
30
32
|
class MessageStream
|
31
33
|
include Anthropic::Internal::Type::BaseStream
|
32
34
|
|
33
35
|
Message =
|
34
|
-
type_member(:in)
|
35
|
-
|
36
|
-
|
37
|
-
Elem = type_member(:out) { {fixed: Anthropic::Streaming::StreamEvent} }
|
36
|
+
type_member(:in) { { fixed: Anthropic::Streaming::RawMessageEvent } }
|
37
|
+
Elem =
|
38
|
+
type_member(:out) { { fixed: Anthropic::Streaming::StreamEvent } }
|
38
39
|
|
39
|
-
sig
|
40
|
-
|
40
|
+
sig do
|
41
|
+
params(raw_stream: Anthropic::Internal::Stream[RawMessageEvent]).void
|
42
|
+
end
|
43
|
+
def initialize(raw_stream:)
|
44
|
+
end
|
41
45
|
|
42
46
|
sig { void }
|
43
|
-
def until_done
|
47
|
+
def until_done
|
48
|
+
end
|
44
49
|
|
45
50
|
sig { returns(T::Enumerator[String]) }
|
46
|
-
def text
|
51
|
+
def text
|
52
|
+
end
|
47
53
|
|
48
54
|
sig { returns(Anthropic::Models::Message) }
|
49
|
-
def accumulated_message
|
55
|
+
def accumulated_message
|
56
|
+
end
|
50
57
|
|
51
58
|
sig { returns(String) }
|
52
|
-
def accumulated_text
|
59
|
+
def accumulated_text
|
60
|
+
end
|
53
61
|
|
54
|
-
sig
|
55
|
-
|
62
|
+
sig do
|
63
|
+
params(
|
64
|
+
event: Anthropic::Streaming::RawMessageEvent,
|
65
|
+
current_snapshot: T.nilable(Anthropic::Models::Message)
|
66
|
+
).returns(Anthropic::Models::Message)
|
67
|
+
end
|
68
|
+
private def accumulate_event(event:, current_snapshot:)
|
69
|
+
end
|
56
70
|
end
|
57
71
|
end
|
58
72
|
end
|
@@ -21,16 +21,26 @@ module Anthropic
|
|
21
21
|
# @api private
|
22
22
|
sig do
|
23
23
|
override
|
24
|
-
.params(
|
24
|
+
.params(
|
25
|
+
req:
|
26
|
+
Anthropic::Internal::Transport::BaseClient::RequestComponents,
|
27
|
+
opts: Anthropic::Internal::AnyHash
|
28
|
+
)
|
25
29
|
.returns(Anthropic::Internal::Transport::BaseClient::RequestInput)
|
26
30
|
end
|
27
|
-
private def build_request(req, opts)
|
31
|
+
private def build_request(req, opts)
|
32
|
+
end
|
28
33
|
|
29
34
|
sig do
|
30
|
-
params(
|
31
|
-
|
35
|
+
params(
|
36
|
+
request_components:
|
37
|
+
Anthropic::Internal::Transport::BaseClient::RequestComponents
|
38
|
+
).returns(
|
39
|
+
Anthropic::Internal::Transport::BaseClient::RequestComponents
|
40
|
+
)
|
41
|
+
end
|
42
|
+
private def fit_req_to_vertex_specs!(request_components)
|
32
43
|
end
|
33
|
-
private def fit_req_to_vertex_specs!(request_components) end
|
34
44
|
|
35
45
|
sig do
|
36
46
|
params(
|
@@ -51,7 +61,8 @@ module Anthropic
|
|
51
61
|
timeout: Anthropic::Client::DEFAULT_TIMEOUT_IN_SECONDS,
|
52
62
|
initial_retry_delay: Anthropic::Client::DEFAULT_INITIAL_RETRY_DELAY,
|
53
63
|
max_retry_delay: Anthropic::Client::DEFAULT_MAX_RETRY_DELAY
|
54
|
-
)
|
64
|
+
)
|
65
|
+
end
|
55
66
|
end
|
56
67
|
end
|
57
68
|
end
|
@@ -26,6 +26,9 @@ module Anthropic
|
|
26
26
|
sig { returns(Integer) }
|
27
27
|
attr_accessor :end_char_index
|
28
28
|
|
29
|
+
sig { returns(T.nilable(String)) }
|
30
|
+
attr_accessor :file_id
|
31
|
+
|
29
32
|
sig { returns(Integer) }
|
30
33
|
attr_accessor :start_char_index
|
31
34
|
|
@@ -38,6 +41,7 @@ module Anthropic
|
|
38
41
|
document_index: Integer,
|
39
42
|
document_title: T.nilable(String),
|
40
43
|
end_char_index: Integer,
|
44
|
+
file_id: T.nilable(String),
|
41
45
|
start_char_index: Integer,
|
42
46
|
type: Symbol
|
43
47
|
).returns(T.attached_class)
|
@@ -47,6 +51,7 @@ module Anthropic
|
|
47
51
|
document_index:,
|
48
52
|
document_title:,
|
49
53
|
end_char_index:,
|
54
|
+
file_id:,
|
50
55
|
start_char_index:,
|
51
56
|
type: :char_location
|
52
57
|
)
|
@@ -59,6 +64,7 @@ module Anthropic
|
|
59
64
|
document_index: Integer,
|
60
65
|
document_title: T.nilable(String),
|
61
66
|
end_char_index: Integer,
|
67
|
+
file_id: T.nilable(String),
|
62
68
|
start_char_index: Integer,
|
63
69
|
type: Symbol
|
64
70
|
}
|
@@ -26,6 +26,9 @@ module Anthropic
|
|
26
26
|
sig { returns(Integer) }
|
27
27
|
attr_accessor :end_block_index
|
28
28
|
|
29
|
+
sig { returns(T.nilable(String)) }
|
30
|
+
attr_accessor :file_id
|
31
|
+
|
29
32
|
sig { returns(Integer) }
|
30
33
|
attr_accessor :start_block_index
|
31
34
|
|
@@ -38,6 +41,7 @@ module Anthropic
|
|
38
41
|
document_index: Integer,
|
39
42
|
document_title: T.nilable(String),
|
40
43
|
end_block_index: Integer,
|
44
|
+
file_id: T.nilable(String),
|
41
45
|
start_block_index: Integer,
|
42
46
|
type: Symbol
|
43
47
|
).returns(T.attached_class)
|
@@ -47,6 +51,7 @@ module Anthropic
|
|
47
51
|
document_index:,
|
48
52
|
document_title:,
|
49
53
|
end_block_index:,
|
54
|
+
file_id:,
|
50
55
|
start_block_index:,
|
51
56
|
type: :content_block_location
|
52
57
|
)
|
@@ -59,6 +64,7 @@ module Anthropic
|
|
59
64
|
document_index: Integer,
|
60
65
|
document_title: T.nilable(String),
|
61
66
|
end_block_index: Integer,
|
67
|
+
file_id: T.nilable(String),
|
62
68
|
start_block_index: Integer,
|
63
69
|
type: Symbol
|
64
70
|
}
|
@@ -26,6 +26,9 @@ module Anthropic
|
|
26
26
|
sig { returns(Integer) }
|
27
27
|
attr_accessor :end_page_number
|
28
28
|
|
29
|
+
sig { returns(T.nilable(String)) }
|
30
|
+
attr_accessor :file_id
|
31
|
+
|
29
32
|
sig { returns(Integer) }
|
30
33
|
attr_accessor :start_page_number
|
31
34
|
|
@@ -38,6 +41,7 @@ module Anthropic
|
|
38
41
|
document_index: Integer,
|
39
42
|
document_title: T.nilable(String),
|
40
43
|
end_page_number: Integer,
|
44
|
+
file_id: T.nilable(String),
|
41
45
|
start_page_number: Integer,
|
42
46
|
type: Symbol
|
43
47
|
).returns(T.attached_class)
|
@@ -47,6 +51,7 @@ module Anthropic
|
|
47
51
|
document_index:,
|
48
52
|
document_title:,
|
49
53
|
end_page_number:,
|
54
|
+
file_id:,
|
50
55
|
start_page_number:,
|
51
56
|
type: :page_location
|
52
57
|
)
|
@@ -59,6 +64,7 @@ module Anthropic
|
|
59
64
|
document_index: Integer,
|
60
65
|
document_title: T.nilable(String),
|
61
66
|
end_page_number: Integer,
|
67
|
+
file_id: T.nilable(String),
|
62
68
|
start_page_number: Integer,
|
63
69
|
type: Symbol
|
64
70
|
}
|