anthropic 1.13.0 → 1.15.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 +27 -0
- data/README.md +31 -1
- data/lib/anthropic/helpers/input_schema/base_model.rb +6 -3
- data/lib/anthropic/helpers/input_schema/json_schema_converter.rb +9 -3
- data/lib/anthropic/helpers/input_schema/supported_schemas.rb +106 -0
- data/lib/anthropic/helpers/input_schema/union_of.rb +3 -1
- data/lib/anthropic/helpers/messages.rb +107 -0
- data/lib/anthropic/helpers/streaming/message_stream.rb +54 -43
- data/lib/anthropic/helpers/tools/base_tool.rb +82 -0
- data/lib/anthropic/helpers/tools/runner.rb +156 -0
- data/lib/anthropic/helpers/tools.rb +5 -0
- data/lib/anthropic/internal/transport/base_client.rb +7 -1
- data/lib/anthropic/internal/transport/pooled_net_requester.rb +6 -2
- data/lib/anthropic/models/beta/beta_code_execution_tool_20250522.rb +8 -1
- data/lib/anthropic/models/beta/beta_code_execution_tool_20250825.rb +8 -1
- data/lib/anthropic/models/beta/beta_json_output_format.rb +27 -0
- data/lib/anthropic/models/beta/beta_memory_tool_20250818.rb +8 -1
- data/lib/anthropic/models/beta/beta_tool.rb +8 -1
- data/lib/anthropic/models/beta/beta_tool_bash_20241022.rb +8 -1
- data/lib/anthropic/models/beta/beta_tool_bash_20250124.rb +8 -1
- data/lib/anthropic/models/beta/beta_tool_computer_use_20241022.rb +8 -1
- data/lib/anthropic/models/beta/beta_tool_computer_use_20250124.rb +8 -1
- data/lib/anthropic/models/beta/beta_tool_text_editor_20241022.rb +8 -1
- data/lib/anthropic/models/beta/beta_tool_text_editor_20250124.rb +8 -1
- data/lib/anthropic/models/beta/beta_tool_text_editor_20250429.rb +8 -1
- data/lib/anthropic/models/beta/beta_tool_text_editor_20250728.rb +8 -1
- data/lib/anthropic/models/beta/beta_tool_use_block.rb +14 -0
- data/lib/anthropic/models/beta/beta_web_fetch_tool_20250910.rb +8 -1
- data/lib/anthropic/models/beta/beta_web_search_tool_20250305.rb +8 -1
- data/lib/anthropic/models/beta/message_count_tokens_params.rb +9 -1
- data/lib/anthropic/models/beta/message_create_params.rb +9 -1
- data/lib/anthropic/models/beta/messages/batch_create_params.rb +9 -1
- data/lib/anthropic/models/tool_use_block.rb +6 -6
- data/lib/anthropic/resources/beta/messages/batches.rb +6 -6
- data/lib/anthropic/resources/beta/messages.rb +37 -11
- data/lib/anthropic/resources/messages/batches.rb +6 -6
- data/lib/anthropic/resources/messages.rb +12 -84
- data/lib/anthropic/version.rb +1 -1
- data/lib/anthropic.rb +16 -10
- data/manifest.yaml +1 -0
- data/rbi/anthropic/helpers/input_schema/base_model.rbi +7 -2
- data/rbi/anthropic/helpers/tools/base_tool.rbi +51 -0
- data/rbi/anthropic/helpers/tools/runner.rbi +40 -0
- data/rbi/anthropic/helpers/tools.rbi +5 -0
- data/rbi/anthropic/internal/transport/base_client.rbi +5 -0
- data/rbi/anthropic/internal/transport/pooled_net_requester.rbi +6 -2
- data/rbi/anthropic/internal/type/base_model.rbi +8 -4
- data/rbi/anthropic/models/beta/beta_code_execution_tool_20250522.rbi +10 -1
- data/rbi/anthropic/models/beta/beta_code_execution_tool_20250825.rbi +10 -1
- data/rbi/anthropic/models/beta/beta_json_output_format.rbi +46 -0
- data/rbi/anthropic/models/beta/beta_memory_tool_20250818.rbi +10 -1
- data/rbi/anthropic/models/beta/beta_tool.rbi +9 -0
- data/rbi/anthropic/models/beta/beta_tool_bash_20241022.rbi +10 -1
- data/rbi/anthropic/models/beta/beta_tool_bash_20250124.rbi +10 -1
- data/rbi/anthropic/models/beta/beta_tool_computer_use_20241022.rbi +10 -1
- data/rbi/anthropic/models/beta/beta_tool_computer_use_20250124.rbi +10 -1
- data/rbi/anthropic/models/beta/beta_tool_text_editor_20241022.rbi +10 -1
- data/rbi/anthropic/models/beta/beta_tool_text_editor_20250124.rbi +10 -1
- data/rbi/anthropic/models/beta/beta_tool_text_editor_20250429.rbi +10 -1
- data/rbi/anthropic/models/beta/beta_tool_text_editor_20250728.rbi +10 -1
- data/rbi/anthropic/models/beta/beta_web_fetch_tool_20250910.rbi +10 -1
- data/rbi/anthropic/models/beta/beta_web_search_tool_20250305.rbi +9 -0
- data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +17 -0
- data/rbi/anthropic/models/beta/message_create_params.rbi +17 -0
- data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +18 -0
- data/rbi/anthropic/models/tool_use_block.rbi +3 -0
- data/rbi/anthropic/resources/beta/messages/batches.rbi +6 -6
- data/rbi/anthropic/resources/beta/messages.rbi +313 -3
- data/rbi/anthropic/resources/messages/batches.rbi +6 -6
- data/rbi/anthropic/resources/messages.rbi +5 -3
- data/sig/anthropic/internal/transport/base_client.rbs +2 -0
- data/sig/anthropic/internal/transport/pooled_net_requester.rbs +4 -1
- data/sig/anthropic/models/beta/beta_code_execution_tool_20250522.rbs +9 -2
- data/sig/anthropic/models/beta/beta_code_execution_tool_20250825.rbs +9 -2
- data/sig/anthropic/models/beta/beta_json_output_format.rbs +23 -0
- data/sig/anthropic/models/beta/beta_memory_tool_20250818.rbs +9 -2
- data/sig/anthropic/models/beta/beta_tool.rbs +7 -0
- data/sig/anthropic/models/beta/beta_tool_bash_20241022.rbs +9 -2
- data/sig/anthropic/models/beta/beta_tool_bash_20250124.rbs +9 -2
- data/sig/anthropic/models/beta/beta_tool_computer_use_20241022.rbs +9 -2
- data/sig/anthropic/models/beta/beta_tool_computer_use_20250124.rbs +9 -2
- data/sig/anthropic/models/beta/beta_tool_text_editor_20241022.rbs +9 -2
- data/sig/anthropic/models/beta/beta_tool_text_editor_20250124.rbs +9 -2
- data/sig/anthropic/models/beta/beta_tool_text_editor_20250429.rbs +9 -2
- data/sig/anthropic/models/beta/beta_tool_text_editor_20250728.rbs +9 -2
- data/sig/anthropic/models/beta/beta_web_fetch_tool_20250910.rbs +9 -2
- data/sig/anthropic/models/beta/beta_web_search_tool_20250305.rbs +7 -0
- data/sig/anthropic/models/beta/message_count_tokens_params.rbs +5 -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/resources/beta/messages.rbs +3 -0
- metadata +14 -4
- data/lib/anthropic/helpers/input_schema/property_mapping.rb +0 -47
- /data/rbi/anthropic/helpers/{structured_output.rbi → input_schema.rbi} +0 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Anthropic
|
|
4
|
+
module Helpers
|
|
5
|
+
module Tools
|
|
6
|
+
# @api private
|
|
7
|
+
#
|
|
8
|
+
class Runner
|
|
9
|
+
# @return [Anthropic::Models::Beta::MessageCreateParams]
|
|
10
|
+
attr_accessor :params
|
|
11
|
+
|
|
12
|
+
# @return [Boolean]
|
|
13
|
+
def finished? = @finished
|
|
14
|
+
|
|
15
|
+
# @param params [Array<Anthropic::Beta::BetaMessageParam>]
|
|
16
|
+
def feed_messages(*messages)
|
|
17
|
+
self.params = {**params.to_h, messages: params[:messages].to_a + messages}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# @return [Array<Anthropic::Beta::BetaMessageParam>]
|
|
21
|
+
private def current_messages = params&.[](:messages).to_a
|
|
22
|
+
|
|
23
|
+
# @return [Anthropic::Models::BetaMessage, nil]
|
|
24
|
+
def next_message
|
|
25
|
+
message = nil
|
|
26
|
+
unless finished?
|
|
27
|
+
fold do
|
|
28
|
+
message = @client.beta.messages.create(_1)
|
|
29
|
+
[true, message]
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
message
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @return [Array<Anthropic::Models::BetaMessage>]
|
|
36
|
+
def run_until_finished
|
|
37
|
+
messages = []
|
|
38
|
+
each_streaming { messages << _1.accumulated_message }
|
|
39
|
+
messages
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# @yieldparam [Anthropic::Models::BetaMessage]
|
|
43
|
+
def each_message(&blk)
|
|
44
|
+
unless block_given?
|
|
45
|
+
raise ArgumentError.new("A block must be given to ##{__method__}")
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
fold do
|
|
49
|
+
message = @client.beta.messages.create(_1)
|
|
50
|
+
blk.call(message)
|
|
51
|
+
[false, message]
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# @yieldparam [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>]
|
|
56
|
+
def each_streaming(&blk)
|
|
57
|
+
unless block_given?
|
|
58
|
+
raise ArgumentError.new("A block must be given to ##{__method__}")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
fold do
|
|
62
|
+
stream = @client.beta.messages.stream(_1)
|
|
63
|
+
blk.call(stream)
|
|
64
|
+
[false, stream.accumulated_message]
|
|
65
|
+
ensure
|
|
66
|
+
stream&.close
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# @api private
|
|
71
|
+
#
|
|
72
|
+
# @yieldparam [Array(Boolean, Anthropic::Models::Beta::MessageCreateParams)]
|
|
73
|
+
private def fold(&blk)
|
|
74
|
+
return nil if finished?
|
|
75
|
+
|
|
76
|
+
count =
|
|
77
|
+
case @param
|
|
78
|
+
in {max_iterations: Integer => m}
|
|
79
|
+
m
|
|
80
|
+
else
|
|
81
|
+
nil
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# rubocop:disable Metrics/BlockLength
|
|
85
|
+
# rubocop:disable Style/CaseEquality
|
|
86
|
+
loop do
|
|
87
|
+
return if (count = count&.pred)&.negative?
|
|
88
|
+
|
|
89
|
+
tools = params[:tools].to_a.grep(Anthropic::Helpers::Tools::BaseTool)
|
|
90
|
+
messages = current_messages
|
|
91
|
+
brk, response = blk.call(params)
|
|
92
|
+
|
|
93
|
+
next unless current_messages.equal?(messages)
|
|
94
|
+
|
|
95
|
+
mapped =
|
|
96
|
+
response
|
|
97
|
+
.content
|
|
98
|
+
.lazy
|
|
99
|
+
.grep(Anthropic::Beta::BetaToolUseBlock)
|
|
100
|
+
.map do |tool_use|
|
|
101
|
+
resp = {type: :tool_result, tool_use_id: tool_use.id}
|
|
102
|
+
if (tool = tools.find { _1.class.model === tool_use.parsed })
|
|
103
|
+
begin
|
|
104
|
+
raw = tool.call(tool_use.parsed)
|
|
105
|
+
is_error = false
|
|
106
|
+
rescue StandardError => e
|
|
107
|
+
is_error = true
|
|
108
|
+
raw = e.message
|
|
109
|
+
end
|
|
110
|
+
else
|
|
111
|
+
is_error = true
|
|
112
|
+
raw = "Error: parsed '#{tool_use.name}' not found"
|
|
113
|
+
end
|
|
114
|
+
content = raw.is_a?(Array) ? raw : raw.to_s
|
|
115
|
+
{**resp, content:, is_error:}
|
|
116
|
+
end
|
|
117
|
+
.to_a
|
|
118
|
+
|
|
119
|
+
if mapped.empty?
|
|
120
|
+
@finished = true
|
|
121
|
+
break
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
content = response.content.map do
|
|
125
|
+
case _1
|
|
126
|
+
in Anthropic::Beta::BetaToolUseBlock
|
|
127
|
+
raw = {**_1, input: _1.parsed}.except(:parsed)
|
|
128
|
+
Anthropic::Internal::Type::Converter.dump(Anthropic::Beta::BetaToolUseBlock, raw)
|
|
129
|
+
else
|
|
130
|
+
_1
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
messages << {role: :assistant, content:}
|
|
135
|
+
messages << {role: :user, content: mapped}
|
|
136
|
+
|
|
137
|
+
break if brk
|
|
138
|
+
end
|
|
139
|
+
# rubocop:enable Style/CaseEquality
|
|
140
|
+
# rubocop:enable Metrics/BlockLength
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# @api private
|
|
144
|
+
#
|
|
145
|
+
# @param client [Anthropic::Client]
|
|
146
|
+
#
|
|
147
|
+
# @param params [Anthropic::Models::Beta::MessageCreateParams]
|
|
148
|
+
def initialize(client, params:)
|
|
149
|
+
@client = client
|
|
150
|
+
@params = params.to_h
|
|
151
|
+
@finished = false
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
@@ -201,7 +201,8 @@ module Anthropic
|
|
|
201
201
|
self.class::PLATFORM_HEADERS,
|
|
202
202
|
{
|
|
203
203
|
"accept" => "application/json",
|
|
204
|
-
"content-type" => "application/json"
|
|
204
|
+
"content-type" => "application/json",
|
|
205
|
+
"user-agent" => user_agent
|
|
205
206
|
},
|
|
206
207
|
headers
|
|
207
208
|
)
|
|
@@ -219,6 +220,11 @@ module Anthropic
|
|
|
219
220
|
# @return [Hash{String=>String}]
|
|
220
221
|
private def auth_headers = {}
|
|
221
222
|
|
|
223
|
+
# @api private
|
|
224
|
+
#
|
|
225
|
+
# @return [String]
|
|
226
|
+
private def user_agent = "#{self.class.name}/Ruby #{Anthropic::VERSION}"
|
|
227
|
+
|
|
222
228
|
# @api private
|
|
223
229
|
#
|
|
224
230
|
# @return [String]
|
|
@@ -16,10 +16,11 @@ module Anthropic
|
|
|
16
16
|
class << self
|
|
17
17
|
# @api private
|
|
18
18
|
#
|
|
19
|
+
# @param cert_store [OpenSSL::X509::Store]
|
|
19
20
|
# @param url [URI::Generic]
|
|
20
21
|
#
|
|
21
22
|
# @return [Net::HTTP]
|
|
22
|
-
def connect(url)
|
|
23
|
+
def connect(cert_store:, url:)
|
|
23
24
|
port =
|
|
24
25
|
case [url.port, url.scheme]
|
|
25
26
|
in [Integer, _]
|
|
@@ -33,6 +34,8 @@ module Anthropic
|
|
|
33
34
|
Net::HTTP.new(url.host, port).tap do
|
|
34
35
|
_1.use_ssl = %w[https wss].include?(url.scheme)
|
|
35
36
|
_1.max_retries = 0
|
|
37
|
+
|
|
38
|
+
(_1.cert_store = cert_store) if _1.use_ssl?
|
|
36
39
|
end
|
|
37
40
|
end
|
|
38
41
|
|
|
@@ -102,7 +105,7 @@ module Anthropic
|
|
|
102
105
|
pool =
|
|
103
106
|
@mutex.synchronize do
|
|
104
107
|
@pools[origin] ||= ConnectionPool.new(size: @size) do
|
|
105
|
-
self.class.connect(url)
|
|
108
|
+
self.class.connect(cert_store: @cert_store, url: url)
|
|
106
109
|
end
|
|
107
110
|
end
|
|
108
111
|
|
|
@@ -192,6 +195,7 @@ module Anthropic
|
|
|
192
195
|
def initialize(size: self.class::DEFAULT_MAX_CONNECTIONS)
|
|
193
196
|
@mutex = Mutex.new
|
|
194
197
|
@size = size
|
|
198
|
+
@cert_store = OpenSSL::X509::Store.new.tap(&:set_default_paths)
|
|
195
199
|
@pools = {}
|
|
196
200
|
end
|
|
197
201
|
|
|
@@ -23,12 +23,19 @@ module Anthropic
|
|
|
23
23
|
# @return [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil]
|
|
24
24
|
optional :cache_control, -> { Anthropic::Beta::BetaCacheControlEphemeral }, nil?: true
|
|
25
25
|
|
|
26
|
-
# @!
|
|
26
|
+
# @!attribute strict
|
|
27
|
+
#
|
|
28
|
+
# @return [Boolean, nil]
|
|
29
|
+
optional :strict, Anthropic::Internal::Type::Boolean
|
|
30
|
+
|
|
31
|
+
# @!method initialize(cache_control: nil, strict: nil, name: :code_execution, type: :code_execution_20250522)
|
|
27
32
|
# Some parameter documentations has been truncated, see
|
|
28
33
|
# {Anthropic::Models::Beta::BetaCodeExecutionTool20250522} for more details.
|
|
29
34
|
#
|
|
30
35
|
# @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
|
|
31
36
|
#
|
|
37
|
+
# @param strict [Boolean]
|
|
38
|
+
#
|
|
32
39
|
# @param name [Symbol, :code_execution] Name of the tool.
|
|
33
40
|
#
|
|
34
41
|
# @param type [Symbol, :code_execution_20250522]
|
|
@@ -23,12 +23,19 @@ module Anthropic
|
|
|
23
23
|
# @return [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil]
|
|
24
24
|
optional :cache_control, -> { Anthropic::Beta::BetaCacheControlEphemeral }, nil?: true
|
|
25
25
|
|
|
26
|
-
# @!
|
|
26
|
+
# @!attribute strict
|
|
27
|
+
#
|
|
28
|
+
# @return [Boolean, nil]
|
|
29
|
+
optional :strict, Anthropic::Internal::Type::Boolean
|
|
30
|
+
|
|
31
|
+
# @!method initialize(cache_control: nil, strict: nil, name: :code_execution, type: :code_execution_20250825)
|
|
27
32
|
# Some parameter documentations has been truncated, see
|
|
28
33
|
# {Anthropic::Models::Beta::BetaCodeExecutionTool20250825} for more details.
|
|
29
34
|
#
|
|
30
35
|
# @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
|
|
31
36
|
#
|
|
37
|
+
# @param strict [Boolean]
|
|
38
|
+
#
|
|
32
39
|
# @param name [Symbol, :code_execution] Name of the tool.
|
|
33
40
|
#
|
|
34
41
|
# @param type [Symbol, :code_execution_20250825]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Anthropic
|
|
4
|
+
module Models
|
|
5
|
+
module Beta
|
|
6
|
+
class BetaJSONOutputFormat < Anthropic::Internal::Type::BaseModel
|
|
7
|
+
# @!attribute schema
|
|
8
|
+
# The JSON schema of the format
|
|
9
|
+
#
|
|
10
|
+
# @return [Hash{Symbol=>Object}]
|
|
11
|
+
required :schema, Anthropic::Internal::Type::HashOf[Anthropic::Internal::Type::Unknown]
|
|
12
|
+
|
|
13
|
+
# @!attribute type
|
|
14
|
+
#
|
|
15
|
+
# @return [Symbol, :json_schema]
|
|
16
|
+
required :type, const: :json_schema
|
|
17
|
+
|
|
18
|
+
# @!method initialize(schema:, type: :json_schema)
|
|
19
|
+
# @param schema [Hash{Symbol=>Object}] The JSON schema of the format
|
|
20
|
+
#
|
|
21
|
+
# @param type [Symbol, :json_schema]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
BetaJSONOutputFormat = Beta::BetaJSONOutputFormat
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -23,12 +23,19 @@ module Anthropic
|
|
|
23
23
|
# @return [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil]
|
|
24
24
|
optional :cache_control, -> { Anthropic::Beta::BetaCacheControlEphemeral }, nil?: true
|
|
25
25
|
|
|
26
|
-
# @!
|
|
26
|
+
# @!attribute strict
|
|
27
|
+
#
|
|
28
|
+
# @return [Boolean, nil]
|
|
29
|
+
optional :strict, Anthropic::Internal::Type::Boolean
|
|
30
|
+
|
|
31
|
+
# @!method initialize(cache_control: nil, strict: nil, name: :memory, type: :memory_20250818)
|
|
27
32
|
# Some parameter documentations has been truncated, see
|
|
28
33
|
# {Anthropic::Models::Beta::BetaMemoryTool20250818} for more details.
|
|
29
34
|
#
|
|
30
35
|
# @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
|
|
31
36
|
#
|
|
37
|
+
# @param strict [Boolean]
|
|
38
|
+
#
|
|
32
39
|
# @param name [Symbol, :memory] Name of the tool.
|
|
33
40
|
#
|
|
34
41
|
# @param type [Symbol, :memory_20250818]
|
|
@@ -38,12 +38,17 @@ module Anthropic
|
|
|
38
38
|
# @return [String, nil]
|
|
39
39
|
optional :description, String
|
|
40
40
|
|
|
41
|
+
# @!attribute strict
|
|
42
|
+
#
|
|
43
|
+
# @return [Boolean, nil]
|
|
44
|
+
optional :strict, Anthropic::Internal::Type::Boolean
|
|
45
|
+
|
|
41
46
|
# @!attribute type
|
|
42
47
|
#
|
|
43
48
|
# @return [Symbol, Anthropic::Models::Beta::BetaTool::Type, nil]
|
|
44
49
|
optional :type, enum: -> { Anthropic::Beta::BetaTool::Type }, nil?: true
|
|
45
50
|
|
|
46
|
-
# @!method initialize(input_schema:, name:, cache_control: nil, description: nil, type: nil)
|
|
51
|
+
# @!method initialize(input_schema:, name:, cache_control: nil, description: nil, strict: nil, type: nil)
|
|
47
52
|
# Some parameter documentations has been truncated, see
|
|
48
53
|
# {Anthropic::Models::Beta::BetaTool} for more details.
|
|
49
54
|
#
|
|
@@ -55,6 +60,8 @@ module Anthropic
|
|
|
55
60
|
#
|
|
56
61
|
# @param description [String] Description of what this tool does.
|
|
57
62
|
#
|
|
63
|
+
# @param strict [Boolean]
|
|
64
|
+
#
|
|
58
65
|
# @param type [Symbol, Anthropic::Models::Beta::BetaTool::Type, nil]
|
|
59
66
|
|
|
60
67
|
# @see Anthropic::Models::Beta::BetaTool#input_schema
|
|
@@ -23,12 +23,19 @@ module Anthropic
|
|
|
23
23
|
# @return [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil]
|
|
24
24
|
optional :cache_control, -> { Anthropic::Beta::BetaCacheControlEphemeral }, nil?: true
|
|
25
25
|
|
|
26
|
-
# @!
|
|
26
|
+
# @!attribute strict
|
|
27
|
+
#
|
|
28
|
+
# @return [Boolean, nil]
|
|
29
|
+
optional :strict, Anthropic::Internal::Type::Boolean
|
|
30
|
+
|
|
31
|
+
# @!method initialize(cache_control: nil, strict: nil, name: :bash, type: :bash_20241022)
|
|
27
32
|
# Some parameter documentations has been truncated, see
|
|
28
33
|
# {Anthropic::Models::Beta::BetaToolBash20241022} for more details.
|
|
29
34
|
#
|
|
30
35
|
# @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
|
|
31
36
|
#
|
|
37
|
+
# @param strict [Boolean]
|
|
38
|
+
#
|
|
32
39
|
# @param name [Symbol, :bash] Name of the tool.
|
|
33
40
|
#
|
|
34
41
|
# @param type [Symbol, :bash_20241022]
|
|
@@ -23,12 +23,19 @@ module Anthropic
|
|
|
23
23
|
# @return [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil]
|
|
24
24
|
optional :cache_control, -> { Anthropic::Beta::BetaCacheControlEphemeral }, nil?: true
|
|
25
25
|
|
|
26
|
-
# @!
|
|
26
|
+
# @!attribute strict
|
|
27
|
+
#
|
|
28
|
+
# @return [Boolean, nil]
|
|
29
|
+
optional :strict, Anthropic::Internal::Type::Boolean
|
|
30
|
+
|
|
31
|
+
# @!method initialize(cache_control: nil, strict: nil, name: :bash, type: :bash_20250124)
|
|
27
32
|
# Some parameter documentations has been truncated, see
|
|
28
33
|
# {Anthropic::Models::Beta::BetaToolBash20250124} for more details.
|
|
29
34
|
#
|
|
30
35
|
# @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
|
|
31
36
|
#
|
|
37
|
+
# @param strict [Boolean]
|
|
38
|
+
#
|
|
32
39
|
# @param name [Symbol, :bash] Name of the tool.
|
|
33
40
|
#
|
|
34
41
|
# @param type [Symbol, :bash_20250124]
|
|
@@ -41,7 +41,12 @@ module Anthropic
|
|
|
41
41
|
# @return [Integer, nil]
|
|
42
42
|
optional :display_number, Integer, nil?: true
|
|
43
43
|
|
|
44
|
-
# @!
|
|
44
|
+
# @!attribute strict
|
|
45
|
+
#
|
|
46
|
+
# @return [Boolean, nil]
|
|
47
|
+
optional :strict, Anthropic::Internal::Type::Boolean
|
|
48
|
+
|
|
49
|
+
# @!method initialize(display_height_px:, display_width_px:, cache_control: nil, display_number: nil, strict: nil, name: :computer, type: :computer_20241022)
|
|
45
50
|
# Some parameter documentations has been truncated, see
|
|
46
51
|
# {Anthropic::Models::Beta::BetaToolComputerUse20241022} for more details.
|
|
47
52
|
#
|
|
@@ -53,6 +58,8 @@ module Anthropic
|
|
|
53
58
|
#
|
|
54
59
|
# @param display_number [Integer, nil] The X11 display number (e.g. 0, 1) for the display.
|
|
55
60
|
#
|
|
61
|
+
# @param strict [Boolean]
|
|
62
|
+
#
|
|
56
63
|
# @param name [Symbol, :computer] Name of the tool.
|
|
57
64
|
#
|
|
58
65
|
# @param type [Symbol, :computer_20241022]
|
|
@@ -41,7 +41,12 @@ module Anthropic
|
|
|
41
41
|
# @return [Integer, nil]
|
|
42
42
|
optional :display_number, Integer, nil?: true
|
|
43
43
|
|
|
44
|
-
# @!
|
|
44
|
+
# @!attribute strict
|
|
45
|
+
#
|
|
46
|
+
# @return [Boolean, nil]
|
|
47
|
+
optional :strict, Anthropic::Internal::Type::Boolean
|
|
48
|
+
|
|
49
|
+
# @!method initialize(display_height_px:, display_width_px:, cache_control: nil, display_number: nil, strict: nil, name: :computer, type: :computer_20250124)
|
|
45
50
|
# Some parameter documentations has been truncated, see
|
|
46
51
|
# {Anthropic::Models::Beta::BetaToolComputerUse20250124} for more details.
|
|
47
52
|
#
|
|
@@ -53,6 +58,8 @@ module Anthropic
|
|
|
53
58
|
#
|
|
54
59
|
# @param display_number [Integer, nil] The X11 display number (e.g. 0, 1) for the display.
|
|
55
60
|
#
|
|
61
|
+
# @param strict [Boolean]
|
|
62
|
+
#
|
|
56
63
|
# @param name [Symbol, :computer] Name of the tool.
|
|
57
64
|
#
|
|
58
65
|
# @param type [Symbol, :computer_20250124]
|
|
@@ -23,12 +23,19 @@ module Anthropic
|
|
|
23
23
|
# @return [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil]
|
|
24
24
|
optional :cache_control, -> { Anthropic::Beta::BetaCacheControlEphemeral }, nil?: true
|
|
25
25
|
|
|
26
|
-
# @!
|
|
26
|
+
# @!attribute strict
|
|
27
|
+
#
|
|
28
|
+
# @return [Boolean, nil]
|
|
29
|
+
optional :strict, Anthropic::Internal::Type::Boolean
|
|
30
|
+
|
|
31
|
+
# @!method initialize(cache_control: nil, strict: nil, name: :str_replace_editor, type: :text_editor_20241022)
|
|
27
32
|
# Some parameter documentations has been truncated, see
|
|
28
33
|
# {Anthropic::Models::Beta::BetaToolTextEditor20241022} for more details.
|
|
29
34
|
#
|
|
30
35
|
# @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
|
|
31
36
|
#
|
|
37
|
+
# @param strict [Boolean]
|
|
38
|
+
#
|
|
32
39
|
# @param name [Symbol, :str_replace_editor] Name of the tool.
|
|
33
40
|
#
|
|
34
41
|
# @param type [Symbol, :text_editor_20241022]
|
|
@@ -23,12 +23,19 @@ module Anthropic
|
|
|
23
23
|
# @return [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil]
|
|
24
24
|
optional :cache_control, -> { Anthropic::Beta::BetaCacheControlEphemeral }, nil?: true
|
|
25
25
|
|
|
26
|
-
# @!
|
|
26
|
+
# @!attribute strict
|
|
27
|
+
#
|
|
28
|
+
# @return [Boolean, nil]
|
|
29
|
+
optional :strict, Anthropic::Internal::Type::Boolean
|
|
30
|
+
|
|
31
|
+
# @!method initialize(cache_control: nil, strict: nil, name: :str_replace_editor, type: :text_editor_20250124)
|
|
27
32
|
# Some parameter documentations has been truncated, see
|
|
28
33
|
# {Anthropic::Models::Beta::BetaToolTextEditor20250124} for more details.
|
|
29
34
|
#
|
|
30
35
|
# @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
|
|
31
36
|
#
|
|
37
|
+
# @param strict [Boolean]
|
|
38
|
+
#
|
|
32
39
|
# @param name [Symbol, :str_replace_editor] Name of the tool.
|
|
33
40
|
#
|
|
34
41
|
# @param type [Symbol, :text_editor_20250124]
|
|
@@ -23,12 +23,19 @@ module Anthropic
|
|
|
23
23
|
# @return [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil]
|
|
24
24
|
optional :cache_control, -> { Anthropic::Beta::BetaCacheControlEphemeral }, nil?: true
|
|
25
25
|
|
|
26
|
-
# @!
|
|
26
|
+
# @!attribute strict
|
|
27
|
+
#
|
|
28
|
+
# @return [Boolean, nil]
|
|
29
|
+
optional :strict, Anthropic::Internal::Type::Boolean
|
|
30
|
+
|
|
31
|
+
# @!method initialize(cache_control: nil, strict: nil, name: :str_replace_based_edit_tool, type: :text_editor_20250429)
|
|
27
32
|
# Some parameter documentations has been truncated, see
|
|
28
33
|
# {Anthropic::Models::Beta::BetaToolTextEditor20250429} for more details.
|
|
29
34
|
#
|
|
30
35
|
# @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
|
|
31
36
|
#
|
|
37
|
+
# @param strict [Boolean]
|
|
38
|
+
#
|
|
32
39
|
# @param name [Symbol, :str_replace_based_edit_tool] Name of the tool.
|
|
33
40
|
#
|
|
34
41
|
# @param type [Symbol, :text_editor_20250429]
|
|
@@ -30,7 +30,12 @@ module Anthropic
|
|
|
30
30
|
# @return [Integer, nil]
|
|
31
31
|
optional :max_characters, Integer, nil?: true
|
|
32
32
|
|
|
33
|
-
# @!
|
|
33
|
+
# @!attribute strict
|
|
34
|
+
#
|
|
35
|
+
# @return [Boolean, nil]
|
|
36
|
+
optional :strict, Anthropic::Internal::Type::Boolean
|
|
37
|
+
|
|
38
|
+
# @!method initialize(cache_control: nil, max_characters: nil, strict: nil, name: :str_replace_based_edit_tool, type: :text_editor_20250728)
|
|
34
39
|
# Some parameter documentations has been truncated, see
|
|
35
40
|
# {Anthropic::Models::Beta::BetaToolTextEditor20250728} for more details.
|
|
36
41
|
#
|
|
@@ -38,6 +43,8 @@ module Anthropic
|
|
|
38
43
|
#
|
|
39
44
|
# @param max_characters [Integer, nil] Maximum number of characters to display when viewing a file. If not specified, d
|
|
40
45
|
#
|
|
46
|
+
# @param strict [Boolean]
|
|
47
|
+
#
|
|
41
48
|
# @param name [Symbol, :str_replace_based_edit_tool] Name of the tool.
|
|
42
49
|
#
|
|
43
50
|
# @param type [Symbol, :text_editor_20250728]
|
|
@@ -24,6 +24,20 @@ module Anthropic
|
|
|
24
24
|
# @return [Symbol, :tool_use]
|
|
25
25
|
required :type, const: :tool_use
|
|
26
26
|
|
|
27
|
+
response_only do
|
|
28
|
+
# @api public
|
|
29
|
+
#
|
|
30
|
+
# Parsed input data coerced to the tool's input schema model.
|
|
31
|
+
# Only present when tools are defined using the InputSchema DSL.
|
|
32
|
+
required :parsed, Anthropic::Internal::Type::Unknown
|
|
33
|
+
|
|
34
|
+
# @api private
|
|
35
|
+
#
|
|
36
|
+
# Internal buffer for accumulating partial JSON during streaming.
|
|
37
|
+
# Used by streaming helpers to reconstruct complete JSON input from deltas.
|
|
38
|
+
optional :_json_buf, String
|
|
39
|
+
end
|
|
40
|
+
|
|
27
41
|
# @!method initialize(id:, input:, name:, type: :tool_use)
|
|
28
42
|
# @param id [String]
|
|
29
43
|
# @param input [Object]
|
|
@@ -55,7 +55,12 @@ module Anthropic
|
|
|
55
55
|
# @return [Integer, nil]
|
|
56
56
|
optional :max_uses, Integer, nil?: true
|
|
57
57
|
|
|
58
|
-
# @!
|
|
58
|
+
# @!attribute strict
|
|
59
|
+
#
|
|
60
|
+
# @return [Boolean, nil]
|
|
61
|
+
optional :strict, Anthropic::Internal::Type::Boolean
|
|
62
|
+
|
|
63
|
+
# @!method initialize(allowed_domains: nil, blocked_domains: nil, cache_control: nil, citations: nil, max_content_tokens: nil, max_uses: nil, strict: nil, name: :web_fetch, type: :web_fetch_20250910)
|
|
59
64
|
# Some parameter documentations has been truncated, see
|
|
60
65
|
# {Anthropic::Models::Beta::BetaWebFetchTool20250910} for more details.
|
|
61
66
|
#
|
|
@@ -71,6 +76,8 @@ module Anthropic
|
|
|
71
76
|
#
|
|
72
77
|
# @param max_uses [Integer, nil] Maximum number of times the tool can be used in the API request.
|
|
73
78
|
#
|
|
79
|
+
# @param strict [Boolean]
|
|
80
|
+
#
|
|
74
81
|
# @param name [Symbol, :web_fetch] Name of the tool.
|
|
75
82
|
#
|
|
76
83
|
# @param type [Symbol, :web_fetch_20250910]
|
|
@@ -43,6 +43,11 @@ module Anthropic
|
|
|
43
43
|
# @return [Integer, nil]
|
|
44
44
|
optional :max_uses, Integer, nil?: true
|
|
45
45
|
|
|
46
|
+
# @!attribute strict
|
|
47
|
+
#
|
|
48
|
+
# @return [Boolean, nil]
|
|
49
|
+
optional :strict, Anthropic::Internal::Type::Boolean
|
|
50
|
+
|
|
46
51
|
# @!attribute user_location
|
|
47
52
|
# Parameters for the user's location. Used to provide more relevant search
|
|
48
53
|
# results.
|
|
@@ -50,7 +55,7 @@ module Anthropic
|
|
|
50
55
|
# @return [Anthropic::Models::Beta::BetaWebSearchTool20250305::UserLocation, nil]
|
|
51
56
|
optional :user_location, -> { Anthropic::Beta::BetaWebSearchTool20250305::UserLocation }, nil?: true
|
|
52
57
|
|
|
53
|
-
# @!method initialize(allowed_domains: nil, blocked_domains: nil, cache_control: nil, max_uses: nil, user_location: nil, name: :web_search, type: :web_search_20250305)
|
|
58
|
+
# @!method initialize(allowed_domains: nil, blocked_domains: nil, cache_control: nil, max_uses: nil, strict: nil, user_location: nil, name: :web_search, type: :web_search_20250305)
|
|
54
59
|
# Some parameter documentations has been truncated, see
|
|
55
60
|
# {Anthropic::Models::Beta::BetaWebSearchTool20250305} for more details.
|
|
56
61
|
#
|
|
@@ -62,6 +67,8 @@ module Anthropic
|
|
|
62
67
|
#
|
|
63
68
|
# @param max_uses [Integer, nil] Maximum number of times the tool can be used in the API request.
|
|
64
69
|
#
|
|
70
|
+
# @param strict [Boolean]
|
|
71
|
+
#
|
|
65
72
|
# @param user_location [Anthropic::Models::Beta::BetaWebSearchTool20250305::UserLocation, nil] Parameters for the user's location. Used to provide more relevant search results
|
|
66
73
|
#
|
|
67
74
|
# @param name [Symbol, :web_search] Name of the tool.
|
|
@@ -102,6 +102,12 @@ module Anthropic
|
|
|
102
102
|
optional :mcp_servers,
|
|
103
103
|
-> { Anthropic::Internal::Type::ArrayOf[Anthropic::Beta::BetaRequestMCPServerURLDefinition] }
|
|
104
104
|
|
|
105
|
+
# @!attribute output_format
|
|
106
|
+
# A schema to specify Claude's output format in responses.
|
|
107
|
+
#
|
|
108
|
+
# @return [Anthropic::Models::Beta::BetaJSONOutputFormat, nil]
|
|
109
|
+
optional :output_format, -> { Anthropic::Beta::BetaJSONOutputFormat }, nil?: true
|
|
110
|
+
|
|
105
111
|
# @!attribute system_
|
|
106
112
|
# System prompt.
|
|
107
113
|
#
|
|
@@ -220,7 +226,7 @@ module Anthropic
|
|
|
220
226
|
# @return [Array<String, Symbol, Anthropic::Models::AnthropicBeta>, nil]
|
|
221
227
|
optional :betas, -> { Anthropic::Internal::Type::ArrayOf[union: Anthropic::AnthropicBeta] }
|
|
222
228
|
|
|
223
|
-
# @!method initialize(messages:, model:, context_management: nil, mcp_servers: nil, system_: nil, thinking: nil, tool_choice: nil, tools: nil, betas: nil, request_options: {})
|
|
229
|
+
# @!method initialize(messages:, model:, context_management: nil, mcp_servers: nil, output_format: nil, system_: nil, thinking: nil, tool_choice: nil, tools: nil, betas: nil, request_options: {})
|
|
224
230
|
# Some parameter documentations has been truncated, see
|
|
225
231
|
# {Anthropic::Models::Beta::MessageCountTokensParams} for more details.
|
|
226
232
|
#
|
|
@@ -232,6 +238,8 @@ module Anthropic
|
|
|
232
238
|
#
|
|
233
239
|
# @param mcp_servers [Array<Anthropic::Models::Beta::BetaRequestMCPServerURLDefinition>] MCP servers to be utilized in this request
|
|
234
240
|
#
|
|
241
|
+
# @param output_format [Anthropic::Models::Beta::BetaJSONOutputFormat, nil]
|
|
242
|
+
#
|
|
235
243
|
# @param system_ [String, Array<Anthropic::Models::Beta::BetaTextBlockParam>] System prompt.
|
|
236
244
|
#
|
|
237
245
|
# @param thinking [Anthropic::Models::Beta::BetaThinkingConfigEnabled, Anthropic::Models::Beta::BetaThinkingConfigDisabled] Configuration for enabling Claude's extended thinking.
|
|
@@ -128,6 +128,12 @@ module Anthropic
|
|
|
128
128
|
# @return [Anthropic::Models::Beta::BetaMetadata, nil]
|
|
129
129
|
optional :metadata, -> { Anthropic::Beta::BetaMetadata }
|
|
130
130
|
|
|
131
|
+
# @!attribute output_format
|
|
132
|
+
# A schema to specify Claude's output format in responses.
|
|
133
|
+
#
|
|
134
|
+
# @return [Anthropic::Models::Beta::BetaJSONOutputFormat, nil]
|
|
135
|
+
optional :output_format, -> { Anthropic::Beta::BetaJSONOutputFormat }, nil?: true
|
|
136
|
+
|
|
131
137
|
# @!attribute service_tier
|
|
132
138
|
# Determines whether to use priority capacity (if available) or standard capacity
|
|
133
139
|
# for this request.
|
|
@@ -308,7 +314,7 @@ module Anthropic
|
|
|
308
314
|
# @return [Array<String, Symbol, Anthropic::Models::AnthropicBeta>, nil]
|
|
309
315
|
optional :betas, -> { Anthropic::Internal::Type::ArrayOf[union: Anthropic::AnthropicBeta] }
|
|
310
316
|
|
|
311
|
-
# @!method initialize(max_tokens:, messages:, model:, container: nil, context_management: 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: {})
|
|
317
|
+
# @!method initialize(max_tokens:, messages:, model:, container: nil, context_management: nil, mcp_servers: nil, metadata: nil, output_format: 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: {})
|
|
312
318
|
# Some parameter documentations has been truncated, see
|
|
313
319
|
# {Anthropic::Models::Beta::MessageCreateParams} for more details.
|
|
314
320
|
#
|
|
@@ -326,6 +332,8 @@ module Anthropic
|
|
|
326
332
|
#
|
|
327
333
|
# @param metadata [Anthropic::Models::Beta::BetaMetadata] An object describing metadata about the request.
|
|
328
334
|
#
|
|
335
|
+
# @param output_format [Anthropic::Models::Beta::BetaJSONOutputFormat, nil]
|
|
336
|
+
#
|
|
329
337
|
# @param service_tier [Symbol, Anthropic::Models::Beta::MessageCreateParams::ServiceTier] Determines whether to use priority capacity (if available) or standard capacity
|
|
330
338
|
#
|
|
331
339
|
# @param stop_sequences [Array<String>] Custom text sequences that will cause the model to stop generating.
|