Class: Ollama::Response::Message::ToolCall

Inherits:
Object
  • Object
show all
Defined in:
lib/ollama/response.rb

Overview

ToolCall wrapper for accessing tool call fields

Defined Under Namespace

Classes: Function

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ ToolCall

Returns a new instance of ToolCall.



166
167
168
# File 'lib/ollama/response.rb', line 166

def initialize(data)
  @data = data
end

Instance Method Details

#argumentsObject



185
186
187
# File 'lib/ollama/response.rb', line 185

def arguments
  function&.arguments
end

#functionObject



174
175
176
177
178
179
# File 'lib/ollama/response.rb', line 174

def function
  func = @data["function"] || @data[:function]
  return nil unless func

  Function.new(func)
end

#idObject



170
171
172
# File 'lib/ollama/response.rb', line 170

def id
  @data["id"] || @data[:id] || @data["tool_call_id"] || @data[:tool_call_id]
end

#nameObject



181
182
183
# File 'lib/ollama/response.rb', line 181

def name
  function&.name
end

#to_hObject



189
190
191
# File 'lib/ollama/response.rb', line 189

def to_h
  @data
end