Class: Durable::Llm::Providers::Xai::XaiStreamDelta

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

Overview

Represents a delta (incremental change) in a streaming response.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(delta) ⇒ XaiStreamDelta

Initializes the delta with role and content.

Parameters:

  • delta (Hash)

    The delta data from the stream chunk



338
339
340
341
# File 'lib/durable/llm/providers/xai.rb', line 338

def initialize(delta)
  @role = delta['role']
  @content = delta['content']
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



333
334
335
# File 'lib/durable/llm/providers/xai.rb', line 333

def content
  @content
end

#roleObject (readonly)

Returns the value of attribute role.



333
334
335
# File 'lib/durable/llm/providers/xai.rb', line 333

def role
  @role
end

Instance Method Details

#to_sString

Converts the delta to a string by returning the content or empty string.

Returns:

  • (String)

    The delta content or empty string



346
347
348
# File 'lib/durable/llm/providers/xai.rb', line 346

def to_s
  @content || ''
end