class Riffer::Messages::Tool
Represents a tool execution result in a conversation.
msg = Riffer::Messages::Tool.new( “The weather is sunny.”, tool_call_id: “call_123”, name: “weather_tool” ) msg.role # => :tool msg.tool_call_id # => “call_123” msg.error? # => false
Attributes
The error message if the tool execution failed.
The type of error (:unknown_tool, :validation_error, :execution_error, :timeout_error).
The name of the tool that was called.
The ID of the tool call this result responds to.
Public Class Methods
Source
# File lib/riffer/messages/tool.rb, line 29 def initialize(content, tool_call_id:, name:, error: nil, error_type: nil) super(content) @tool_call_id = tool_call_id @name = name @error = error @error_type = error_type end
: (String, tool_call_id: String, name: String, ?error: String?, ?error_type: Symbol?) -> void
Calls superclass method
Riffer::Messages::Base::new
Public Instance Methods
Source
# File lib/riffer/messages/tool.rb, line 40 def error? !@error.nil? end
Returns true if the tool execution resulted in an error.
: () -> bool
Source
# File lib/riffer/messages/tool.rb, line 52 def to_h hash = {role: role, content: content, tool_call_id: tool_call_id, name: name} if error? hash[:error] = error hash[:error_type] = error_type end hash end
Converts the message to a hash.
: () -> Hash[Symbol, untyped]