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.



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

def initialize(data)
  @data = data
end

Instance Method Details

#argumentsObject



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

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

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

#descriptionObject



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

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

#nameObject



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

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

#to_hObject



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

def to_h
  @data
end