Module: Anthropic::Models::Beta::BetaContentBlock

Extended by:
Internal::Type::Union
Defined in:
lib/anthropic/models/beta/beta_content_block.rb

Defined Under Namespace

Modules: Type

Class Method Summary collapse

Methods included from Internal::Type::Union

==, ===, coerce, derefed_variants, dump, hash, inspect, to_sorbet_type, variants

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Methods included from Internal::Type::Converter

#coerce, coerce, #dump, dump, inspect, #inspect, meta_info, new_coerce_state, type_info

Class Method Details

.new(type:, **args) ⇒ Anthropic::Models::Beta::BetaTextBlock, ...

Creates a new instance of the variant class whose type matches the given value, passing the remaining arguments to its constructor.

Some parameter documentations has been truncated, see Anthropic::Models::Beta::BetaContentBlock for more details.

Parameters:

  • type (Symbol, Anthropic::Models::Beta::BetaContentBlock::Type, String)
  • args (Hash{Symbol=>Object})

    Attributes for the chosen variant.

    @option args [Array<Anthropic::Models::Beta::BetaCitationCharLocation, Anthropic::Models::Beta::BetaCitationPageLocation, Anthropic::Models::Beta::BetaCitationContentBlockLocation, Anthropic::Models::Beta::BetaCitationsWebSearchResultLocation, Anthropic::Models::Beta::BetaCitationSearchResultLocation>, nil] :citations Citations supporting the text block.

    @option args [String] :text

    @option args [String, String, nil] :signature A value used to verify that this thinking block was generated by Claude when it

    @option args [String] :thinking The text of Claude's thinking process for this block.

    @option args [String] :data The contents of this redacted thinking block, returned when portions of the mode

    @option args [String] :id

    @option args [HashSymbol=>Object] :input

    @option args [String, Symbol, Anthropic::Models::Beta::BetaServerToolUseBlock::Name] :name The name of the MCP tool

    @option args [Anthropic::Models::Beta::BetaDirectCaller, Anthropic::Models::Beta::BetaServerToolCaller, Anthropic::Models::Beta::BetaServerToolCaller20260120] :caller_

    @option args [String, nil] :toolset_name For a toolset member tool_use, the toolset family.

    @option args [Anthropic::Models::Beta::BetaWebSearchToolResultError, ArrayAnthropic::Models::Beta::BetaWebSearchResultBlock, Anthropic::Models::Beta::BetaWebFetchToolResultErrorBlock, Anthropic::Models::Beta::BetaWebFetchBlock, Anthropic::Models::Beta::BetaAdvisorToolResultError, Anthropic::Models::Beta::BetaAdvisorResultBlock, Anthropic::Models::Beta::BetaAdvisorRedactedResultBlock, Anthropic::Models::Beta::BetaCodeExecutionToolResultError, Anthropic::Models::Beta::BetaCodeExecutionResultBlock, Anthropic::Models::Beta::BetaEncryptedCodeExecutionResultBlock, Anthropic::Models::Beta::BetaBashCodeExecutionToolResultError, Anthropic::Models::Beta::BetaBashCodeExecutionResultBlock, Anthropic::Models::Beta::BetaTextEditorCodeExecutionToolResultError, Anthropic::Models::Beta::BetaTextEditorCodeExecutionViewResultBlock, Anthropic::Models::Beta::BetaTextEditorCodeExecutionCreateResultBlock, Anthropic::Models::Beta::BetaTextEditorCodeExecutionStrReplaceResultBlock, Anthropic::Models::Beta::BetaToolSearchToolResultError, Anthropic::Models::Beta::BetaToolSearchToolSearchResultBlock, String, ArrayAnthropic::Models::Beta::BetaTextBlock, String, nil] :content Summary of compacted content, or null if compaction failed

    @option args [String] :tool_use_id

    @option args [String] :server_name The name of the MCP server

    @option args [Boolean] :is_error

    @option args [String] :file_id

    @option args [String, nil] :encrypted_content Opaque metadata from prior compaction, to be round-tripped verbatim

    @option args [Array<Anthropic::Models::Beta::BetaResponseToolAdditionBlock, Anthropic::Models::Beta::BetaResponseToolRemovalBlock>, nil] :tool_changes The tool changes of the compacted range: the tool_addition and tool_removal

    @option args [Anthropic::Models::Beta::BetaFallbackInfo] :from The model whose output ends at this point — the model that declined at this hop.

    @option args [Anthropic::Models::Beta::BetaFallbackInfo] :to The fallback model producing the content that follows this block. Its model is

    @option args [Anthropic::Models::Beta::BetaFallbackRefusalTrigger] :trigger What caused the from model to hand over at this hop.

    @option args [String] :mcp_server_name

    @option args [ArrayAnthropic::Models::Beta::BetaMCPTool] :tools

Returns:

Raises:

  • (ArgumentError)


154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/anthropic/models/beta/beta_content_block.rb', line 154

def self.new(type:, **args)
  case type.to_sym
  when :text
    Anthropic::Beta::BetaTextBlock.new(**args)
  when :thinking
    Anthropic::Beta::BetaThinkingBlock.new(**args)
  when :redacted_thinking
    Anthropic::Beta::BetaRedactedThinkingBlock.new(**args)
  when :tool_use
    Anthropic::Beta::BetaToolUseBlock.new(**args)
  when :server_tool_use
    Anthropic::Beta::BetaServerToolUseBlock.new(**args)
  when :web_search_tool_result
    Anthropic::Beta::BetaWebSearchToolResultBlock.new(**args)
  when :web_fetch_tool_result
    Anthropic::Beta::BetaWebFetchToolResultBlock.new(**args)
  when :advisor_tool_result
    Anthropic::Beta::BetaAdvisorToolResultBlock.new(**args)
  when :code_execution_tool_result
    Anthropic::Beta::BetaCodeExecutionToolResultBlock.new(**args)
  when :bash_code_execution_tool_result
    Anthropic::Beta::BetaBashCodeExecutionToolResultBlock.new(**args)
  when :text_editor_code_execution_tool_result
    Anthropic::Beta::BetaTextEditorCodeExecutionToolResultBlock.new(**args)
  when :tool_search_tool_result
    Anthropic::Beta::BetaToolSearchToolResultBlock.new(**args)
  when :mcp_tool_use
    Anthropic::Beta::BetaMCPToolUseBlock.new(**args)
  when :mcp_tool_result
    Anthropic::Beta::BetaMCPToolResultBlock.new(**args)
  when :container_upload
    Anthropic::Beta::BetaContainerUploadBlock.new(**args)
  when :compaction
    Anthropic::Beta::BetaCompactionBlock.new(**args)
  when :fallback
    Anthropic::Beta::BetaFallbackBlock.new(**args)
  when :mcp_tool_listing
    Anthropic::Beta::BetaMCPToolListingBlock.new(**args)
  else
    raise ArgumentError, "unknown type: #{type}"
  end
end

.valuesArray<Symbol>

Returns:

  • (Array<Symbol>)


# File 'lib/anthropic/models/beta/beta_content_block.rb', line 91

.variantsArray(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, Anthropic::Models::Beta::BetaMCPToolListingBlock)



# File 'lib/anthropic/models/beta/beta_content_block.rb', line 95