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

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

Overview

A class that represents a single property within the parameters specification for a tool function.

This class encapsulates the definition of an individual parameter, including its data type, descriptive text, and optional enumeration values that define valid inputs.

Examples:

Creating a property with type and description

property = Ollama::Tool::Function::Parameters::Property.new(
  type: 'string',
  description: 'The location to get weather for'
)

Creating a property with an enumeration of valid values

property = Ollama::Tool::Function::Parameters::Property.new(
  type: 'string',
  description: 'Temperature unit',
  enum: %w[celsius fahrenheit]
)

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:, description:, enum: nil) ⇒ Property

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

Parameters:

  • type (String)

    the data type of the property

  • description (String)

    a detailed explanation of what the property represents

  • enum (Array<String>, nil) (defaults to: nil)

    an optional array of valid values that the property can take



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

def initialize(type:, description:, enum: nil)
  @type, @description, @enum = type, description, Array(enum)
end

Instance Attribute Details

#descriptionString (readonly)

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

Returns:

  • (String)

    the description value stored in the instance variable



32
33
34
# File 'lib/ollama/tool/function/parameters/property.rb', line 32

def description
  @description
end

#enumArray<String>? (readonly)

The enum attribute reader returns the enumeration values associated with the object.

property can take, or nil if not set

Returns:

  • (Array<String>, nil)

    an array of valid string values that the



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

def enum
  @enum
end

#typeString (readonly)

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

Returns:

  • (String)

    the type value stored in the instance variable



26
27
28
# File 'lib/ollama/tool/function/parameters/property.rb', line 26

def type
  @type
end