Class: Ollama::Options
- Inherits:
-
Object
- Object
- Ollama::Options
- Defined in:
- lib/ollama/options.rb
Overview
Options class for model parameters with basic type checking
Provides type-safe access to Ollama model runtime options. These are passed under the ‘options:` key in API requests.
Example:
options = Ollama::Options.new(temperature: 0.7, top_p: 0.95, num_predict: 256)
client.chat(messages: [...], options: options.to_h)
client.generate(prompt: "...", options: options.to_h)
Constant Summary collapse
- VALID_KEYS =
%i[ temperature top_p top_k num_ctx repeat_penalty seed num_predict stop tfs_z mirostat mirostat_tau mirostat_eta num_gpu num_thread num_keep typical_p presence_penalty frequency_penalty ].freeze
Instance Attribute Summary collapse
-
#frequency_penalty ⇒ Object
Returns the value of attribute frequency_penalty.
-
#mirostat ⇒ Object
Returns the value of attribute mirostat.
-
#mirostat_eta ⇒ Object
Returns the value of attribute mirostat_eta.
-
#mirostat_tau ⇒ Object
Returns the value of attribute mirostat_tau.
-
#num_ctx ⇒ Object
Returns the value of attribute num_ctx.
-
#num_gpu ⇒ Object
Returns the value of attribute num_gpu.
-
#num_keep ⇒ Object
Returns the value of attribute num_keep.
-
#num_predict ⇒ Object
Returns the value of attribute num_predict.
-
#num_thread ⇒ Object
Returns the value of attribute num_thread.
-
#presence_penalty ⇒ Object
Returns the value of attribute presence_penalty.
-
#repeat_penalty ⇒ Object
Returns the value of attribute repeat_penalty.
-
#seed ⇒ Object
Returns the value of attribute seed.
-
#stop ⇒ Object
Returns the value of attribute stop.
-
#temperature ⇒ Object
Returns the value of attribute temperature.
-
#tfs_z ⇒ Object
Returns the value of attribute tfs_z.
-
#top_k ⇒ Object
Returns the value of attribute top_k.
-
#top_p ⇒ Object
Returns the value of attribute top_p.
-
#typical_p ⇒ Object
Returns the value of attribute typical_p.
Instance Method Summary collapse
-
#initialize(**options) ⇒ Options
constructor
A new instance of Options.
-
#to_h ⇒ Object
Convert to hash for API calls.
Constructor Details
#initialize(**options) ⇒ Options
Returns a new instance of Options.
27 28 29 30 31 32 33 34 |
# File 'lib/ollama/options.rb', line 27 def initialize(**) unknown_keys = .keys - VALID_KEYS raise ArgumentError, "Unknown options: #{unknown_keys.join(", ")}" if unknown_keys.any? VALID_KEYS.each do |key| assign_option(key, [key]) end end |
Instance Attribute Details
#frequency_penalty ⇒ Object
Returns the value of attribute frequency_penalty.
22 23 24 |
# File 'lib/ollama/options.rb', line 22 def frequency_penalty @frequency_penalty end |
#mirostat ⇒ Object
Returns the value of attribute mirostat.
22 23 24 |
# File 'lib/ollama/options.rb', line 22 def mirostat @mirostat end |
#mirostat_eta ⇒ Object
Returns the value of attribute mirostat_eta.
22 23 24 |
# File 'lib/ollama/options.rb', line 22 def mirostat_eta @mirostat_eta end |
#mirostat_tau ⇒ Object
Returns the value of attribute mirostat_tau.
22 23 24 |
# File 'lib/ollama/options.rb', line 22 def mirostat_tau @mirostat_tau end |
#num_ctx ⇒ Object
Returns the value of attribute num_ctx.
22 23 24 |
# File 'lib/ollama/options.rb', line 22 def num_ctx @num_ctx end |
#num_gpu ⇒ Object
Returns the value of attribute num_gpu.
22 23 24 |
# File 'lib/ollama/options.rb', line 22 def num_gpu @num_gpu end |
#num_keep ⇒ Object
Returns the value of attribute num_keep.
22 23 24 |
# File 'lib/ollama/options.rb', line 22 def num_keep @num_keep end |
#num_predict ⇒ Object
Returns the value of attribute num_predict.
22 23 24 |
# File 'lib/ollama/options.rb', line 22 def num_predict @num_predict end |
#num_thread ⇒ Object
Returns the value of attribute num_thread.
22 23 24 |
# File 'lib/ollama/options.rb', line 22 def num_thread @num_thread end |
#presence_penalty ⇒ Object
Returns the value of attribute presence_penalty.
22 23 24 |
# File 'lib/ollama/options.rb', line 22 def presence_penalty @presence_penalty end |
#repeat_penalty ⇒ Object
Returns the value of attribute repeat_penalty.
22 23 24 |
# File 'lib/ollama/options.rb', line 22 def repeat_penalty @repeat_penalty end |
#seed ⇒ Object
Returns the value of attribute seed.
22 23 24 |
# File 'lib/ollama/options.rb', line 22 def seed @seed end |
#stop ⇒ Object
Returns the value of attribute stop.
22 23 24 |
# File 'lib/ollama/options.rb', line 22 def stop @stop end |
#temperature ⇒ Object
Returns the value of attribute temperature.
22 23 24 |
# File 'lib/ollama/options.rb', line 22 def temperature @temperature end |
#tfs_z ⇒ Object
Returns the value of attribute tfs_z.
22 23 24 |
# File 'lib/ollama/options.rb', line 22 def tfs_z @tfs_z end |
#top_k ⇒ Object
Returns the value of attribute top_k.
22 23 24 |
# File 'lib/ollama/options.rb', line 22 def top_k @top_k end |
#top_p ⇒ Object
Returns the value of attribute top_p.
22 23 24 |
# File 'lib/ollama/options.rb', line 22 def top_p @top_p end |
#typical_p ⇒ Object
Returns the value of attribute typical_p.
22 23 24 |
# File 'lib/ollama/options.rb', line 22 def typical_p @typical_p end |
Instance Method Details
#to_h ⇒ Object
Convert to hash for API calls
129 130 131 132 133 134 135 136 |
# File 'lib/ollama/options.rb', line 129 def to_h hash = {} VALID_KEYS.each do |key| val = instance_variable_get(:"@#{key}") hash[key] = val unless val.nil? end hash end |