Class: OpenRouter::ToolResult
- Inherits:
-
Object
- Object
- OpenRouter::ToolResult
- Defined in:
- lib/open_router/tool_call.rb
Overview
Represents the result of executing a tool call
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#tool_call ⇒ Object
readonly
Returns the value of attribute tool_call.
Class Method Summary collapse
-
.failure(tool_call, error) ⇒ Object
Create a failed result.
-
.success(tool_call, result) ⇒ Object
Create a successful result.
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(tool_call, result = nil, error = nil) ⇒ ToolResult
constructor
A new instance of ToolResult.
- #success? ⇒ Boolean
-
#to_message ⇒ Object
Convert to message format for conversation continuation.
Constructor Details
#initialize(tool_call, result = nil, error = nil) ⇒ ToolResult
Returns a new instance of ToolResult.
151 152 153 154 155 |
# File 'lib/open_router/tool_call.rb', line 151 def initialize(tool_call, result = nil, error = nil) @tool_call = tool_call @result = result @error = error end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
149 150 151 |
# File 'lib/open_router/tool_call.rb', line 149 def error @error end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
149 150 151 |
# File 'lib/open_router/tool_call.rb', line 149 def result @result end |
#tool_call ⇒ Object (readonly)
Returns the value of attribute tool_call.
149 150 151 |
# File 'lib/open_router/tool_call.rb', line 149 def tool_call @tool_call end |
Class Method Details
.failure(tool_call, error) ⇒ Object
Create a failed result
171 172 173 |
# File 'lib/open_router/tool_call.rb', line 171 def self.failure(tool_call, error) new(tool_call, nil, error) end |
.success(tool_call, result) ⇒ Object
Create a successful result
176 177 178 |
# File 'lib/open_router/tool_call.rb', line 176 def self.success(tool_call, result) new(tool_call, result, nil) end |
Instance Method Details
#failure? ⇒ Boolean
161 162 163 |
# File 'lib/open_router/tool_call.rb', line 161 def failure? !success? end |
#success? ⇒ Boolean
157 158 159 |
# File 'lib/open_router/tool_call.rb', line 157 def success? @error.nil? end |
#to_message ⇒ Object
Convert to message format for conversation continuation
166 167 168 |
# File 'lib/open_router/tool_call.rb', line 166 def @tool_call.(@error || @result) end |