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_hash, #to_json

Constructor Details

#initialize(type:, description:, enum: nil, properties: nil, items: 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

  • properties (Hash, nil) (defaults to: nil)

    optional nested properties for 'object' types

  • items (Object, nil) (defaults to: nil)

    optional schema definition for 'array' type elements



60
61
62
# File 'lib/ollama/tool/function/parameters/property.rb', line 60

def initialize(type:, description:, enum: nil, properties: nil, items: nil)
  @type, @description, @enum, @properties, @items = type, description, Array(enum), properties, items
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.

Returns:

  • (Array<String>, nil)

    an array of valid string values that the property can take, or nil if not set



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

def enum
  @enum
end

#itemsObject? (readonly)

The items attribute reader returns the definition of elements for array types.

Returns:

  • (Object, nil)

    the schema definition for array items, or nil if not set



50
51
52
# File 'lib/ollama/tool/function/parameters/property.rb', line 50

def items
  @items
end

#propertiesHash? (readonly)

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

Returns:

  • (Hash, nil)

    a map of property names to their corresponding Property objects, or nil if not set



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

def properties
  @properties
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