Class: Durable::Llm::Providers::Groq::GroqStreamResponse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fragment) ⇒ GroqStreamResponse

Returns a new instance of GroqStreamResponse.



134
135
136
137
138
139
# File 'lib/durable/llm/providers/groq.rb', line 134

def initialize(fragment)
  json_frag = fragment.split('data: ').last.strip
  puts json_frag
  parsed = JSON.parse(json_frag)
  @choices = parsed['choices'].map { |choice| GroqStreamChoice.new(choice) }
end

Instance Attribute Details

#choicesObject (readonly)

Returns the value of attribute choices.



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

def choices
  @choices
end

Instance Method Details

#to_sObject



141
142
143
# File 'lib/durable/llm/providers/groq.rb', line 141

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