Class: Riffer::Messages::Tool
Overview
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
The error message if the tool execution failed.
-
#error_type ⇒ Object
readonly
The type of error (:unknown_tool, :validation_error, :execution_error, :timeout_error).
-
#name ⇒ Object
readonly
The name of the tool that was called.
-
#tool_call_id ⇒ Object
readonly
The ID of the tool call this result responds to.
Attributes inherited from Base
Instance Method Summary collapse
-
#error? ⇒ Boolean
Returns true if the tool execution resulted in an error.
-
#initialize(content, tool_call_id:, name:, error: nil, error_type: nil) ⇒ Tool
constructor
Creates a new tool result message.
-
#role ⇒ Object
Returns :tool.
-
#to_h ⇒ Object
Converts the message to a hash.
Constructor Details
#initialize(content, tool_call_id:, name:, error: nil, error_type: nil) ⇒ Tool
Creates a new tool result message.
- content
-
String - the tool execution result
- tool_call_id
-
String - the ID of the tool call
- name
-
String - the tool name
- error
-
String or nil - optional error message
- error_type
-
Symbol or nil - optional error type
42 43 44 45 46 47 48 |
# File 'lib/riffer/messages/tool.rb', line 42 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 |
Instance Attribute Details
#error ⇒ Object (readonly)
The error message if the tool execution failed.
Returns String or nil.
28 29 30 |
# File 'lib/riffer/messages/tool.rb', line 28 def error @error end |
#error_type ⇒ Object (readonly)
The type of error (:unknown_tool, :validation_error, :execution_error, :timeout_error).
Returns Symbol or nil.
33 34 35 |
# File 'lib/riffer/messages/tool.rb', line 33 def error_type @error_type end |
#name ⇒ Object (readonly)
The name of the tool that was called.
Returns String.
23 24 25 |
# File 'lib/riffer/messages/tool.rb', line 23 def name @name end |
#tool_call_id ⇒ Object (readonly)
The ID of the tool call this result responds to.
Returns String.
18 19 20 |
# File 'lib/riffer/messages/tool.rb', line 18 def tool_call_id @tool_call_id end |
Instance Method Details
#error? ⇒ Boolean
Returns true if the tool execution resulted in an error.
Returns Boolean.
53 54 55 |
# File 'lib/riffer/messages/tool.rb', line 53 def error? !@error.nil? end |
#role ⇒ Object
Returns :tool.
58 59 60 |
# File 'lib/riffer/messages/tool.rb', line 58 def role :tool end |
#to_h ⇒ Object
Converts the message to a hash.
Returns Hash with message data including error info if present.
65 66 67 68 69 70 71 72 |
# File 'lib/riffer/messages/tool.rb', line 65 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 |