Module: OllamaChat::ModelHandling
- Included in:
- Chat
- Defined in:
- lib/ollama_chat/model_handling.rb
Instance Method Summary collapse
- #model_present?(model) ⇒ Boolean
- #pull_model_from_remote(model) ⇒ Object
- #pull_model_unless_present(model, options) ⇒ Object
Instance Method Details
#model_present?(model) ⇒ Boolean
2 3 4 5 6 |
# File 'lib/ollama_chat/model_handling.rb', line 2 def model_present?(model) ollama.show(model:) { return _1.system.to_s } rescue Ollama::Errors::NotFoundError false end |
#pull_model_from_remote(model) ⇒ Object
8 9 10 11 |
# File 'lib/ollama_chat/model_handling.rb', line 8 def pull_model_from_remote(model) STDOUT.puts "Model #{bold{model}} not found locally, attempting to pull it from remote now…" ollama.pull(model:) end |
#pull_model_unless_present(model, options) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ollama_chat/model_handling.rb', line 13 def pull_model_unless_present(model, ) if system = model_present?(model) return system.full? else pull_model_from_remote(model) if system = model_present?(model) return system.full? else STDOUT.puts "Model #{bold{model}} not found remotely. => Exiting." exit 1 end end rescue Ollama::Errors::Error => e warn "Caught #{e.class} while pulling model: #{e} => Exiting." exit 1 end |