Class: ActiveAgent::ActionPrompt::Message
- Inherits:
-
Object
- Object
- ActiveAgent::ActionPrompt::Message
- Defined in:
- lib/active_agent/action_prompt/message.rb
Constant Summary collapse
- VALID_ROLES =
%w[system assistant user tool function].freeze
Instance Attribute Summary collapse
-
#action_requested ⇒ Object
Returns the value of attribute action_requested.
-
#charset ⇒ Object
Returns the value of attribute charset.
-
#content ⇒ Object
Returns the value of attribute content.
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#name ⇒ Object
Returns the value of attribute name.
-
#requested_actions ⇒ Object
Returns the value of attribute requested_actions.
-
#role ⇒ Object
Returns the value of attribute role.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Message
constructor
A new instance of Message.
- #to_h ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Message
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/active_agent/action_prompt/message.rb', line 8 def initialize(attributes = {}) @agent_class = attributes[:agent_class] @charset = attributes[:charset] || "UTF-8" @content = attributes[:content] || "" @content_type = attributes[:content_type] || "text/plain" @name = attributes[:name] @role = attributes[:role] || :user @requested_actions = attributes[:requested_actions] || [] @action_requested = @requested_actions.any? validate_role end |
Instance Attribute Details
#action_requested ⇒ Object
Returns the value of attribute action_requested.
6 7 8 |
# File 'lib/active_agent/action_prompt/message.rb', line 6 def action_requested @action_requested end |
#charset ⇒ Object
Returns the value of attribute charset.
6 7 8 |
# File 'lib/active_agent/action_prompt/message.rb', line 6 def charset @charset end |
#content ⇒ Object
Returns the value of attribute content.
6 7 8 |
# File 'lib/active_agent/action_prompt/message.rb', line 6 def content @content end |
#content_type ⇒ Object
Returns the value of attribute content_type.
6 7 8 |
# File 'lib/active_agent/action_prompt/message.rb', line 6 def content_type @content_type end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/active_agent/action_prompt/message.rb', line 6 def name @name end |
#requested_actions ⇒ Object
Returns the value of attribute requested_actions.
6 7 8 |
# File 'lib/active_agent/action_prompt/message.rb', line 6 def requested_actions @requested_actions end |
#role ⇒ Object
Returns the value of attribute role.
6 7 8 |
# File 'lib/active_agent/action_prompt/message.rb', line 6 def role @role end |
Instance Method Details
#to_h ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/active_agent/action_prompt/message.rb', line 20 def to_h hash = { role: role, content: content, content_type: content_type, charset: charset } hash[:name] = name if name hash[:action_requested] = requested_actions.any? hash[:requested_actions] = requested_actions if requested_actions.any? hash end |