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

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

Overview

Function wrapper for accessing function fields

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Function

Returns a new instance of Function.



195
196
197
# File 'lib/ollama/response.rb', line 195

def initialize(data)
  @data = data
end

Instance Method Details

#argumentsObject



207
208
209
210
211
212
213
214
# File 'lib/ollama/response.rb', line 207

def arguments
  args = @data["arguments"] || @data[:arguments]
  return {} unless args

  args.is_a?(String) ? JSON.parse(args) : args
rescue JSON::ParserError
  {}
end

#descriptionObject



203
204
205
# File 'lib/ollama/response.rb', line 203

def description
  @data["description"] || @data[:description]
end

#nameObject



199
200
201
# File 'lib/ollama/response.rb', line 199

def name
  @data["name"] || @data[:name]
end

#to_hObject



216
217
218
# File 'lib/ollama/response.rb', line 216

def to_h
  @data
end