Class: Ollama::Tool::Function::Parameters

Inherits:
Object
  • Object
show all
Includes:
DTO
Defined in:
lib/ollama/tool/function/parameters.rb

Overview

A class that represents the parameters specification for a tool function in Ollama API interactions.

This class encapsulates the structure required for defining the parameters that a function tool accepts. It includes the type of parameter object, the properties of each parameter, and which parameters are required.

Examples:

Creating a parameters specification for a tool function

property = Ollama::Tool::Function::Parameters::Property.new(
  type: 'string',
  description: 'The location to get weather for'
)
parameters = Ollama::Tool::Function::Parameters.new(
  type: 'object',
  properties: { location: property },
  required: %w[location]
)

Defined Under Namespace

Classes: Property

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DTO

#==, #as_array, #as_array_of_hashes, #as_hash, #as_json, #empty?, #to_json

Constructor Details

#initialize(type:, properties:, required:) ⇒ Parameters

The initialize method sets up a new Parameters instance with the specified attributes.

Parameters:

  • type (String)

    the type of parameter object

  • properties (Hash)

    the properties of each parameter

  • required (Array<String>)

    the names of required parameters



45
46
47
48
# File 'lib/ollama/tool/function/parameters.rb', line 45

def initialize(type:, properties:, required:)
  @type, @properties, @required =
    type, Hash(properties).transform_values(&:to_hash), Array(required)
end

Instance Attribute Details

#propertiesHash (readonly)

The properties attribute reader returns the properties associated with the object.

Returns:

  • (Hash)

    the properties hash, or nil if not set



30
31
32
# File 'lib/ollama/tool/function/parameters.rb', line 30

def properties
  @properties
end

#requiredArray<String>? (readonly)

The required attribute reader returns the required parameter values associated with the object.

if not set

Returns:

  • (Array<String>, nil)

    an array of required parameter names, or nil



37
38
39
# File 'lib/ollama/tool/function/parameters.rb', line 37

def required
  @required
end

#typeString (readonly)

The type attribute reader returns the type associated with the object.

Returns:

  • (String)

    the type value stored in the instance variable



24
25
26
# File 'lib/ollama/tool/function/parameters.rb', line 24

def type
  @type
end