Class: RobotLab::ToolCallMessage
- Defined in:
- lib/robot_lab/message.rb
Overview
Message containing one or more tool calls from the assistant
Constant Summary
Constants inherited from Message
Message::VALID_ROLES, Message::VALID_STOP_REASONS, Message::VALID_TYPES
Instance Attribute Summary collapse
-
#tools ⇒ Object
readonly
Returns the value of attribute tools.
Attributes inherited from Message
#content, #role, #stop_reason, #type
Instance Method Summary collapse
-
#initialize(role:, tools:, stop_reason: nil) ⇒ ToolCallMessage
constructor
Creates a new ToolCallMessage instance.
-
#to_h ⇒ Hash
Converts the tool call message to a hash representation.
Methods inherited from Message
#assistant?, from_hash, #stopped?, #system?, #text?, #to_json, #tool_call?, #tool_result?, #tool_stop?, #user?
Constructor Details
#initialize(role:, tools:, stop_reason: nil) ⇒ ToolCallMessage
Creates a new ToolCallMessage instance.
241 242 243 244 |
# File 'lib/robot_lab/message.rb', line 241 def initialize(role:, tools:, stop_reason: nil) @tools = normalize_tools(tools) super(type: "tool_call", role: role, content: nil, stop_reason: stop_reason || "tool") end |
Instance Attribute Details
#tools ⇒ Object (readonly)
Returns the value of attribute tools.
234 235 236 |
# File 'lib/robot_lab/message.rb', line 234 def tools @tools end |
Instance Method Details
#to_h ⇒ Hash
Converts the tool call message to a hash representation.
249 250 251 252 253 254 255 256 |
# File 'lib/robot_lab/message.rb', line 249 def to_h { type: type, role: role, tools: tools.map(&:to_h), stop_reason: stop_reason } end |