anthropic 1.46.0 → 1.47.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 +8 -0
- data/README.md +1 -1
- data/lib/anthropic/helpers/streaming/message_stream.rb +4 -0
- data/lib/anthropic/models/anthropic_beta.rb +6 -0
- data/lib/anthropic/models/beta/beta_content_block.rb +14 -1
- data/lib/anthropic/models/beta/beta_content_block_param.rb +18 -1
- data/lib/anthropic/models/beta/beta_fallback_block.rb +54 -0
- data/lib/anthropic/models/beta/beta_fallback_block_param.rb +51 -0
- data/lib/anthropic/models/beta/beta_fallback_info.rb +28 -0
- data/lib/anthropic/models/beta/beta_fallback_info_param.rb +28 -0
- data/lib/anthropic/models/beta/beta_fallback_message_iteration_usage.rb +81 -0
- data/lib/anthropic/models/beta/beta_fallback_param.rb +88 -0
- data/lib/anthropic/models/beta/beta_iterations_usage.rb +9 -1
- data/lib/anthropic/models/beta/beta_managed_agents_model.rb +5 -0
- data/lib/anthropic/models/beta/beta_message.rb +2 -2
- data/lib/anthropic/models/beta/beta_message_delta_usage.rb +2 -2
- data/lib/anthropic/models/beta/beta_message_iteration_usage.rb +15 -1
- data/lib/anthropic/models/beta/beta_message_param.rb +3 -3
- data/lib/anthropic/models/beta/beta_model_info.rb +11 -1
- data/lib/anthropic/models/beta/beta_raw_content_block_start_event.rb +16 -3
- data/lib/anthropic/models/beta/beta_refusal_stop_details.rb +64 -1
- data/lib/anthropic/models/beta/beta_usage.rb +2 -2
- data/lib/anthropic/models/beta/message_create_params.rb +39 -1
- data/lib/anthropic/models/beta/messages/batch_create_params.rb +39 -1
- data/lib/anthropic/models/model.rb +13 -0
- data/lib/anthropic/models/refusal_stop_details.rb +1 -0
- data/lib/anthropic/resources/beta/messages.rb +10 -2
- data/lib/anthropic/version.rb +1 -1
- data/lib/anthropic.rb +6 -0
- data/rbi/anthropic/models/anthropic_beta.rbi +10 -0
- data/rbi/anthropic/models/beta/beta_content_block.rbi +2 -1
- data/rbi/anthropic/models/beta/beta_content_block_param.rbi +2 -1
- data/rbi/anthropic/models/beta/beta_fallback_block.rbi +83 -0
- data/rbi/anthropic/models/beta/beta_fallback_block_param.rbi +81 -0
- data/rbi/anthropic/models/beta/beta_fallback_info.rbi +45 -0
- data/rbi/anthropic/models/beta/beta_fallback_info_param.rbi +47 -0
- data/rbi/anthropic/models/beta/beta_fallback_message_iteration_usage.rbi +113 -0
- data/rbi/anthropic/models/beta/beta_fallback_param.rbi +167 -0
- data/rbi/anthropic/models/beta/beta_iterations_usage.rbi +2 -1
- data/rbi/anthropic/models/beta/beta_managed_agents_model.rbi +7 -0
- data/rbi/anthropic/models/beta/beta_message.rbi +2 -1
- data/rbi/anthropic/models/beta/beta_message_delta_usage.rbi +2 -1
- data/rbi/anthropic/models/beta/beta_message_iteration_usage.rbi +14 -0
- data/rbi/anthropic/models/beta/beta_model_info.rbi +12 -0
- data/rbi/anthropic/models/beta/beta_raw_content_block_start_event.rbi +4 -2
- data/rbi/anthropic/models/beta/beta_refusal_stop_details.rbi +105 -0
- data/rbi/anthropic/models/beta/beta_usage.rbi +2 -1
- data/rbi/anthropic/models/beta/message_create_params.rbi +58 -0
- data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +62 -0
- data/rbi/anthropic/models/model.rbi +7 -0
- data/rbi/anthropic/models/refusal_stop_details.rbi +5 -0
- data/rbi/anthropic/resources/beta/messages.rbi +54 -0
- data/sig/anthropic/models/anthropic_beta.rbs +4 -0
- data/sig/anthropic/models/beta/beta_content_block.rbs +1 -0
- data/sig/anthropic/models/beta/beta_content_block_param.rbs +1 -0
- data/sig/anthropic/models/beta/beta_fallback_block.rbs +34 -0
- data/sig/anthropic/models/beta/beta_fallback_block_param.rbs +34 -0
- data/sig/anthropic/models/beta/beta_fallback_info.rbs +17 -0
- data/sig/anthropic/models/beta/beta_fallback_info_param.rbs +17 -0
- data/sig/anthropic/models/beta/beta_fallback_message_iteration_usage.rbs +54 -0
- data/sig/anthropic/models/beta/beta_fallback_param.rbs +66 -0
- data/sig/anthropic/models/beta/beta_iterations_usage.rbs +1 -0
- data/sig/anthropic/models/beta/beta_managed_agents_model.rbs +5 -1
- data/sig/anthropic/models/beta/beta_message_iteration_usage.rbs +5 -0
- data/sig/anthropic/models/beta/beta_model_info.rbs +5 -0
- data/sig/anthropic/models/beta/beta_raw_content_block_start_event.rbs +1 -0
- data/sig/anthropic/models/beta/beta_refusal_stop_details.rbs +17 -1
- data/sig/anthropic/models/beta/message_create_params.rbs +10 -0
- data/sig/anthropic/models/beta/messages/batch_create_params.rbs +10 -0
- data/sig/anthropic/models/model.rbs +9 -1
- data/sig/anthropic/models/refusal_stop_details.rbs +2 -1
- data/sig/anthropic/resources/beta/messages.rbs +4 -0
- metadata +20 -2
|
@@ -11,6 +11,14 @@ module Anthropic
|
|
|
11
11
|
# @return [String]
|
|
12
12
|
required :id, String
|
|
13
13
|
|
|
14
|
+
# @!attribute allowed_fallback_models
|
|
15
|
+
# Model IDs this model accepts as `fallbacks[i].model` on the Messages API. An
|
|
16
|
+
# empty list means the `fallbacks` parameter is not supported for this model as
|
|
17
|
+
# primary.
|
|
18
|
+
#
|
|
19
|
+
# @return [Array<String>, nil]
|
|
20
|
+
required :allowed_fallback_models, Anthropic::Internal::Type::ArrayOf[String], nil?: true
|
|
21
|
+
|
|
14
22
|
# @!attribute capabilities
|
|
15
23
|
# Model capability information.
|
|
16
24
|
#
|
|
@@ -50,12 +58,14 @@ module Anthropic
|
|
|
50
58
|
# @return [Symbol, :model]
|
|
51
59
|
required :type, const: :model
|
|
52
60
|
|
|
53
|
-
# @!method initialize(id:, capabilities:, created_at:, display_name:, max_input_tokens:, max_tokens:, type: :model)
|
|
61
|
+
# @!method initialize(id:, allowed_fallback_models:, capabilities:, created_at:, display_name:, max_input_tokens:, max_tokens:, type: :model)
|
|
54
62
|
# Some parameter documentations has been truncated, see
|
|
55
63
|
# {Anthropic::Models::Beta::BetaModelInfo} for more details.
|
|
56
64
|
#
|
|
57
65
|
# @param id [String] Unique model identifier.
|
|
58
66
|
#
|
|
67
|
+
# @param allowed_fallback_models [Array<String>, nil] Model IDs this model accepts as `fallbacks[i].model` on the Messages API. An emp
|
|
68
|
+
#
|
|
59
69
|
# @param capabilities [Anthropic::Models::Beta::BetaModelCapabilities, nil] Model capability information.
|
|
60
70
|
#
|
|
61
71
|
# @param created_at [Time] RFC 3339 datetime string representing the time at which the model was released.
|
|
@@ -7,7 +7,7 @@ module Anthropic
|
|
|
7
7
|
# @!attribute content_block
|
|
8
8
|
# Response model for a file uploaded to the container.
|
|
9
9
|
#
|
|
10
|
-
# @return [Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaWebFetchToolResultBlock, Anthropic::Models::Beta::BetaAdvisorToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaBashCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaTextEditorCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaToolSearchToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock, Anthropic::Models::Beta::BetaCompactionBlock]
|
|
10
|
+
# @return [Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaWebFetchToolResultBlock, Anthropic::Models::Beta::BetaAdvisorToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaBashCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaTextEditorCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaToolSearchToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock, Anthropic::Models::Beta::BetaCompactionBlock, Anthropic::Models::Beta::BetaFallbackBlock]
|
|
11
11
|
required :content_block, union: -> { Anthropic::Beta::BetaRawContentBlockStartEvent::ContentBlock }
|
|
12
12
|
|
|
13
13
|
# @!attribute index
|
|
@@ -21,7 +21,7 @@ module Anthropic
|
|
|
21
21
|
required :type, const: :content_block_start
|
|
22
22
|
|
|
23
23
|
# @!method initialize(content_block:, index:, type: :content_block_start)
|
|
24
|
-
# @param content_block [Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaWebFetchToolResultBlock, Anthropic::Models::Beta::BetaAdvisorToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaBashCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaTextEditorCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaToolSearchToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock, Anthropic::Models::Beta::BetaCompactionBlock] Response model for a file uploaded to the container.
|
|
24
|
+
# @param content_block [Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaWebFetchToolResultBlock, Anthropic::Models::Beta::BetaAdvisorToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaBashCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaTextEditorCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaToolSearchToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock, Anthropic::Models::Beta::BetaCompactionBlock, Anthropic::Models::Beta::BetaFallbackBlock] Response model for a file uploaded to the container.
|
|
25
25
|
#
|
|
26
26
|
# @param index [Integer]
|
|
27
27
|
#
|
|
@@ -74,8 +74,21 @@ module Anthropic
|
|
|
74
74
|
# compaction blocks with null content; the server treats them as no-ops.
|
|
75
75
|
variant :compaction, -> { Anthropic::Beta::BetaCompactionBlock }
|
|
76
76
|
|
|
77
|
+
# Marks the point in `content` where one model's output gives way to the next.
|
|
78
|
+
#
|
|
79
|
+
# One block appears per hop where a preceding model actually ran this turn and
|
|
80
|
+
# declined. A turn routed directly by the sticky decision has no such boundary
|
|
81
|
+
# and carries no block — the signal for whether a fallback model served the
|
|
82
|
+
# response is the presence of a `fallback_message` entry in
|
|
83
|
+
# `usage.iterations`, not this block.
|
|
84
|
+
#
|
|
85
|
+
# The block is treated like a server-tool content block for streaming: it
|
|
86
|
+
# arrives via the standard `content_block_start` / `content_block_stop`
|
|
87
|
+
# pair and carries no deltas.
|
|
88
|
+
variant :fallback, -> { Anthropic::Beta::BetaFallbackBlock }
|
|
89
|
+
|
|
77
90
|
# @!method self.variants
|
|
78
|
-
# @return [Array(Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaWebFetchToolResultBlock, Anthropic::Models::Beta::BetaAdvisorToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaBashCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaTextEditorCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaToolSearchToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock, Anthropic::Models::Beta::BetaCompactionBlock)]
|
|
91
|
+
# @return [Array(Anthropic::Models::Beta::BetaTextBlock, Anthropic::Models::Beta::BetaThinkingBlock, Anthropic::Models::Beta::BetaRedactedThinkingBlock, Anthropic::Models::Beta::BetaToolUseBlock, Anthropic::Models::Beta::BetaServerToolUseBlock, Anthropic::Models::Beta::BetaWebSearchToolResultBlock, Anthropic::Models::Beta::BetaWebFetchToolResultBlock, Anthropic::Models::Beta::BetaAdvisorToolResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaBashCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaTextEditorCodeExecutionToolResultBlock, Anthropic::Models::Beta::BetaToolSearchToolResultBlock, Anthropic::Models::Beta::BetaMCPToolUseBlock, Anthropic::Models::Beta::BetaMCPToolResultBlock, Anthropic::Models::Beta::BetaContainerUploadBlock, Anthropic::Models::Beta::BetaCompactionBlock, Anthropic::Models::Beta::BetaFallbackBlock)]
|
|
79
92
|
end
|
|
80
93
|
end
|
|
81
94
|
end
|
|
@@ -21,12 +21,68 @@ module Anthropic
|
|
|
21
21
|
# @return [String, nil]
|
|
22
22
|
required :explanation, String, nil?: true
|
|
23
23
|
|
|
24
|
+
# @!attribute fallback_credit_token
|
|
25
|
+
# Opaque code that refunds the cache-miss cost when retrying this refused request
|
|
26
|
+
# on the fallback model. Pass it as `fallback_credit_token` on the retry request.
|
|
27
|
+
# Expires 5 minutes after the refusal.
|
|
28
|
+
#
|
|
29
|
+
# The retry is sent either with the same request body (`system`, `messages`,
|
|
30
|
+
# `tools`, and other render-shaping fields), or with the same body plus one
|
|
31
|
+
# appended `assistant` message whose content is the partial text (with any
|
|
32
|
+
# trailing whitespace stripped from the final text block) and paired server-tool
|
|
33
|
+
# blocks from this refusal — which also authorizes that appended turn as an
|
|
34
|
+
# assistant-prefill continuation on models that otherwise disallow prefill. A
|
|
35
|
+
# token minted mid-server-tool-loop whose partial content was continuable may only
|
|
36
|
+
# be redeemed the second way — if a same-body retry is rejected with a 400 saying
|
|
37
|
+
# the token must be redeemed by continuing the partial response, retry the second
|
|
38
|
+
# way instead. Either way: same workspace, same platform; a mismatch is a 400.
|
|
39
|
+
# Resending a token for an already-warm prefix is permitted but yields no
|
|
40
|
+
# additional credit.
|
|
41
|
+
#
|
|
42
|
+
# `null` when the refused model isn't eligible for a fallback credit.
|
|
43
|
+
#
|
|
44
|
+
# @return [String, nil]
|
|
45
|
+
required :fallback_credit_token, String, nil?: true
|
|
46
|
+
|
|
47
|
+
# @!attribute fallback_has_prefill_claim
|
|
48
|
+
# Whether the accompanying `fallback_credit_token` may be redeemed with the
|
|
49
|
+
# appended-assistant retry form. Only set when `fallback_credit_token` is present.
|
|
50
|
+
#
|
|
51
|
+
# `true`: retry by resending the same request body plus one appended `assistant`
|
|
52
|
+
# message whose content is this response's `content` with any trailing whitespace
|
|
53
|
+
# stripped from the final text block and unpaired `tool_use` blocks omitted (the
|
|
54
|
+
# same appended-turn shape described on `fallback_credit_token`), with the token
|
|
55
|
+
# attached. `false`: retry by resending the original request body unchanged, with
|
|
56
|
+
# the token attached — the appended-assistant form is not available for this
|
|
57
|
+
# refusal (no continuable partial content, or the request uses `output_format` or
|
|
58
|
+
# a `tool_choice` that forces tool use). One exception: when the request used
|
|
59
|
+
# `output_format` or a forced `tool_choice` and the refusal arrived after server
|
|
60
|
+
# tools (including MCP connector tools) had already executed, the token may not be
|
|
61
|
+
# redeemable by either retry form; if the exact-body retry is then rejected with a
|
|
62
|
+
# 400 saying the token must be redeemed by continuing the partial response,
|
|
63
|
+
# discard the token and retry without it.
|
|
64
|
+
#
|
|
65
|
+
# Advisory: if an appended-assistant retry is rejected with a 400 despite `true`,
|
|
66
|
+
# fall back to resending the original request body with the token.
|
|
67
|
+
#
|
|
68
|
+
# @return [Boolean, nil]
|
|
69
|
+
required :fallback_has_prefill_claim, Anthropic::Internal::Type::Boolean, nil?: true
|
|
70
|
+
|
|
71
|
+
# @!attribute recommended_model
|
|
72
|
+
# The server's suggested retry target for this refusal. Populated when a fallback
|
|
73
|
+
# attempt could not be made (the fallback model's rate limit was exhausted, or it
|
|
74
|
+
# was overloaded); names the fallback model the caller can retry directly. Null
|
|
75
|
+
# otherwise.
|
|
76
|
+
#
|
|
77
|
+
# @return [String, nil]
|
|
78
|
+
required :recommended_model, String, nil?: true
|
|
79
|
+
|
|
24
80
|
# @!attribute type
|
|
25
81
|
#
|
|
26
82
|
# @return [Symbol, :refusal]
|
|
27
83
|
required :type, const: :refusal
|
|
28
84
|
|
|
29
|
-
# @!method initialize(category:, explanation:, type: :refusal)
|
|
85
|
+
# @!method initialize(category:, explanation:, fallback_credit_token:, fallback_has_prefill_claim:, recommended_model:, type: :refusal)
|
|
30
86
|
# Some parameter documentations has been truncated, see
|
|
31
87
|
# {Anthropic::Models::Beta::BetaRefusalStopDetails} for more details.
|
|
32
88
|
#
|
|
@@ -36,6 +92,12 @@ module Anthropic
|
|
|
36
92
|
#
|
|
37
93
|
# @param explanation [String, nil] Human-readable explanation of the refusal.
|
|
38
94
|
#
|
|
95
|
+
# @param fallback_credit_token [String, nil] Opaque code that refunds the cache-miss cost when retrying this refused
|
|
96
|
+
#
|
|
97
|
+
# @param fallback_has_prefill_claim [Boolean, nil] Whether the accompanying `fallback_credit_token` may be redeemed with the
|
|
98
|
+
#
|
|
99
|
+
# @param recommended_model [String, nil] The server's suggested retry target for this refusal. Populated when a fallback
|
|
100
|
+
#
|
|
39
101
|
# @param type [Symbol, :refusal]
|
|
40
102
|
|
|
41
103
|
# The policy category that triggered the refusal.
|
|
@@ -48,6 +110,7 @@ module Anthropic
|
|
|
48
110
|
|
|
49
111
|
CYBER = :cyber
|
|
50
112
|
BIO = :bio
|
|
113
|
+
REASONING_EXTRACTION = :reasoning_extraction
|
|
51
114
|
|
|
52
115
|
# @!method self.values
|
|
53
116
|
# @return [Array<Symbol>]
|
|
@@ -44,7 +44,7 @@ module Anthropic
|
|
|
44
44
|
# - Calculate the true context window size from the last iteration
|
|
45
45
|
# - Understand token accumulation across server-side tool use loops
|
|
46
46
|
#
|
|
47
|
-
# @return [Array<Anthropic::Models::Beta::BetaMessageIterationUsage, Anthropic::Models::Beta::BetaCompactionIterationUsage, Anthropic::Models::Beta::BetaAdvisorMessageIterationUsage>, nil]
|
|
47
|
+
# @return [Array<Anthropic::Models::Beta::BetaMessageIterationUsage, Anthropic::Models::Beta::BetaCompactionIterationUsage, Anthropic::Models::Beta::BetaAdvisorMessageIterationUsage, Anthropic::Models::Beta::BetaFallbackMessageIterationUsage>, nil]
|
|
48
48
|
required :iterations,
|
|
49
49
|
-> { Anthropic::Internal::Type::ArrayOf[union: Anthropic::Beta::BetaIterationsUsageItem] },
|
|
50
50
|
nil?: true
|
|
@@ -98,7 +98,7 @@ module Anthropic
|
|
|
98
98
|
#
|
|
99
99
|
# @param input_tokens [Integer] The number of input tokens which were used.
|
|
100
100
|
#
|
|
101
|
-
# @param iterations [Array<Anthropic::Models::Beta::BetaMessageIterationUsage, Anthropic::Models::Beta::BetaCompactionIterationUsage, Anthropic::Models::Beta::BetaAdvisorMessageIterationUsage>, nil] Per-iteration token usage breakdown.
|
|
101
|
+
# @param iterations [Array<Anthropic::Models::Beta::BetaMessageIterationUsage, Anthropic::Models::Beta::BetaCompactionIterationUsage, Anthropic::Models::Beta::BetaAdvisorMessageIterationUsage, Anthropic::Models::Beta::BetaFallbackMessageIterationUsage>, nil] Per-iteration token usage breakdown.
|
|
102
102
|
#
|
|
103
103
|
# @param output_tokens [Integer] The number of output tokens which were used.
|
|
104
104
|
#
|
|
@@ -134,6 +134,40 @@ module Anthropic
|
|
|
134
134
|
# @return [Anthropic::Models::Beta::BetaDiagnosticsParam, nil]
|
|
135
135
|
optional :diagnostics, -> { Anthropic::Beta::BetaDiagnosticsParam }, nil?: true
|
|
136
136
|
|
|
137
|
+
# @!attribute fallback_credit_token
|
|
138
|
+
# The `fallback_credit_token` from a prior refusal's `stop_details`.
|
|
139
|
+
#
|
|
140
|
+
# When a preceding request was refused and returned a `fallback_credit_token`,
|
|
141
|
+
# pass that code here on the retry to have the retry's cache-creation tokens for
|
|
142
|
+
# the prefix that was warm on the refused model billed at the cache-read rate.
|
|
143
|
+
# Must be redeemed by the same organization and workspace, with the same request
|
|
144
|
+
# body (optionally extended by one appended `assistant` message whose content is
|
|
145
|
+
# the partial text — with any trailing whitespace stripped from the final text
|
|
146
|
+
# block — and paired server-tool blocks streamed before the refusal; the
|
|
147
|
+
# appended-assistant form is not available for requests with `output_format` set
|
|
148
|
+
# or forced `tool_choice`), on an eligible fallback model, on the same platform,
|
|
149
|
+
# and within 5 minutes of the refusal; a mismatch is a 400. A token minted
|
|
150
|
+
# mid-server-tool-loop whose partial content was continuable may only be redeemed
|
|
151
|
+
# with the appended-assistant form — if an exact-body retry is rejected with a 400
|
|
152
|
+
# saying the token must be redeemed by continuing the partial response, retry with
|
|
153
|
+
# the appended-assistant form instead.
|
|
154
|
+
#
|
|
155
|
+
# When the appended-assistant form is used on a model that otherwise disallows
|
|
156
|
+
# assistant-turn prefill, this token also authorizes that one prefill.
|
|
157
|
+
#
|
|
158
|
+
# @return [String, nil]
|
|
159
|
+
optional :fallback_credit_token, String, nil?: true
|
|
160
|
+
|
|
161
|
+
# @!attribute fallbacks
|
|
162
|
+
# Opt-in server-side retry on one or more substitute models when the requested
|
|
163
|
+
# model declines for policy reasons. Tried in order: if the first entry also
|
|
164
|
+
# declines, the second is tried, and so on.
|
|
165
|
+
#
|
|
166
|
+
# @return [Array<Anthropic::Models::Beta::BetaFallbackParam>, nil]
|
|
167
|
+
optional :fallbacks,
|
|
168
|
+
-> { Anthropic::Internal::Type::ArrayOf[Anthropic::Beta::BetaFallbackParam] },
|
|
169
|
+
nil?: true
|
|
170
|
+
|
|
137
171
|
# @!attribute inference_geo
|
|
138
172
|
# Specifies the geographic region for inference processing. If not specified, the
|
|
139
173
|
# workspace's `default_inference_geo` is used.
|
|
@@ -374,7 +408,7 @@ module Anthropic
|
|
|
374
408
|
# @return [Array<String, Symbol, Anthropic::Models::AnthropicBeta>, nil]
|
|
375
409
|
optional :betas, -> { Anthropic::Internal::Type::ArrayOf[union: Anthropic::AnthropicBeta] }
|
|
376
410
|
|
|
377
|
-
# @!method initialize(max_tokens:, messages:, model:, cache_control: nil, container: nil, context_management: nil, diagnostics: nil, inference_geo: nil, mcp_servers: nil, metadata: nil, output_config: nil, output_format: nil, service_tier: nil, speed: nil, stop_sequences: nil, system_: nil, temperature: nil, thinking: nil, tool_choice: nil, tools: nil, top_k: nil, top_p: nil, user_profile_id: nil, betas: nil, request_options: {})
|
|
411
|
+
# @!method initialize(max_tokens:, messages:, model:, cache_control: nil, container: nil, context_management: nil, diagnostics: nil, fallback_credit_token: nil, fallbacks: nil, inference_geo: nil, mcp_servers: nil, metadata: nil, output_config: nil, output_format: nil, service_tier: nil, speed: nil, stop_sequences: nil, system_: nil, temperature: nil, thinking: nil, tool_choice: nil, tools: nil, top_k: nil, top_p: nil, user_profile_id: nil, betas: nil, request_options: {})
|
|
378
412
|
# Some parameter documentations has been truncated, see
|
|
379
413
|
# {Anthropic::Models::Beta::MessageCreateParams} for more details.
|
|
380
414
|
#
|
|
@@ -392,6 +426,10 @@ module Anthropic
|
|
|
392
426
|
#
|
|
393
427
|
# @param diagnostics [Anthropic::Models::Beta::BetaDiagnosticsParam, nil] Request-level diagnostics. Currently carries the previous response
|
|
394
428
|
#
|
|
429
|
+
# @param fallback_credit_token [String, nil] The `fallback_credit_token` from a prior refusal's `stop_details`.
|
|
430
|
+
#
|
|
431
|
+
# @param fallbacks [Array<Anthropic::Models::Beta::BetaFallbackParam>, nil] Opt-in server-side retry on one or more substitute models when the requested mod
|
|
432
|
+
#
|
|
395
433
|
# @param inference_geo [String, nil] Specifies the geographic region for inference processing. If not specified, the
|
|
396
434
|
#
|
|
397
435
|
# @param mcp_servers [Array<Anthropic::Models::Beta::BetaRequestMCPServerURLDefinition>] MCP servers to be utilized in this request
|
|
@@ -189,6 +189,40 @@ module Anthropic
|
|
|
189
189
|
# @return [Anthropic::Models::Beta::BetaDiagnosticsParam, nil]
|
|
190
190
|
optional :diagnostics, -> { Anthropic::Beta::BetaDiagnosticsParam }, nil?: true
|
|
191
191
|
|
|
192
|
+
# @!attribute fallback_credit_token
|
|
193
|
+
# The `fallback_credit_token` from a prior refusal's `stop_details`.
|
|
194
|
+
#
|
|
195
|
+
# When a preceding request was refused and returned a `fallback_credit_token`,
|
|
196
|
+
# pass that code here on the retry to have the retry's cache-creation tokens for
|
|
197
|
+
# the prefix that was warm on the refused model billed at the cache-read rate.
|
|
198
|
+
# Must be redeemed by the same organization and workspace, with the same request
|
|
199
|
+
# body (optionally extended by one appended `assistant` message whose content is
|
|
200
|
+
# the partial text — with any trailing whitespace stripped from the final text
|
|
201
|
+
# block — and paired server-tool blocks streamed before the refusal; the
|
|
202
|
+
# appended-assistant form is not available for requests with `output_format` set
|
|
203
|
+
# or forced `tool_choice`), on an eligible fallback model, on the same platform,
|
|
204
|
+
# and within 5 minutes of the refusal; a mismatch is a 400. A token minted
|
|
205
|
+
# mid-server-tool-loop whose partial content was continuable may only be redeemed
|
|
206
|
+
# with the appended-assistant form — if an exact-body retry is rejected with a 400
|
|
207
|
+
# saying the token must be redeemed by continuing the partial response, retry with
|
|
208
|
+
# the appended-assistant form instead.
|
|
209
|
+
#
|
|
210
|
+
# When the appended-assistant form is used on a model that otherwise disallows
|
|
211
|
+
# assistant-turn prefill, this token also authorizes that one prefill.
|
|
212
|
+
#
|
|
213
|
+
# @return [String, nil]
|
|
214
|
+
optional :fallback_credit_token, String, nil?: true
|
|
215
|
+
|
|
216
|
+
# @!attribute fallbacks
|
|
217
|
+
# Opt-in server-side retry on one or more substitute models when the requested
|
|
218
|
+
# model declines for policy reasons. Tried in order: if the first entry also
|
|
219
|
+
# declines, the second is tried, and so on.
|
|
220
|
+
#
|
|
221
|
+
# @return [Array<Anthropic::Models::Beta::BetaFallbackParam>, nil]
|
|
222
|
+
optional :fallbacks,
|
|
223
|
+
-> { Anthropic::Internal::Type::ArrayOf[Anthropic::Beta::BetaFallbackParam] },
|
|
224
|
+
nil?: true
|
|
225
|
+
|
|
192
226
|
# @!attribute inference_geo
|
|
193
227
|
# Specifies the geographic region for inference processing. If not specified, the
|
|
194
228
|
# workspace's `default_inference_geo` is used.
|
|
@@ -436,7 +470,7 @@ module Anthropic
|
|
|
436
470
|
# @return [String, nil]
|
|
437
471
|
optional :user_profile_id, String, nil?: true
|
|
438
472
|
|
|
439
|
-
# @!method initialize(max_tokens:, messages:, model:, cache_control: nil, container: nil, context_management: nil, diagnostics: nil, inference_geo: nil, mcp_servers: nil, metadata: nil, output_config: nil, output_format: nil, service_tier: nil, speed: nil, stop_sequences: nil, stream: nil, system_: nil, temperature: nil, thinking: nil, tool_choice: nil, tools: nil, top_k: nil, top_p: nil, user_profile_id: nil)
|
|
473
|
+
# @!method initialize(max_tokens:, messages:, model:, cache_control: nil, container: nil, context_management: nil, diagnostics: nil, fallback_credit_token: nil, fallbacks: nil, inference_geo: nil, mcp_servers: nil, metadata: nil, output_config: nil, output_format: nil, service_tier: nil, speed: nil, stop_sequences: nil, stream: nil, system_: nil, temperature: nil, thinking: nil, tool_choice: nil, tools: nil, top_k: nil, top_p: nil, user_profile_id: nil)
|
|
440
474
|
# Some parameter documentations has been truncated, see
|
|
441
475
|
# {Anthropic::Models::Beta::Messages::BatchCreateParams::Request::Params} for more
|
|
442
476
|
# details.
|
|
@@ -460,6 +494,10 @@ module Anthropic
|
|
|
460
494
|
#
|
|
461
495
|
# @param diagnostics [Anthropic::Models::Beta::BetaDiagnosticsParam, nil] Request-level diagnostics. Currently carries the previous response
|
|
462
496
|
#
|
|
497
|
+
# @param fallback_credit_token [String, nil] The `fallback_credit_token` from a prior refusal's `stop_details`.
|
|
498
|
+
#
|
|
499
|
+
# @param fallbacks [Array<Anthropic::Models::Beta::BetaFallbackParam>, nil] Opt-in server-side retry on one or more substitute models when the requested mod
|
|
500
|
+
#
|
|
463
501
|
# @param inference_geo [String, nil] Specifies the geographic region for inference processing. If not specified, the
|
|
464
502
|
#
|
|
465
503
|
# @param mcp_servers [Array<Anthropic::Models::Beta::BetaRequestMCPServerURLDefinition>] MCP servers to be utilized in this request
|
|
@@ -9,6 +9,10 @@ module Anthropic
|
|
|
9
9
|
module Model
|
|
10
10
|
extend Anthropic::Internal::Type::Union
|
|
11
11
|
|
|
12
|
+
variant const: -> { Anthropic::Models::Model::CLAUDE_FABLE_5 }
|
|
13
|
+
|
|
14
|
+
variant const: -> { Anthropic::Models::Model::CLAUDE_MYTHOS_5 }
|
|
15
|
+
|
|
12
16
|
variant const: -> { Anthropic::Models::Model::CLAUDE_OPUS_4_8 }
|
|
13
17
|
|
|
14
18
|
variant const: -> { Anthropic::Models::Model::CLAUDE_OPUS_4_7 }
|
|
@@ -56,6 +60,12 @@ module Anthropic
|
|
|
56
60
|
|
|
57
61
|
# @!group
|
|
58
62
|
|
|
63
|
+
# Next generation of intelligence for the hardest knowledge work and coding problems
|
|
64
|
+
CLAUDE_FABLE_5 = :"claude-fable-5"
|
|
65
|
+
|
|
66
|
+
# Most capable model for cybersecurity and biology research
|
|
67
|
+
CLAUDE_MYTHOS_5 = :"claude-mythos-5"
|
|
68
|
+
|
|
59
69
|
# Frontier intelligence for long-running agents and coding
|
|
60
70
|
CLAUDE_OPUS_4_8 = :"claude-opus-4-8"
|
|
61
71
|
|
|
@@ -63,6 +73,9 @@ module Anthropic
|
|
|
63
73
|
CLAUDE_OPUS_4_7 = :"claude-opus-4-7"
|
|
64
74
|
|
|
65
75
|
# New class of intelligence, strongest in coding and cybersecurity
|
|
76
|
+
# @deprecated Will reach end-of-life on June 30, 2026. Please migrate to claude-mythos-5.
|
|
77
|
+
# Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more
|
|
78
|
+
# information.
|
|
66
79
|
CLAUDE_MYTHOS_PREVIEW = :"claude-mythos-preview"
|
|
67
80
|
|
|
68
81
|
# Frontier intelligence for long-running agents and coding
|
|
@@ -40,7 +40,7 @@ module Anthropic
|
|
|
40
40
|
# Learn more about the Messages API in our
|
|
41
41
|
# [user guide](https://docs.claude.com/en/docs/initial-setup)
|
|
42
42
|
#
|
|
43
|
-
# @overload create(max_tokens:, messages:, model:, cache_control: nil, container: nil, context_management: nil, diagnostics: nil, inference_geo: nil, mcp_servers: nil, metadata: nil, output_config: nil, output_format: nil, service_tier: nil, speed: nil, stop_sequences: nil, system_: nil, temperature: nil, thinking: nil, tool_choice: nil, tools: nil, top_k: nil, top_p: nil, user_profile_id: nil, betas: nil, request_options: {})
|
|
43
|
+
# @overload create(max_tokens:, messages:, model:, cache_control: nil, container: nil, context_management: nil, diagnostics: nil, fallback_credit_token: nil, fallbacks: nil, inference_geo: nil, mcp_servers: nil, metadata: nil, output_config: nil, output_format: nil, service_tier: nil, speed: nil, stop_sequences: nil, system_: nil, temperature: nil, thinking: nil, tool_choice: nil, tools: nil, top_k: nil, top_p: nil, user_profile_id: nil, betas: nil, request_options: {})
|
|
44
44
|
#
|
|
45
45
|
# @param max_tokens [Integer] Body param: The maximum number of tokens to generate before stopping.
|
|
46
46
|
#
|
|
@@ -56,6 +56,10 @@ module Anthropic
|
|
|
56
56
|
#
|
|
57
57
|
# @param diagnostics [Anthropic::Models::Beta::BetaDiagnosticsParam, nil] Body param: Request-level diagnostics. Currently carries the previous response
|
|
58
58
|
#
|
|
59
|
+
# @param fallback_credit_token [String, nil] Body param: The `fallback_credit_token` from a prior refusal's `stop_details`.
|
|
60
|
+
#
|
|
61
|
+
# @param fallbacks [Array<Anthropic::Models::Beta::BetaFallbackParam>, nil] Body param: Opt-in server-side retry on one or more substitute models when the r
|
|
62
|
+
#
|
|
59
63
|
# @param inference_geo [String, nil] Body param: Specifies the geographic region for inference processing. If not spe
|
|
60
64
|
#
|
|
61
65
|
# @param mcp_servers [Array<Anthropic::Models::Beta::BetaRequestMCPServerURLDefinition>] Body param: MCP servers to be utilized in this request
|
|
@@ -150,7 +154,7 @@ module Anthropic
|
|
|
150
154
|
# Learn more about the Messages API in our
|
|
151
155
|
# [user guide](https://docs.claude.com/en/docs/initial-setup)
|
|
152
156
|
#
|
|
153
|
-
# @overload stream_raw(max_tokens:, messages:, model:, cache_control: nil, container: nil, context_management: nil, diagnostics: nil, inference_geo: nil, mcp_servers: nil, metadata: nil, output_config: nil, output_format: nil, service_tier: nil, speed: nil, stop_sequences: nil, system_: nil, temperature: nil, thinking: nil, tool_choice: nil, tools: nil, top_k: nil, top_p: nil, user_profile_id: nil, betas: nil, request_options: {})
|
|
157
|
+
# @overload stream_raw(max_tokens:, messages:, model:, cache_control: nil, container: nil, context_management: nil, diagnostics: nil, fallback_credit_token: nil, fallbacks: nil, inference_geo: nil, mcp_servers: nil, metadata: nil, output_config: nil, output_format: nil, service_tier: nil, speed: nil, stop_sequences: nil, system_: nil, temperature: nil, thinking: nil, tool_choice: nil, tools: nil, top_k: nil, top_p: nil, user_profile_id: nil, betas: nil, request_options: {})
|
|
154
158
|
#
|
|
155
159
|
# @param max_tokens [Integer] Body param: The maximum number of tokens to generate before stopping.
|
|
156
160
|
#
|
|
@@ -166,6 +170,10 @@ module Anthropic
|
|
|
166
170
|
#
|
|
167
171
|
# @param diagnostics [Anthropic::Models::Beta::BetaDiagnosticsParam, nil] Body param: Request-level diagnostics. Currently carries the previous response
|
|
168
172
|
#
|
|
173
|
+
# @param fallback_credit_token [String, nil] Body param: The `fallback_credit_token` from a prior refusal's `stop_details`.
|
|
174
|
+
#
|
|
175
|
+
# @param fallbacks [Array<Anthropic::Models::Beta::BetaFallbackParam>, nil] Body param: Opt-in server-side retry on one or more substitute models when the r
|
|
176
|
+
#
|
|
169
177
|
# @param inference_geo [String, nil] Body param: Specifies the geographic region for inference processing. If not spe
|
|
170
178
|
#
|
|
171
179
|
# @param mcp_servers [Array<Anthropic::Models::Beta::BetaRequestMCPServerURLDefinition>] Body param: MCP servers to be utilized in this request
|
data/lib/anthropic/version.rb
CHANGED
data/lib/anthropic.rb
CHANGED
|
@@ -205,6 +205,12 @@ require_relative "anthropic/models/beta/beta_encrypted_code_execution_result_blo
|
|
|
205
205
|
require_relative "anthropic/models/beta/beta_encrypted_code_execution_result_block_param"
|
|
206
206
|
require_relative "anthropic/models/beta/beta_environment"
|
|
207
207
|
require_relative "anthropic/models/beta/beta_environment_delete_response"
|
|
208
|
+
require_relative "anthropic/models/beta/beta_fallback_block"
|
|
209
|
+
require_relative "anthropic/models/beta/beta_fallback_block_param"
|
|
210
|
+
require_relative "anthropic/models/beta/beta_fallback_info"
|
|
211
|
+
require_relative "anthropic/models/beta/beta_fallback_info_param"
|
|
212
|
+
require_relative "anthropic/models/beta/beta_fallback_message_iteration_usage"
|
|
213
|
+
require_relative "anthropic/models/beta/beta_fallback_param"
|
|
208
214
|
require_relative "anthropic/models/beta/beta_file_document_source"
|
|
209
215
|
require_relative "anthropic/models/beta/beta_file_image_source"
|
|
210
216
|
require_relative "anthropic/models/beta/beta_file_scope"
|
|
@@ -118,6 +118,16 @@ module Anthropic
|
|
|
118
118
|
:"thinking-token-count-2026-05-13",
|
|
119
119
|
Anthropic::AnthropicBeta::TaggedSymbol
|
|
120
120
|
)
|
|
121
|
+
SERVER_SIDE_FALLBACK_2026_06_01 =
|
|
122
|
+
T.let(
|
|
123
|
+
:"server-side-fallback-2026-06-01",
|
|
124
|
+
Anthropic::AnthropicBeta::TaggedSymbol
|
|
125
|
+
)
|
|
126
|
+
FALLBACK_CREDIT_2026_06_01 =
|
|
127
|
+
T.let(
|
|
128
|
+
:"fallback-credit-2026-06-01",
|
|
129
|
+
Anthropic::AnthropicBeta::TaggedSymbol
|
|
130
|
+
)
|
|
121
131
|
end
|
|
122
132
|
end
|
|
123
133
|
end
|
|
@@ -27,7 +27,8 @@ module Anthropic
|
|
|
27
27
|
Anthropic::Beta::BetaMCPToolUseBlock,
|
|
28
28
|
Anthropic::Beta::BetaMCPToolResultBlock,
|
|
29
29
|
Anthropic::Beta::BetaContainerUploadBlock,
|
|
30
|
-
Anthropic::Beta::BetaCompactionBlock
|
|
30
|
+
Anthropic::Beta::BetaCompactionBlock,
|
|
31
|
+
Anthropic::Beta::BetaFallbackBlock
|
|
31
32
|
)
|
|
32
33
|
end
|
|
33
34
|
|
|
@@ -32,7 +32,8 @@ module Anthropic
|
|
|
32
32
|
Anthropic::Beta::BetaRequestMCPToolResultBlockParam,
|
|
33
33
|
Anthropic::Beta::BetaContainerUploadBlockParam,
|
|
34
34
|
Anthropic::Beta::BetaCompactionBlockParam,
|
|
35
|
-
Anthropic::Beta::BetaMidConversationSystemBlockParam
|
|
35
|
+
Anthropic::Beta::BetaMidConversationSystemBlockParam,
|
|
36
|
+
Anthropic::Beta::BetaFallbackBlockParam
|
|
36
37
|
)
|
|
37
38
|
end
|
|
38
39
|
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module Anthropic
|
|
4
|
+
module Models
|
|
5
|
+
BetaFallbackBlock = Beta::BetaFallbackBlock
|
|
6
|
+
|
|
7
|
+
module Beta
|
|
8
|
+
class BetaFallbackBlock < Anthropic::Internal::Type::BaseModel
|
|
9
|
+
OrHash =
|
|
10
|
+
T.type_alias do
|
|
11
|
+
T.any(
|
|
12
|
+
Anthropic::Beta::BetaFallbackBlock,
|
|
13
|
+
Anthropic::Internal::AnyHash
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# The model whose output ends at this point — the model that declined at this hop.
|
|
18
|
+
# When the declining hop is the requested model, its `model` echoes the top-level
|
|
19
|
+
# `model` string the caller sent (alias or canonical); when the declining hop is a
|
|
20
|
+
# fallback model, its `model` is that model's canonical id.
|
|
21
|
+
sig { returns(Anthropic::Beta::BetaFallbackInfo) }
|
|
22
|
+
attr_reader :from
|
|
23
|
+
|
|
24
|
+
sig { params(from: Anthropic::Beta::BetaFallbackInfo::OrHash).void }
|
|
25
|
+
attr_writer :from
|
|
26
|
+
|
|
27
|
+
# The fallback model producing the content that follows this block. Its `model` is
|
|
28
|
+
# always the canonical id.
|
|
29
|
+
sig { returns(Anthropic::Beta::BetaFallbackInfo) }
|
|
30
|
+
attr_reader :to
|
|
31
|
+
|
|
32
|
+
sig { params(to: Anthropic::Beta::BetaFallbackInfo::OrHash).void }
|
|
33
|
+
attr_writer :to
|
|
34
|
+
|
|
35
|
+
sig { returns(Symbol) }
|
|
36
|
+
attr_accessor :type
|
|
37
|
+
|
|
38
|
+
# Marks the point in `content` where one model's output gives way to the next.
|
|
39
|
+
#
|
|
40
|
+
# One block appears per hop where a preceding model actually ran this turn and
|
|
41
|
+
# declined. A turn routed directly by the sticky decision has no such boundary and
|
|
42
|
+
# carries no block — the signal for whether a fallback model served the response
|
|
43
|
+
# is the presence of a `fallback_message` entry in `usage.iterations`, not this
|
|
44
|
+
# block.
|
|
45
|
+
#
|
|
46
|
+
# The block is treated like a server-tool content block for streaming: it arrives
|
|
47
|
+
# via the standard `content_block_start` / `content_block_stop` pair and carries
|
|
48
|
+
# no deltas.
|
|
49
|
+
sig do
|
|
50
|
+
params(
|
|
51
|
+
from: Anthropic::Beta::BetaFallbackInfo::OrHash,
|
|
52
|
+
to: Anthropic::Beta::BetaFallbackInfo::OrHash,
|
|
53
|
+
type: Symbol
|
|
54
|
+
).returns(T.attached_class)
|
|
55
|
+
end
|
|
56
|
+
def self.new(
|
|
57
|
+
# The model whose output ends at this point — the model that declined at this hop.
|
|
58
|
+
# When the declining hop is the requested model, its `model` echoes the top-level
|
|
59
|
+
# `model` string the caller sent (alias or canonical); when the declining hop is a
|
|
60
|
+
# fallback model, its `model` is that model's canonical id.
|
|
61
|
+
from:,
|
|
62
|
+
# The fallback model producing the content that follows this block. Its `model` is
|
|
63
|
+
# always the canonical id.
|
|
64
|
+
to:,
|
|
65
|
+
type: :fallback
|
|
66
|
+
)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
sig do
|
|
70
|
+
override.returns(
|
|
71
|
+
{
|
|
72
|
+
from: Anthropic::Beta::BetaFallbackInfo,
|
|
73
|
+
to: Anthropic::Beta::BetaFallbackInfo,
|
|
74
|
+
type: Symbol
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
end
|
|
78
|
+
def to_hash
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module Anthropic
|
|
4
|
+
module Models
|
|
5
|
+
BetaFallbackBlockParam = Beta::BetaFallbackBlockParam
|
|
6
|
+
|
|
7
|
+
module Beta
|
|
8
|
+
class BetaFallbackBlockParam < Anthropic::Internal::Type::BaseModel
|
|
9
|
+
OrHash =
|
|
10
|
+
T.type_alias do
|
|
11
|
+
T.any(
|
|
12
|
+
Anthropic::Beta::BetaFallbackBlockParam,
|
|
13
|
+
Anthropic::Internal::AnyHash
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Identifies one hop of a fallback transition.
|
|
18
|
+
sig { returns(Anthropic::Beta::BetaFallbackInfoParam) }
|
|
19
|
+
attr_reader :from
|
|
20
|
+
|
|
21
|
+
sig do
|
|
22
|
+
params(from: Anthropic::Beta::BetaFallbackInfoParam::OrHash).void
|
|
23
|
+
end
|
|
24
|
+
attr_writer :from
|
|
25
|
+
|
|
26
|
+
# Identifies one hop of a fallback transition.
|
|
27
|
+
sig { returns(Anthropic::Beta::BetaFallbackInfoParam) }
|
|
28
|
+
attr_reader :to
|
|
29
|
+
|
|
30
|
+
sig { params(to: Anthropic::Beta::BetaFallbackInfoParam::OrHash).void }
|
|
31
|
+
attr_writer :to
|
|
32
|
+
|
|
33
|
+
sig { returns(Symbol) }
|
|
34
|
+
attr_accessor :type
|
|
35
|
+
|
|
36
|
+
# A `fallback` block echoed back from a prior response.
|
|
37
|
+
#
|
|
38
|
+
# Accepted in `messages[].content` and never rendered into the prompt, not
|
|
39
|
+
# validated against the request's `fallbacks` chain or top-level `model`, and
|
|
40
|
+
# stripped before the sticky-routing cache key is computed.
|
|
41
|
+
#
|
|
42
|
+
# Callers should echo the assistant turn verbatim — block included. The block's
|
|
43
|
+
# position is load-bearing for thinking verification: the thinking runs on either
|
|
44
|
+
# side of a fallback hop carry independently-rooted verification hash chains, and
|
|
45
|
+
# this block is the only record of where one chain ends and the next begins. When
|
|
46
|
+
# thinking runs flank the boundary, omitting the block merges the runs into one
|
|
47
|
+
# contiguous span whose hashes cannot verify (the request is rejected), and moving
|
|
48
|
+
# it into the middle of a single run splits that run's chain and is likewise
|
|
49
|
+
# rejected; between non-thinking blocks the block's placement has no verification
|
|
50
|
+
# effect.
|
|
51
|
+
sig do
|
|
52
|
+
params(
|
|
53
|
+
from: Anthropic::Beta::BetaFallbackInfoParam::OrHash,
|
|
54
|
+
to: Anthropic::Beta::BetaFallbackInfoParam::OrHash,
|
|
55
|
+
type: Symbol
|
|
56
|
+
).returns(T.attached_class)
|
|
57
|
+
end
|
|
58
|
+
def self.new(
|
|
59
|
+
# Identifies one hop of a fallback transition.
|
|
60
|
+
from:,
|
|
61
|
+
# Identifies one hop of a fallback transition.
|
|
62
|
+
to:,
|
|
63
|
+
type: :fallback
|
|
64
|
+
)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
sig do
|
|
68
|
+
override.returns(
|
|
69
|
+
{
|
|
70
|
+
from: Anthropic::Beta::BetaFallbackInfoParam,
|
|
71
|
+
to: Anthropic::Beta::BetaFallbackInfoParam,
|
|
72
|
+
type: Symbol
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
end
|
|
76
|
+
def to_hash
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|