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 min_p penalize_newline repeat_last_n numa num_batch main_gpu low_vram vocab_only use_mmap use_mlock ].freeze
Instance Attribute Summary collapse
-
#frequency_penalty ⇒ Object
Returns the value of attribute frequency_penalty.
-
#low_vram ⇒ Object
Returns the value of attribute low_vram.
-
#main_gpu ⇒ Object
Returns the value of attribute main_gpu.
-
#min_p ⇒ Object
Returns the value of attribute min_p.
-
#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_batch ⇒ Object
Returns the value of attribute num_batch.
-
#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.
-
#numa ⇒ Object
Returns the value of attribute numa.
-
#penalize_newline ⇒ Object
Returns the value of attribute penalize_newline.
-
#presence_penalty ⇒ Object
Returns the value of attribute presence_penalty.
-
#repeat_last_n ⇒ Object
Returns the value of attribute repeat_last_n.
-
#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.
-
#use_mlock ⇒ Object
Returns the value of attribute use_mlock.
-
#use_mmap ⇒ Object
Returns the value of attribute use_mmap.
-
#vocab_only ⇒ Object
Returns the value of attribute vocab_only.
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.
31 32 33 34 35 36 37 38 |
# File 'lib/ollama/options.rb', line 31 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.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def frequency_penalty @frequency_penalty end |
#low_vram ⇒ Object
Returns the value of attribute low_vram.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def low_vram @low_vram end |
#main_gpu ⇒ Object
Returns the value of attribute main_gpu.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def main_gpu @main_gpu end |
#min_p ⇒ Object
Returns the value of attribute min_p.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def min_p @min_p end |
#mirostat ⇒ Object
Returns the value of attribute mirostat.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def mirostat @mirostat end |
#mirostat_eta ⇒ Object
Returns the value of attribute mirostat_eta.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def mirostat_eta @mirostat_eta end |
#mirostat_tau ⇒ Object
Returns the value of attribute mirostat_tau.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def mirostat_tau @mirostat_tau end |
#num_batch ⇒ Object
Returns the value of attribute num_batch.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def num_batch @num_batch end |
#num_ctx ⇒ Object
Returns the value of attribute num_ctx.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def num_ctx @num_ctx end |
#num_gpu ⇒ Object
Returns the value of attribute num_gpu.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def num_gpu @num_gpu end |
#num_keep ⇒ Object
Returns the value of attribute num_keep.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def num_keep @num_keep end |
#num_predict ⇒ Object
Returns the value of attribute num_predict.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def num_predict @num_predict end |
#num_thread ⇒ Object
Returns the value of attribute num_thread.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def num_thread @num_thread end |
#numa ⇒ Object
Returns the value of attribute numa.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def numa @numa end |
#penalize_newline ⇒ Object
Returns the value of attribute penalize_newline.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def penalize_newline @penalize_newline end |
#presence_penalty ⇒ Object
Returns the value of attribute presence_penalty.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def presence_penalty @presence_penalty end |
#repeat_last_n ⇒ Object
Returns the value of attribute repeat_last_n.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def repeat_last_n @repeat_last_n end |
#repeat_penalty ⇒ Object
Returns the value of attribute repeat_penalty.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def repeat_penalty @repeat_penalty end |
#seed ⇒ Object
Returns the value of attribute seed.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def seed @seed end |
#stop ⇒ Object
Returns the value of attribute stop.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def stop @stop end |
#temperature ⇒ Object
Returns the value of attribute temperature.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def temperature @temperature end |
#tfs_z ⇒ Object
Returns the value of attribute tfs_z.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def tfs_z @tfs_z end |
#top_k ⇒ Object
Returns the value of attribute top_k.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def top_k @top_k end |
#top_p ⇒ Object
Returns the value of attribute top_p.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def top_p @top_p end |
#typical_p ⇒ Object
Returns the value of attribute typical_p.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def typical_p @typical_p end |
#use_mlock ⇒ Object
Returns the value of attribute use_mlock.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def use_mlock @use_mlock end |
#use_mmap ⇒ Object
Returns the value of attribute use_mmap.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def use_mmap @use_mmap end |
#vocab_only ⇒ Object
Returns the value of attribute vocab_only.
24 25 26 |
# File 'lib/ollama/options.rb', line 24 def vocab_only @vocab_only end |
Instance Method Details
#to_h ⇒ Object
Convert to hash for API calls
183 184 185 186 187 188 189 190 |
# File 'lib/ollama/options.rb', line 183 def to_h hash = {} VALID_KEYS.each do |key| val = instance_variable_get(:"@#{key}") hash[key] = val unless val.nil? end hash end |