Class: OmniAI::Chat::Delta
- Inherits:
-
Object
- Object
- OmniAI::Chat::Delta
- Defined in:
- lib/omniai/chat/delta.rb
Overview
A delta returned by the API.
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#role ⇒ Object
Returns the value of attribute role.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(content:, role: nil) ⇒ Delta
constructor
A new instance of Delta.
- #inspect ⇒ String
Constructor Details
#initialize(content:, role: nil) ⇒ Delta
Returns a new instance of Delta.
20 21 22 23 |
# File 'lib/omniai/chat/delta.rb', line 20 def initialize(content:, role: nil) @content = content @role = role end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
7 8 9 |
# File 'lib/omniai/chat/delta.rb', line 7 def content @content end |
#role ⇒ Object
Returns the value of attribute role.
7 8 9 |
# File 'lib/omniai/chat/delta.rb', line 7 def role @role end |
Class Method Details
.for(data:) ⇒ OmniAI::Chat::Message
11 12 13 14 15 16 |
# File 'lib/omniai/chat/delta.rb', line 11 def self.for(data:) content = data['content'] || data[:content] role = data['role'] || data[:role] new(content:, role: role || Role::USER) end |
Instance Method Details
#inspect ⇒ String
26 27 28 |
# File 'lib/omniai/chat/delta.rb', line 26 def inspect "#<#{self.class.name} role=#{role.inspect} content=#{content.inspect}>" end |