Class: Durable::Llm::Providers::OpenAI::OpenAIStreamDelta

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

Overview

Represents the incremental content delta in a streaming response.

Contains the role (for the first chunk) and content updates.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(delta) ⇒ OpenAIStreamDelta

Returns a new instance of OpenAIStreamDelta.



379
380
381
382
# File 'lib/durable/llm/providers/openai.rb', line 379

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

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



377
378
379
# File 'lib/durable/llm/providers/openai.rb', line 377

def content
  @content
end

#roleObject (readonly)

Returns the value of attribute role.



377
378
379
# File 'lib/durable/llm/providers/openai.rb', line 377

def role
  @role
end

Instance Method Details

#to_sObject



384
385
386
# File 'lib/durable/llm/providers/openai.rb', line 384

def to_s
  @content || ''
end