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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fragment) ⇒ AnthropicStreamResponse

Returns a new instance of AnthropicStreamResponse.



131
132
133
134
# File 'lib/durable/llm/providers/anthropic.rb', line 131

def initialize(fragment)
  parsed = JSON.parse(fragment.split('data: ').last)
  @choices = [AnthropicStreamChoice.new(parsed['delta'])]
end

Instance Attribute Details

#choicesObject (readonly)

Returns the value of attribute choices.



129
130
131
# File 'lib/durable/llm/providers/anthropic.rb', line 129

def choices
  @choices
end

Instance Method Details

#to_sObject



136
137
138
# File 'lib/durable/llm/providers/anthropic.rb', line 136

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