anthropic 1.2.0 → 1.3.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 +24 -0
- data/README.md +1 -1
- data/lib/anthropic/models/model.rb +0 -22
- data/lib/anthropic/resources/beta/messages.rb +68 -1
- data/lib/anthropic/version.rb +1 -1
- 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/models/model.rbi +0 -8
- data/rbi/anthropic/resources/messages.rbi +47 -25
- data/sig/anthropic/helpers/streaming/events.rbs +30 -32
- data/sig/anthropic/helpers/streaming/message_stream.rbs +4 -2
- data/sig/anthropic/models/model.rbs +0 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3c745f561e82ef46c67d6b63e2c658c0df34d601613097bbd735f8e098bdc7a
|
4
|
+
data.tar.gz: 6f34d4ad97937f46f85b84ff7d97a345ebd264db1ad69f79694a15c938a9baa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c607669b393c983b41c82a31cf0c278edf16b408900deab1e1bedbf4a9d3c5dae510723122a08706ed6da845ad9ce8a1066bc196c592243e484f3a89dbe6627
|
7
|
+
data.tar.gz: 32b833e14c4dbfce6ae04fa4bb3fbb61855df8f9ee58334f9c0c32b047eea7271a8d3404d756b4eb02917d36067d38aca0de30e8794da56fe40eb1d5e53fa4a3
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.3.0 (2025-07-28)
|
4
|
+
|
5
|
+
Full Changelog: [v1.2.0...v1.3.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.2.0...v1.3.0)
|
6
|
+
|
7
|
+
### Features
|
8
|
+
|
9
|
+
* **api:** removed older deprecated models ([47de6c2](https://github.com/anthropics/anthropic-sdk-ruby/commit/47de6c2860fabd344374aed733df1bcb17988454))
|
10
|
+
* **client:** add beta stream implementation and fine grained tool streaming example ([2856b81](https://github.com/anthropics/anthropic-sdk-ruby/commit/2856b8119b99e6487093df3f49216ecc8d1bd3e3))
|
11
|
+
* **client:** add beta stream implementation and fine grained tool streaming example ([bc87fd4](https://github.com/anthropics/anthropic-sdk-ruby/commit/bc87fd4afd94a48301fec548a0e7b21f44a24a59))
|
12
|
+
|
13
|
+
|
14
|
+
### Bug Fixes
|
15
|
+
|
16
|
+
* **internal:** ensure sorbet test always runs serially ([0b39a19](https://github.com/anthropics/anthropic-sdk-ruby/commit/0b39a1908587597ca5836872333541307f24bdf2))
|
17
|
+
* **internal:** ensure vertex client test ordering ([#667](https://github.com/anthropics/anthropic-sdk-ruby/issues/667)) ([d7439fa](https://github.com/anthropics/anthropic-sdk-ruby/commit/d7439fa58664d9a533cacca6a299b3dbbe43ec7f))
|
18
|
+
|
19
|
+
|
20
|
+
### Chores
|
21
|
+
|
22
|
+
* add basic tool use example ([#107](https://github.com/anthropics/anthropic-sdk-ruby/issues/107)) ([4452119](https://github.com/anthropics/anthropic-sdk-ruby/commit/445211929b09ff0be9406aad1b3f3604d8bf3794))
|
23
|
+
* add Darwin to PLATFORMS in Gemfile.lock ([#104](https://github.com/anthropics/anthropic-sdk-ruby/issues/104)) ([aa5bcbe](https://github.com/anthropics/anthropic-sdk-ruby/commit/aa5bcbedc48cc9a49ba14050fa3ad934a6f95c99))
|
24
|
+
* **internal:** run formatter ([87ce979](https://github.com/anthropics/anthropic-sdk-ruby/commit/87ce979a06108f980e8c867d43166fbeeff02ec3))
|
25
|
+
* update contribute.md ([aa928a0](https://github.com/anthropics/anthropic-sdk-ruby/commit/aa928a09f08250c9e6e93b884761eb35a9d5b6b4))
|
26
|
+
|
3
27
|
## 1.2.0 (2025-07-18)
|
4
28
|
|
5
29
|
Full Changelog: [v1.1.1...v1.2.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.1.1...v1.2.0)
|
data/README.md
CHANGED
@@ -38,14 +38,8 @@ module Anthropic
|
|
38
38
|
|
39
39
|
variant const: -> { Anthropic::Models::Model::CLAUDE_3_OPUS_20240229 }
|
40
40
|
|
41
|
-
variant const: -> { Anthropic::Models::Model::CLAUDE_3_SONNET_20240229 }
|
42
|
-
|
43
41
|
variant const: -> { Anthropic::Models::Model::CLAUDE_3_HAIKU_20240307 }
|
44
42
|
|
45
|
-
variant const: -> { Anthropic::Models::Model::CLAUDE_2_1 }
|
46
|
-
|
47
|
-
variant const: -> { Anthropic::Models::Model::CLAUDE_2_0 }
|
48
|
-
|
49
43
|
variant String
|
50
44
|
|
51
45
|
# @!method self.variants
|
@@ -107,25 +101,9 @@ module Anthropic
|
|
107
101
|
# information.
|
108
102
|
CLAUDE_3_OPUS_20240229 = :"claude-3-opus-20240229"
|
109
103
|
|
110
|
-
# Balance of speed and intelligence
|
111
|
-
# @deprecated Will reach end-of-life on July 21st, 2025. Please migrate to a newer model.
|
112
|
-
# Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more
|
113
|
-
# information.
|
114
|
-
CLAUDE_3_SONNET_20240229 = :"claude-3-sonnet-20240229"
|
115
|
-
|
116
104
|
# Our previous most fast and cost-effective
|
117
105
|
CLAUDE_3_HAIKU_20240307 = :"claude-3-haiku-20240307"
|
118
106
|
|
119
|
-
# @deprecated Will reach end-of-life on July 21st, 2025. Please migrate to a newer model.
|
120
|
-
# Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more
|
121
|
-
# information.
|
122
|
-
CLAUDE_2_1 = :"claude-2.1"
|
123
|
-
|
124
|
-
# @deprecated Will reach end-of-life on July 21st, 2025. Please migrate to a newer model.
|
125
|
-
# Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more
|
126
|
-
# information.
|
127
|
-
CLAUDE_2_0 = :"claude-2.0"
|
128
|
-
|
129
107
|
# @!endgroup
|
130
108
|
end
|
131
109
|
end
|
@@ -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::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
|
|
data/lib/anthropic/version.rb
CHANGED
@@ -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
|
@@ -76,17 +76,9 @@ module Anthropic
|
|
76
76
|
CLAUDE_3_OPUS_20240229 =
|
77
77
|
T.let(:"claude-3-opus-20240229", Anthropic::Model::TaggedSymbol)
|
78
78
|
|
79
|
-
# Balance of speed and intelligence
|
80
|
-
CLAUDE_3_SONNET_20240229 =
|
81
|
-
T.let(:"claude-3-sonnet-20240229", Anthropic::Model::TaggedSymbol)
|
82
|
-
|
83
79
|
# Our previous most fast and cost-effective
|
84
80
|
CLAUDE_3_HAIKU_20240307 =
|
85
81
|
T.let(:"claude-3-haiku-20240307", Anthropic::Model::TaggedSymbol)
|
86
|
-
|
87
|
-
CLAUDE_2_1 = T.let(:"claude-2.1", Anthropic::Model::TaggedSymbol)
|
88
|
-
|
89
|
-
CLAUDE_2_0 = T.let(:"claude-2.0", Anthropic::Model::TaggedSymbol)
|
90
82
|
end
|
91
83
|
end
|
92
84
|
end
|
@@ -314,38 +314,59 @@ module Anthropic
|
|
314
314
|
sig do
|
315
315
|
params(
|
316
316
|
max_tokens: Integer,
|
317
|
-
messages:
|
317
|
+
messages:
|
318
|
+
T::Array[
|
319
|
+
T.any(
|
320
|
+
Anthropic::Models::MessageParam,
|
321
|
+
Anthropic::Internal::AnyHash
|
322
|
+
)
|
323
|
+
],
|
318
324
|
model: T.any(Anthropic::Models::Model::OrSymbol, String),
|
319
|
-
metadata:
|
325
|
+
metadata:
|
326
|
+
T.any(Anthropic::Models::Metadata, Anthropic::Internal::AnyHash),
|
320
327
|
stop_sequences: T::Array[String],
|
321
|
-
system_:
|
328
|
+
system_:
|
329
|
+
T.any(
|
330
|
+
String,
|
331
|
+
T::Array[
|
332
|
+
T.any(
|
333
|
+
Anthropic::Models::TextBlockParam,
|
334
|
+
Anthropic::Internal::AnyHash
|
335
|
+
)
|
336
|
+
]
|
337
|
+
),
|
322
338
|
temperature: Float,
|
323
|
-
thinking:
|
324
|
-
Anthropic::Models::ThinkingConfigEnabled,
|
325
|
-
Anthropic::Internal::AnyHash,
|
326
|
-
Anthropic::Models::ThinkingConfigDisabled
|
327
|
-
),
|
328
|
-
tool_choice: T.any(
|
329
|
-
Anthropic::Models::ToolChoiceAuto,
|
330
|
-
Anthropic::Internal::AnyHash,
|
331
|
-
Anthropic::Models::ToolChoiceAny,
|
332
|
-
Anthropic::Models::ToolChoiceTool,
|
333
|
-
Anthropic::Models::ToolChoiceNone
|
334
|
-
),
|
335
|
-
tools: T::Array[
|
339
|
+
thinking:
|
336
340
|
T.any(
|
337
|
-
Anthropic::Models::
|
341
|
+
Anthropic::Models::ThinkingConfigEnabled,
|
338
342
|
Anthropic::Internal::AnyHash,
|
339
|
-
Anthropic::Models::
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
+
Anthropic::Models::ThinkingConfigDisabled
|
344
|
+
),
|
345
|
+
tool_choice:
|
346
|
+
T.any(
|
347
|
+
Anthropic::Models::ToolChoiceAuto,
|
348
|
+
Anthropic::Internal::AnyHash,
|
349
|
+
Anthropic::Models::ToolChoiceAny,
|
350
|
+
Anthropic::Models::ToolChoiceTool,
|
351
|
+
Anthropic::Models::ToolChoiceNone
|
352
|
+
),
|
353
|
+
tools:
|
354
|
+
T::Array[
|
355
|
+
T.any(
|
356
|
+
Anthropic::Models::Tool,
|
357
|
+
Anthropic::Internal::AnyHash,
|
358
|
+
Anthropic::Models::ToolBash20250124,
|
359
|
+
Anthropic::Models::ToolTextEditor20250124
|
360
|
+
)
|
361
|
+
],
|
343
362
|
top_k: Integer,
|
344
363
|
top_p: Float,
|
345
364
|
stream: T.noreturn,
|
346
|
-
request_options:
|
347
|
-
|
348
|
-
|
365
|
+
request_options:
|
366
|
+
T.nilable(
|
367
|
+
T.any(Anthropic::RequestOptions, Anthropic::Internal::AnyHash)
|
368
|
+
)
|
369
|
+
).returns(Anthropic::Helpers::Streaming::MessageStream)
|
349
370
|
end
|
350
371
|
def stream(
|
351
372
|
# The maximum number of tokens to generate before stopping.
|
@@ -579,7 +600,8 @@ module Anthropic
|
|
579
600
|
# for streaming and non-streaming use cases, respectively.
|
580
601
|
stream: true,
|
581
602
|
request_options: {}
|
582
|
-
)
|
603
|
+
)
|
604
|
+
end
|
583
605
|
sig do
|
584
606
|
params(
|
585
607
|
max_tokens: Integer,
|
@@ -10,18 +10,15 @@ module Anthropic
|
|
10
10
|
|
11
11
|
attr_accessor snapshot: String
|
12
12
|
|
13
|
-
def initialize: (
|
14
|
-
?type: :text,
|
15
|
-
text: String,
|
16
|
-
snapshot: String
|
17
|
-
) -> void
|
13
|
+
def initialize: (text: String, snapshot: String, ?type: :text) -> void
|
18
14
|
end
|
19
15
|
|
20
|
-
type citation_event =
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
16
|
+
type citation_event =
|
17
|
+
{
|
18
|
+
type: :citation,
|
19
|
+
citation: Anthropic::Models::CitationsDelta::citation,
|
20
|
+
snapshot: ::Array[Anthropic::Models::CitationsDelta::citation]
|
21
|
+
}
|
25
22
|
|
26
23
|
class CitationEvent < Anthropic::Internal::Type::BaseModel
|
27
24
|
attr_accessor type: :citation
|
@@ -31,13 +28,14 @@ module Anthropic
|
|
31
28
|
attr_accessor snapshot: ::Array[Anthropic::Models::CitationsDelta::citation]
|
32
29
|
|
33
30
|
def initialize: (
|
34
|
-
?type: :citation,
|
35
31
|
citation: Anthropic::Models::CitationsDelta::citation,
|
36
|
-
snapshot: ::Array[Anthropic::Models::CitationsDelta::citation]
|
32
|
+
snapshot: ::Array[Anthropic::Models::CitationsDelta::citation],
|
33
|
+
?type: :citation
|
37
34
|
) -> void
|
38
35
|
end
|
39
36
|
|
40
|
-
type thinking_event =
|
37
|
+
type thinking_event =
|
38
|
+
{ type: :thinking, thinking: String, snapshot: String }
|
41
39
|
|
42
40
|
class ThinkingEvent < Anthropic::Internal::Type::BaseModel
|
43
41
|
attr_accessor type: :thinking
|
@@ -47,9 +45,9 @@ module Anthropic
|
|
47
45
|
attr_accessor snapshot: String
|
48
46
|
|
49
47
|
def initialize: (
|
50
|
-
?type: :thinking,
|
51
48
|
thinking: String,
|
52
|
-
snapshot: String
|
49
|
+
snapshot: String,
|
50
|
+
?type: :thinking
|
53
51
|
) -> void
|
54
52
|
end
|
55
53
|
|
@@ -60,13 +58,11 @@ module Anthropic
|
|
60
58
|
|
61
59
|
attr_accessor signature: String
|
62
60
|
|
63
|
-
def initialize: (
|
64
|
-
?type: :signature,
|
65
|
-
signature: String
|
66
|
-
) -> void
|
61
|
+
def initialize: (signature: String, ?type: :signature) -> void
|
67
62
|
end
|
68
63
|
|
69
|
-
type input_json_event =
|
64
|
+
type input_json_event =
|
65
|
+
{ type: :input_json, partial_json: String, snapshot: untyped }
|
70
66
|
|
71
67
|
class InputJsonEvent < Anthropic::Internal::Type::BaseModel
|
72
68
|
attr_accessor type: :input_json
|
@@ -76,13 +72,14 @@ module Anthropic
|
|
76
72
|
attr_accessor snapshot: untyped
|
77
73
|
|
78
74
|
def initialize: (
|
79
|
-
?type: :input_json,
|
80
75
|
partial_json: String,
|
81
|
-
snapshot: untyped
|
76
|
+
snapshot: untyped,
|
77
|
+
?type: :input_json
|
82
78
|
) -> void
|
83
79
|
end
|
84
80
|
|
85
|
-
type message_stop_event =
|
81
|
+
type message_stop_event =
|
82
|
+
{ type: :message_stop, message: Anthropic::Models::message }
|
86
83
|
|
87
84
|
class MessageStopEvent < Anthropic::Models::RawMessageStopEvent
|
88
85
|
attr_accessor type: :message_stop
|
@@ -90,16 +87,17 @@ module Anthropic
|
|
90
87
|
attr_accessor message: Anthropic::Models::message
|
91
88
|
|
92
89
|
def initialize: (
|
93
|
-
|
94
|
-
|
90
|
+
message: Anthropic::Models::message,
|
91
|
+
?type: :message_stop
|
95
92
|
) -> void
|
96
93
|
end
|
97
94
|
|
98
|
-
type content_block_stop_event =
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
95
|
+
type content_block_stop_event =
|
96
|
+
{
|
97
|
+
type: :content_block_stop,
|
98
|
+
index: Integer,
|
99
|
+
content_block: Anthropic::Models::content_block
|
100
|
+
}
|
103
101
|
|
104
102
|
class ContentBlockStopEvent < Anthropic::Models::RawContentBlockStopEvent
|
105
103
|
attr_accessor type: :content_block_stop
|
@@ -109,9 +107,9 @@ module Anthropic
|
|
109
107
|
attr_accessor content_block: Anthropic::Models::content_block
|
110
108
|
|
111
109
|
def initialize: (
|
112
|
-
?type: :content_block_stop,
|
113
110
|
index: Integer,
|
114
|
-
content_block: Anthropic::Models::content_block
|
111
|
+
content_block: Anthropic::Models::content_block,
|
112
|
+
?type: :content_block_stop
|
115
113
|
) -> void
|
116
114
|
end
|
117
115
|
end
|
@@ -26,7 +26,9 @@ module Anthropic
|
|
26
26
|
@accumated_message_snapshot: Anthropic::Models::message?
|
27
27
|
@iterator: Enumerable[stream_event]?
|
28
28
|
|
29
|
-
def initialize: (
|
29
|
+
def initialize: (
|
30
|
+
raw_stream: Anthropic::Internal::Stream[raw_message_event]
|
31
|
+
) -> void
|
30
32
|
|
31
33
|
def until_done: -> void
|
32
34
|
|
@@ -52,4 +54,4 @@ module Anthropic
|
|
52
54
|
end
|
53
55
|
end
|
54
56
|
end
|
55
|
-
end
|
57
|
+
end
|
@@ -16,10 +16,7 @@ module Anthropic
|
|
16
16
|
| :"claude-4-opus-20250514"
|
17
17
|
| :"claude-3-opus-latest"
|
18
18
|
| :"claude-3-opus-20240229"
|
19
|
-
| :"claude-3-sonnet-20240229"
|
20
19
|
| :"claude-3-haiku-20240307"
|
21
|
-
| :"claude-2.1"
|
22
|
-
| :"claude-2.0"
|
23
20
|
| String
|
24
21
|
|
25
22
|
module Model
|
@@ -71,15 +68,8 @@ module Anthropic
|
|
71
68
|
# Excels at writing and complex tasks
|
72
69
|
CLAUDE_3_OPUS_20240229: :"claude-3-opus-20240229"
|
73
70
|
|
74
|
-
# Balance of speed and intelligence
|
75
|
-
CLAUDE_3_SONNET_20240229: :"claude-3-sonnet-20240229"
|
76
|
-
|
77
71
|
# Our previous most fast and cost-effective
|
78
72
|
CLAUDE_3_HAIKU_20240307: :"claude-3-haiku-20240307"
|
79
|
-
|
80
|
-
CLAUDE_2_1: :"claude-2.1"
|
81
|
-
|
82
|
-
CLAUDE_2_0: :"claude-2.0"
|
83
73
|
end
|
84
74
|
end
|
85
75
|
end
|