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
– : (String, tool_call_id: String, name: String, ?error: String?, ?error_type: Symbol?) -> void.
-
#role ⇒ Object
– : () -> Symbol.
-
#to_h ⇒ Object
Converts the message to a hash.
Constructor Details
#initialize(content, tool_call_id:, name:, error: nil, error_type: nil) ⇒ Tool
– : (String, tool_call_id: String, name: String, ?error: String?, ?error_type: Symbol?) -> void
30 31 32 33 34 35 36 |
# File 'lib/riffer/messages/tool.rb', line 30 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.
23 24 25 |
# File 'lib/riffer/messages/tool.rb', line 23 def error @error end |
#error_type ⇒ Object (readonly)
The type of error (:unknown_tool, :validation_error, :execution_error, :timeout_error).
26 27 28 |
# File 'lib/riffer/messages/tool.rb', line 26 def error_type @error_type end |
#name ⇒ Object (readonly)
The name of the tool that was called.
20 21 22 |
# File 'lib/riffer/messages/tool.rb', line 20 def name @name end |
#tool_call_id ⇒ Object (readonly)
The ID of the tool call this result responds to.
17 18 19 |
# File 'lib/riffer/messages/tool.rb', line 17 def tool_call_id @tool_call_id end |
Instance Method Details
#error? ⇒ Boolean
Returns true if the tool execution resulted in an error.
– : () -> bool
42 43 44 |
# File 'lib/riffer/messages/tool.rb', line 42 def error? !@error.nil? end |
#role ⇒ Object
– : () -> Symbol
48 49 50 |
# File 'lib/riffer/messages/tool.rb', line 48 def role :tool end |
#to_h ⇒ Object
Converts the message to a hash.
– : () -> Hash[Symbol, untyped]
56 57 58 59 60 61 62 63 |
# File 'lib/riffer/messages/tool.rb', line 56 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 |