Class: OpenRouter::ResponsesToolCall
- Inherits:
-
Object
- Object
- OpenRouter::ResponsesToolCall
- Includes:
- ToolCallBase
- Defined in:
- lib/open_router/responses_tool_call.rb
Overview
Represents a tool/function call from the Responses API. Format: type=“function_call” with name/arguments at top level (not nested)
Instance Attribute Summary collapse
-
#arguments_string ⇒ Object
readonly
Returns the value of attribute arguments_string.
-
#call_id ⇒ Object
readonly
Returns the value of attribute call_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Get the function name.
Instance Method Summary collapse
-
#build_result(result, error = nil) ⇒ Object
Build result for execute method (required by ToolCallBase).
-
#function_name ⇒ Object
Alias for consistency with ToolCall.
-
#initialize(tool_call_data) ⇒ ResponsesToolCall
constructor
A new instance of ResponsesToolCall.
- #to_h ⇒ Object
-
#to_input_item ⇒ Object
Convert to the function_call format for conversation continuation.
- #to_json(*args) ⇒ Object
-
#type ⇒ Object
Type is always “function” for tool calls (for consistency with ToolCall).
Methods included from ToolCallBase
Constructor Details
#initialize(tool_call_data) ⇒ ResponsesToolCall
Returns a new instance of ResponsesToolCall.
13 14 15 16 17 18 |
# File 'lib/open_router/responses_tool_call.rb', line 13 def initialize(tool_call_data) @id = tool_call_data["id"] @call_id = tool_call_data["call_id"] @name = tool_call_data["name"] @arguments_string = tool_call_data["arguments"] || "{}" end |
Instance Attribute Details
#arguments_string ⇒ Object (readonly)
Returns the value of attribute arguments_string.
11 12 13 |
# File 'lib/open_router/responses_tool_call.rb', line 11 def arguments_string @arguments_string end |
#call_id ⇒ Object (readonly)
Returns the value of attribute call_id.
11 12 13 |
# File 'lib/open_router/responses_tool_call.rb', line 11 def call_id @call_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/open_router/responses_tool_call.rb', line 11 def id @id end |
#name ⇒ Object (readonly)
Get the function name
21 22 23 |
# File 'lib/open_router/responses_tool_call.rb', line 21 def name @name end |
Instance Method Details
#build_result(result, error = nil) ⇒ Object
Build result for execute method (required by ToolCallBase)
34 35 36 |
# File 'lib/open_router/responses_tool_call.rb', line 34 def build_result(result, error = nil) ResponsesToolResult.new(self, result, error) end |
#function_name ⇒ Object
Alias for consistency with ToolCall
24 25 26 |
# File 'lib/open_router/responses_tool_call.rb', line 24 def function_name @name end |
#to_h ⇒ Object
49 50 51 |
# File 'lib/open_router/responses_tool_call.rb', line 49 def to_h to_input_item end |
#to_input_item ⇒ Object
Convert to the function_call format for conversation continuation
39 40 41 42 43 44 45 46 47 |
# File 'lib/open_router/responses_tool_call.rb', line 39 def to_input_item { "type" => "function_call", "id" => @id, "call_id" => @call_id, "name" => @name, "arguments" => @arguments_string } end |
#to_json(*args) ⇒ Object
53 54 55 |
# File 'lib/open_router/responses_tool_call.rb', line 53 def to_json(*args) to_h.to_json(*args) end |
#type ⇒ Object
Type is always “function” for tool calls (for consistency with ToolCall)
29 30 31 |
# File 'lib/open_router/responses_tool_call.rb', line 29 def type "function" end |