Class: Durable::Llm::Providers::Xai::XaiStreamChoice
- Inherits:
-
Object
- Object
- Durable::Llm::Providers::Xai::XaiStreamChoice
- Defined in:
- lib/durable/llm/providers/xai.rb
Overview
Represents a choice in a streaming response from xAI.
Instance Attribute Summary collapse
-
#delta ⇒ Object
readonly
Returns the value of attribute delta.
-
#finish_reason ⇒ Object
readonly
Returns the value of attribute finish_reason.
Instance Method Summary collapse
-
#initialize(choice) ⇒ XaiStreamChoice
constructor
Initializes the stream choice with delta and finish reason.
-
#to_s ⇒ String
Converts the choice to a string by returning the delta content.
Constructor Details
#initialize(choice) ⇒ XaiStreamChoice
Initializes the stream choice with delta and finish reason.
317 318 319 320 321 |
# File 'lib/durable/llm/providers/xai.rb', line 317 def initialize(choice) @choice = [choice].flatten.first @delta = XaiStreamDelta.new(@choice['delta']) @finish_reason = @choice['finish_reason'] end |
Instance Attribute Details
#delta ⇒ Object (readonly)
Returns the value of attribute delta.
312 313 314 |
# File 'lib/durable/llm/providers/xai.rb', line 312 def delta @delta end |
#finish_reason ⇒ Object (readonly)
Returns the value of attribute finish_reason.
312 313 314 |
# File 'lib/durable/llm/providers/xai.rb', line 312 def finish_reason @finish_reason end |
Instance Method Details
#to_s ⇒ String
Converts the choice to a string by returning the delta content.
326 327 328 |
# File 'lib/durable/llm/providers/xai.rb', line 326 def to_s @delta.to_s end |