Module: Anthropic::Models::ContentBlockParam

Extended by:
Internal::Type::Union
Defined in:
lib/anthropic/models/content_block_param.rb,
sig/anthropic/models/content_block_param.rbs

Overview

Regular text content.

Class Method Summary collapse

Instance 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::TextBlockParam, ...

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::ContentBlockParam for more details.

Parameters:

  • type (Symbol, String)
  • args (Hash{Symbol=>Object})

    Attributes for the chosen variant.

    @option args [String] :text

    @option args [Anthropic::Models::CacheControlEphemeral, nil] :cache_control Create a cache control breakpoint at this content block.

    @option args [Array<Anthropic::Models::CitationCharLocationParam, Anthropic::Models::CitationPageLocationParam, Anthropic::Models::CitationContentBlockLocationParam, Anthropic::Models::CitationWebSearchResultLocationParam, Anthropic::Models::CitationSearchResultLocationParam>, nil, Anthropic::Models::CitationsConfigParam, nil, Anthropic::Models::CitationsConfigParam] :citations

    @option args [Anthropic::Models::Base64ImageSource, Anthropic::Models::URLImageSource, Anthropic::Models::Base64PDFSource, Anthropic::Models::PlainTextSource, Anthropic::Models::ContentBlockSource, Anthropic::Models::URLPDFSource, String] :source

    @option args [String, nil] :context

    @option args [String, nil, String] :title

    @option args [ArrayAnthropic::Models::TextBlockParam, String, Array<Anthropic::Models::TextBlockParam, Anthropic::Models::ImageBlockParam, Anthropic::Models::SearchResultBlockParam, Anthropic::Models::DocumentBlockParam, Anthropic::Models::ToolReferenceBlockParam>, ArrayAnthropic::Models::WebSearchResultBlockParam, Anthropic::Models::WebSearchToolRequestError, Anthropic::Models::WebFetchToolResultErrorBlockParam, Anthropic::Models::WebFetchBlockParam, Anthropic::Models::CodeExecutionToolResultErrorParam, Anthropic::Models::CodeExecutionResultBlockParam, Anthropic::Models::EncryptedCodeExecutionResultBlockParam, Anthropic::Models::BashCodeExecutionToolResultErrorParam, Anthropic::Models::BashCodeExecutionResultBlockParam, Anthropic::Models::TextEditorCodeExecutionToolResultErrorParam, Anthropic::Models::TextEditorCodeExecutionViewResultBlockParam, Anthropic::Models::TextEditorCodeExecutionCreateResultBlockParam, Anthropic::Models::TextEditorCodeExecutionStrReplaceResultBlockParam, Anthropic::Models::ToolSearchToolResultErrorParam, Anthropic::Models::ToolSearchToolSearchResultBlockParam] :content Code execution result with encrypted stdout for PFC + web_search results.

    @option args [String] :signature The signature value of this thinking block, exactly as returned by the API in

    @option args [String] :thinking The thinking text of this block as returned by the API.

    @option args [String] :data The data value of this redacted thinking block, exactly as returned by the API

    @option args [String] :id

    @option args [HashSymbol=>Object] :input

    @option args [String, Symbol, Anthropic::Models::ServerToolUseBlockParam::Name] :name

    @option args [Anthropic::Models::DirectCaller, Anthropic::Models::ServerToolCaller, Anthropic::Models::ServerToolCaller20260120] :caller_ Tool invocation directly from the model.

    @option args [String] :tool_use_id

    @option args [Boolean] :is_error

    @option args [String] :file_id

Returns:

Raises:

  • (ArgumentError)


109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/anthropic/models/content_block_param.rb', line 109

def self.new(type:, **args)
  case type.to_sym
  when :text
    Anthropic::TextBlockParam.new(**args)
  when :image
    Anthropic::ImageBlockParam.new(**args)
  when :document
    Anthropic::DocumentBlockParam.new(**args)
  when :search_result
    Anthropic::SearchResultBlockParam.new(**args)
  when :thinking
    Anthropic::ThinkingBlockParam.new(**args)
  when :redacted_thinking
    Anthropic::RedactedThinkingBlockParam.new(**args)
  when :tool_use
    Anthropic::ToolUseBlockParam.new(**args)
  when :tool_result
    Anthropic::ToolResultBlockParam.new(**args)
  when :server_tool_use
    Anthropic::ServerToolUseBlockParam.new(**args)
  when :web_search_tool_result
    Anthropic::WebSearchToolResultBlockParam.new(**args)
  when :web_fetch_tool_result
    Anthropic::WebFetchToolResultBlockParam.new(**args)
  when :code_execution_tool_result
    Anthropic::CodeExecutionToolResultBlockParam.new(**args)
  when :bash_code_execution_tool_result
    Anthropic::BashCodeExecutionToolResultBlockParam.new(**args)
  when :text_editor_code_execution_tool_result
    Anthropic::TextEditorCodeExecutionToolResultBlockParam.new(**args)
  when :tool_search_tool_result
    Anthropic::ToolSearchToolResultBlockParam.new(**args)
  when :container_upload
    Anthropic::ContainerUploadBlockParam.new(**args)
  when :mid_conv_system
    Anthropic::MidConversationSystemBlockParam.new(**args)
  else
    raise ArgumentError, "unknown type: #{type}"
  end
end

.variantsArray(Anthropic::Models::TextBlockParam, Anthropic::Models::ImageBlockParam, Anthropic::Models::DocumentBlockParam, Anthropic::Models::SearchResultBlockParam, Anthropic::Models::ThinkingBlockParam, Anthropic::Models::RedactedThinkingBlockParam, Anthropic::Models::ToolUseBlockParam, Anthropic::Models::ToolResultBlockParam, Anthropic::Models::ServerToolUseBlockParam, Anthropic::Models::WebSearchToolResultBlockParam, Anthropic::Models::WebFetchToolResultBlockParam, Anthropic::Models::CodeExecutionToolResultBlockParam, Anthropic::Models::BashCodeExecutionToolResultBlockParam, Anthropic::Models::TextEditorCodeExecutionToolResultBlockParam, Anthropic::Models::ToolSearchToolResultBlockParam, Anthropic::Models::ContainerUploadBlockParam, Anthropic::Models::MidConversationSystemBlockParam)



# File 'lib/anthropic/models/content_block_param.rb', line 60

Instance Method Details

#self?.variants::Array[Anthropic::Models::content_block_param]

Returns:

  • (::Array[Anthropic::Models::content_block_param])


25
# File 'sig/anthropic/models/content_block_param.rbs', line 25

def self?.variants: -> ::Array[Anthropic::Models::content_block_param]