Class: RubyGPT::Message
- Inherits:
-
Object
- Object
- RubyGPT::Message
- Defined in:
- lib/ruby_gpt/message.rb
Overview
The ‘RubyGPT::Message` class provides a simple interface for creating message objects [TODO].
Constant Summary collapse
- VALID_ROLES =
%w[user assistant system].freeze
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
Instance Method Summary collapse
-
#initialize(role:, content:) ⇒ Message
constructor
A new instance of Message.
- #to_h ⇒ Object
Constructor Details
#initialize(role:, content:) ⇒ Message
Returns a new instance of Message.
8 9 10 11 12 13 14 |
# File 'lib/ruby_gpt/message.rb', line 8 def initialize(role:, content:) validate_role(role) validate_content(content) @role = role @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
6 7 8 |
# File 'lib/ruby_gpt/message.rb', line 6 def content @content end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
6 7 8 |
# File 'lib/ruby_gpt/message.rb', line 6 def role @role end |
Instance Method Details
#to_h ⇒ Object
16 17 18 |
# File 'lib/ruby_gpt/message.rb', line 16 def to_h { role: @role, content: @content } end |