Class: Durable::Llm::Providers::Anthropic::AnthropicStreamResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/durable/llm/providers/anthropic.rb

Overview

Response object for streaming Anthropic messages chunks.

This wraps individual chunks from the Server-Sent Events stream, providing access to the incremental content updates.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parsed) ⇒ AnthropicStreamResponse

Returns a new instance of AnthropicStreamResponse.



326
327
328
329
330
331
332
333
334
# File 'lib/durable/llm/providers/anthropic.rb', line 326

def initialize(parsed)
  @type = parsed['type']
  @choices = case @type
             when 'content_block_delta'
               [AnthropicStreamChoice.new(parsed)]
             else
               []
             end
end

Instance Attribute Details

#choicesObject (readonly)

Returns the value of attribute choices.



324
325
326
# File 'lib/durable/llm/providers/anthropic.rb', line 324

def choices
  @choices
end

#typeObject (readonly)

Returns the value of attribute type.



324
325
326
# File 'lib/durable/llm/providers/anthropic.rb', line 324

def type
  @type
end

Instance Method Details

#to_sObject



336
337
338
# File 'lib/durable/llm/providers/anthropic.rb', line 336

def to_s
  @choices.map(&:to_s).join(' ')
end