Class: OmniAI::Chat::Delta

Inherits:
Object
  • Object
show all
Defined in:
lib/omniai/chat/delta.rb

Overview

An OmniAI::Chat::Delta is used to assist with streaming. It represents a chunk of a conversation that is yielded back to the caller.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text: nil, thinking: nil) ⇒ Delta

Returns a new instance of Delta.

Parameters:

  • text (String, nil) (defaults to: nil)
  • thinking (String, nil) (defaults to: nil)


18
19
20
21
# File 'lib/omniai/chat/delta.rb', line 18

def initialize(text: nil, thinking: nil)
  @text = text
  @thinking = thinking
end

Instance Attribute Details

#textString?

Returns:

  • (String, nil)


10
11
12
# File 'lib/omniai/chat/delta.rb', line 10

def text
  @text
end

#thinkingString?

Returns:

  • (String, nil)


14
15
16
# File 'lib/omniai/chat/delta.rb', line 14

def thinking
  @thinking
end

Instance Method Details

#text?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/omniai/chat/delta.rb', line 24

def text?
  !@text.nil? && !@text.empty?
end

#thinking?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/omniai/chat/delta.rb', line 29

def thinking?
  !@thinking.nil? && !@thinking.empty?
end