Class: Durable::Llm::Providers::Xai::XaiStreamResponse

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

Overview

Represents a streaming response chunk from xAI’s API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parsed) ⇒ XaiStreamResponse

Initializes the stream response with parsed chunk data.

Parameters:

  • parsed (Hash)

    The parsed JSON chunk from the stream



279
280
281
# File 'lib/durable/llm/providers/xai.rb', line 279

def initialize(parsed)
  @choices = XaiStreamChoice.new(parsed['choices'])
end

Instance Attribute Details

#choicesObject (readonly)

Returns the value of attribute choices.



274
275
276
# File 'lib/durable/llm/providers/xai.rb', line 274

def choices
  @choices
end

Instance Method Details

#to_sString

Converts the stream response to a string by returning the choice content.

Returns:

  • (String)

    The chunk content



286
287
288
# File 'lib/durable/llm/providers/xai.rb', line 286

def to_s
  @choices.to_s
end