Module: Anthropic::Models::RawMessageStreamEvent

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

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::RawMessageStartEvent, ...

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

Parameters:

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

    Attributes for the chosen variant.

    @option args [Anthropic::Models::Message] :message

    @option args [Anthropic::Models::RawMessageDeltaEvent::Delta, Anthropic::Models::TextDelta, Anthropic::Models::InputJSONDelta, Anthropic::Models::CitationsDelta, Anthropic::Models::ThinkingDelta, Anthropic::Models::SignatureDelta] :delta

    @option args [Anthropic::Models::MessageDeltaUsage] :usage Billing and rate-limit usage.

    @option args [Anthropic::Models::TextBlock, Anthropic::Models::ThinkingBlock, Anthropic::Models::RedactedThinkingBlock, Anthropic::Models::ToolUseBlock, Anthropic::Models::ServerToolUseBlock, Anthropic::Models::WebSearchToolResultBlock, Anthropic::Models::WebFetchToolResultBlock, Anthropic::Models::CodeExecutionToolResultBlock, Anthropic::Models::BashCodeExecutionToolResultBlock, Anthropic::Models::TextEditorCodeExecutionToolResultBlock, Anthropic::Models::ToolSearchToolResultBlock, Anthropic::Models::ContainerUploadBlock] :content_block Response model for a file uploaded to the container.

    @option args [Integer] :index

Returns:

Raises:

  • (ArgumentError)


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/anthropic/models/raw_message_stream_event.rb', line 47

def self.new(type:, **args)
  case type.to_sym
  when :message_start
    Anthropic::RawMessageStartEvent.new(**args)
  when :message_delta
    Anthropic::RawMessageDeltaEvent.new(**args)
  when :message_stop
    Anthropic::RawMessageStopEvent.new(**args)
  when :content_block_start
    Anthropic::RawContentBlockStartEvent.new(**args)
  when :content_block_delta
    Anthropic::RawContentBlockDeltaEvent.new(**args)
  when :content_block_stop
    Anthropic::RawContentBlockStopEvent.new(**args)
  else
    raise ArgumentError, "unknown type: #{type}"
  end
end

Instance Method Details

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

Returns:

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


14
# File 'sig/anthropic/models/raw_message_stream_event.rbs', line 14

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