Class: Kodo::Message
- Inherits:
-
Data
- Object
- Data
- Kodo::Message
- Defined in:
- lib/kodo/message.rb
Instance Attribute Summary collapse
-
#channel_id ⇒ Object
readonly
Returns the value of attribute channel_id.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#sender ⇒ Object
readonly
Returns the value of attribute sender.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #from_agent? ⇒ Boolean
- #from_system? ⇒ Boolean
- #from_user? ⇒ Boolean
-
#initialize(id: SecureRandom.uuid, channel_id:, sender:, content:, timestamp: Time.now, metadata: {}) ⇒ Message
constructor
A new instance of Message.
-
#to_llm_message ⇒ Object
Convert to the format expected by LLM providers.
Constructor Details
#initialize(id: SecureRandom.uuid, channel_id:, sender:, content:, timestamp: Time.now, metadata: {}) ⇒ Message
Returns a new instance of Message.
14 15 16 |
# File 'lib/kodo/message.rb', line 14 def initialize(id: SecureRandom.uuid, channel_id:, sender:, content:, timestamp: Time.now, metadata: {}) super end |
Instance Attribute Details
#channel_id ⇒ Object (readonly)
Returns the value of attribute channel_id
6 7 8 |
# File 'lib/kodo/message.rb', line 6 def channel_id @channel_id end |
#content ⇒ Object (readonly)
Returns the value of attribute content
6 7 8 |
# File 'lib/kodo/message.rb', line 6 def content @content end |
#id ⇒ Object (readonly)
Returns the value of attribute id
6 7 8 |
# File 'lib/kodo/message.rb', line 6 def id @id end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata
6 7 8 |
# File 'lib/kodo/message.rb', line 6 def @metadata end |
#sender ⇒ Object (readonly)
Returns the value of attribute sender
6 7 8 |
# File 'lib/kodo/message.rb', line 6 def sender @sender end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp
6 7 8 |
# File 'lib/kodo/message.rb', line 6 def @timestamp end |
Instance Method Details
#from_agent? ⇒ Boolean
19 |
# File 'lib/kodo/message.rb', line 19 def from_agent? = sender == :agent |
#from_system? ⇒ Boolean
20 |
# File 'lib/kodo/message.rb', line 20 def from_system? = sender == :system |
#from_user? ⇒ Boolean
18 |
# File 'lib/kodo/message.rb', line 18 def from_user? = sender == :user |
#to_llm_message ⇒ Object
Convert to the format expected by LLM providers
23 24 25 26 |
# File 'lib/kodo/message.rb', line 23 def role = from_user? ? "user" : "assistant" { role: role, content: content } end |