Class: Raif::Messages::UserMessage
- Inherits:
-
Object
- Object
- Raif::Messages::UserMessage
- Defined in:
- lib/raif/messages.rb
Overview
User role message
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Class Method Summary collapse
-
.from_h(hash) ⇒ UserMessage
Deserialize from a hash.
Instance Method Summary collapse
-
#initialize(content:) ⇒ UserMessage
constructor
A new instance of UserMessage.
-
#to_h ⇒ Hash
Hash representation for JSONB storage and LLM APIs.
Constructor Details
#initialize(content:) ⇒ UserMessage
Returns a new instance of UserMessage.
36 37 38 |
# File 'lib/raif/messages.rb', line 36 def initialize(content:) @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
33 34 35 |
# File 'lib/raif/messages.rb', line 33 def content @content end |
Class Method Details
.from_h(hash) ⇒ UserMessage
Deserialize from a hash
48 49 50 |
# File 'lib/raif/messages.rb', line 48 def self.from_h(hash) new(content: hash["content"]) end |
Instance Method Details
#to_h ⇒ Hash
Returns Hash representation for JSONB storage and LLM APIs.
41 42 43 |
# File 'lib/raif/messages.rb', line 41 def to_h { "role" => "user", "content" => content } end |