Class: OpenRouter::ResponsesToolResult
- Inherits:
-
Object
- Object
- OpenRouter::ResponsesToolResult
- Includes:
- ToolResultBase
- Defined in:
- lib/open_router/responses_tool_call.rb
Overview
Represents the result of executing a Responses API tool call
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#output_id ⇒ Object
readonly
Returns the value of attribute output_id.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#tool_call ⇒ Object
readonly
Returns the value of attribute tool_call.
Instance Method Summary collapse
-
#initialize(tool_call, result = nil, error = nil) ⇒ ResponsesToolResult
constructor
A new instance of ResponsesToolResult.
- #to_h ⇒ Object
-
#to_input_item ⇒ Hash
Convert to function_call_output format for conversation continuation.
- #to_json(*args) ⇒ Object
Methods included from ToolResultBase
#failure?, included, #success?
Constructor Details
#initialize(tool_call, result = nil, error = nil) ⇒ ResponsesToolResult
Returns a new instance of ResponsesToolResult.
64 65 66 67 68 69 |
# File 'lib/open_router/responses_tool_call.rb', line 64 def initialize(tool_call, result = nil, error = nil) @tool_call = tool_call @result = result @error = error @output_id = "fc_output_#{SecureRandom.hex(8)}" end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
62 63 64 |
# File 'lib/open_router/responses_tool_call.rb', line 62 def error @error end |
#output_id ⇒ Object (readonly)
Returns the value of attribute output_id.
62 63 64 |
# File 'lib/open_router/responses_tool_call.rb', line 62 def output_id @output_id end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
62 63 64 |
# File 'lib/open_router/responses_tool_call.rb', line 62 def result @result end |
#tool_call ⇒ Object (readonly)
Returns the value of attribute tool_call.
62 63 64 |
# File 'lib/open_router/responses_tool_call.rb', line 62 def tool_call @tool_call end |
Instance Method Details
#to_h ⇒ Object
91 92 93 |
# File 'lib/open_router/responses_tool_call.rb', line 91 def to_h to_input_item end |
#to_input_item ⇒ Hash
Convert to function_call_output format for conversation continuation
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/open_router/responses_tool_call.rb', line 74 def to_input_item output_content = if @error { error: @error }.to_json elsif @result.is_a?(String) @result else @result.to_json end { "type" => "function_call_output", "id" => @output_id, "call_id" => @tool_call.call_id, "output" => output_content } end |
#to_json(*args) ⇒ Object
95 96 97 |
# File 'lib/open_router/responses_tool_call.rb', line 95 def to_json(*args) to_h.to_json(*args) end |