Class: Brute::Providers::Ollama
- Inherits:
-
LLM::Ollama
- Object
- LLM::Ollama
- Brute::Providers::Ollama
- Defined in:
- lib/brute/providers/ollama.rb
Overview
Brute-level wrapper around LLM::Ollama for local model inference.
Adds environment-variable-based configuration so that all Brute examples and the CLI work out of the box with a local Ollama instance:
OLLAMA_HOST — base URL (default: http://localhost:11434)
OLLAMA_MODEL — default model (default: llm.rb's default, currently qwen3:latest)
Class Method Summary collapse
-
.parse_host(url) ⇒ Hash
Parse OLLAMA_HOST into host, port, and ssl components.
Instance Method Summary collapse
-
#default_model ⇒ String
Returns the default model, preferring OLLAMA_MODEL env var.
-
#initialize(key: "none") ⇒ Ollama
constructor
A new instance of Ollama.
- #name ⇒ Symbol
Constructor Details
#initialize(key: "none") ⇒ Ollama
Returns a new instance of Ollama.
59 60 61 62 |
# File 'lib/brute/providers/ollama.rb', line 59 def initialize(key: "none", **) config = self.class.parse_host(ENV["OLLAMA_HOST"]) super(key: key, host: config[:host], port: config[:port], ssl: config[:ssl], **) end |
Class Method Details
.parse_host(url) ⇒ Hash
Parse OLLAMA_HOST into host, port, and ssl components. Accepts formats like:
http://localhost:11434
https://ollama.example.com
192.168.1.50:11434
localhost
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/brute/providers/ollama.rb', line 43 def self.parse_host(url) return { host: LLM::Ollama::HOST, port: 11434, ssl: false } if url.nil? || url.empty? # Prepend scheme if missing so URI.parse works url = "http://#{url}" unless url.match?(%r{\A\w+://}) uri = URI.parse(url) { host: uri.host || LLM::Ollama::HOST, port: uri.port || 11434, ssl: uri.scheme == "https", } end |
Instance Method Details
#default_model ⇒ String
Returns the default model, preferring OLLAMA_MODEL env var.
73 74 75 |
# File 'lib/brute/providers/ollama.rb', line 73 def default_model ENV["OLLAMA_MODEL"] || super end |
#name ⇒ Symbol
66 67 68 |
# File 'lib/brute/providers/ollama.rb', line 66 def name :ollama end |