Class: OpenRouter::ResponsesToolCall

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from ToolCallBase

#arguments, #execute

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_stringObject (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_idObject (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

#idObject (readonly)

Returns the value of attribute id.



11
12
13
# File 'lib/open_router/responses_tool_call.rb', line 11

def id
  @id
end

#nameObject (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_nameObject

Alias for consistency with ToolCall



24
25
26
# File 'lib/open_router/responses_tool_call.rb', line 24

def function_name
  @name
end

#to_hObject



49
50
51
# File 'lib/open_router/responses_tool_call.rb', line 49

def to_h
  to_input_item
end

#to_input_itemObject

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

#typeObject

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