Class: OpenAI::SystemMessage

Inherits:
Message
  • Object
show all
Defined in:
lib/open_ai/message.rb

Instance Attribute Summary

Attributes inherited from Message

#body, #chat_id, #chat_thread, #cost, #from, #id, #image, #replies_to, #role, #timestamp

Instance Method Summary collapse

Methods inherited from Message

#as_json, #for_logs

Constructor Details

#initializeSystemMessage

Returns a new instance of SystemMessage.



62
63
64
65
# File 'lib/open_ai/message.rb', line 62

def initialize(...)
  super(...)
  @role = :system
end

Instance Method Details

#to_sObject



67
68
69
# File 'lib/open_ai/message.rb', line 67

def to_s
  [Time.now.utc, "SYSTEM INSTRUCTION", body].join("\n") + "\n"
end

#valid?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/open_ai/message.rb', line 71

def valid?
  [body, chat_thread].all?(&:present?)
end