Class: OmniAI::Chat::Text

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

Overview

Just some text.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Content

summarize

Constructor Details

#initialize(text = nil) ⇒ Text

Returns a new instance of Text.

Parameters:

  • text (text) (defaults to: nil)


11
12
13
14
# File 'lib/omniai/chat/text.rb', line 11

def initialize(text = nil)
  super()
  @text = text
end

Instance Attribute Details

#textString

Returns:

  • (String)


8
9
10
# File 'lib/omniai/chat/text.rb', line 8

def text
  @text
end

Class Method Details

.deserialize(data, context: nil) ⇒ Object

Parameters:

  • data (Hash)


27
28
29
30
31
32
# File 'lib/omniai/chat/text.rb', line 27

def self.deserialize(data, context: nil)
  deserialize = context&.deserializer(:text)
  return deserialize.call(data, context:) if deserialize

  new(data['text'])
end

Instance Method Details

#inspectString

Returns:

  • (String)


17
18
19
# File 'lib/omniai/chat/text.rb', line 17

def inspect
  "#<#{self.class} text=#{@text.inspect}>"
end

#serialize(context: nil) ⇒ Hash

Parameters:

  • context (Context) (defaults to: nil)

    optional

Returns:

  • (Hash)


37
38
39
40
41
42
# File 'lib/omniai/chat/text.rb', line 37

def serialize(context: nil)
  serializer = context&.serializer(:text)
  return serializer.call(self, context:) if serializer

  { type: 'text', text: @text }
end

#summarizeString

Returns:

  • (String)


22
23
24
# File 'lib/omniai/chat/text.rb', line 22

def summarize
  @text
end