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.



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

def initialize(data)
  @data = data
end

Instance Method Details

#argumentsObject



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

def arguments
  function&.arguments
end

#functionObject



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

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

  Function.new(func)
end

#idObject



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

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

#nameObject



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

def name
  function&.name
end

#to_hObject



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

def to_h
  @data
end