Class: Ollama::Options

Inherits:
Object
  • Object
show all
Extended by:
JSONLoader
Includes:
DTO
Defined in:
lib/ollama/options.rb

Overview

A class that encapsulates configuration options for Ollama models.

This class provides a structured way to define and manage various parameters that can be passed to Ollama models during generation or chat operations. It includes type validation to ensure that option values conform to expected data types, making it easier to work with model configurations programmatically.

Options are explained in the parameters for the modelfile.

Examples:

Creating an Options object with specific settings

options = Ollama::Options.new(
  temperature: 0.7,
  num_ctx: 8192,
  top_p: 0.9
)

Constant Summary collapse

@@types =
{
  numa:              [ false, true ],
  num_ctx:           Integer,
  num_batch:         Integer,
  num_gpu:           Integer,
  main_gpu:          Integer,
  low_vram:          [ false, true ],
  f16_kv:            [ false, true ],
  logits_all:        [ false, true ],
  vocab_only:        [ false, true ],
  use_mmap:          [ false, true ],
  use_mlock:         [ false, true ],
  num_thread:        Integer,
  num_keep:          Integer,
  seed:              Integer,
  num_predict:       Integer,
  top_k:             Integer,
  top_p:             Float,
  min_p:             Float,
  tfs_z:             Float,
  typical_p:         Float,
  repeat_last_n:     Integer,
  temperature:       Float,
  repeat_penalty:    Float,
  presence_penalty:  Float,
  frequency_penalty: Float,
  mirostat:          Integer,
  mirostat_tau:      Float,
  mirostat_eta:      Float,
  penalize_newline:  [ false, true ],
  stop:              Array,
}

Class Method Summary collapse

Methods included from JSONLoader

load_from_json

Methods included from DTO

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

Class Method Details

.[](value) ⇒ self

The [] method creates a new instance of the class using a hash of attributes.

This class method provides a convenient way to instantiate an object by passing a hash containing the desired attribute values. It converts the hash keys to symbols and forwards them as keyword arguments to the constructor.

attributes

Parameters:

  • value (Hash)

    a hash containing the attribute names and their values

Returns:

  • (self)

    a new instance of the class initialized with the provided



97
98
99
# File 'lib/ollama/options.rb', line 97

def self.[](value)
  new(**value.to_h)
end