Class: Botiasloop::Conversation::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/botiasloop/conversation.rb

Overview

Message model nested within Conversation namespace

Instance Method Summary collapse

Instance Method Details

#to_hashHash

Convert message to hash for API compatibility

Returns:

  • (Hash)

    Message as hash with symbol keys



27
28
29
30
31
32
33
34
35
# File 'lib/botiasloop/conversation.rb', line 27

def to_hash
  {
    role: role,
    content: content,
    input_tokens: input_tokens || 0,
    output_tokens: output_tokens || 0,
    timestamp: timestamp.iso8601
  }
end

#validateObject

Validations



20
21
22
23
# File 'lib/botiasloop/conversation.rb', line 20

def validate
  super
  validates_presence i[conversation_id role content]
end