Module: Legion::Extensions::Llm::Ollama
- Extended by:
- Core, AutoRegistration, Logging::Helper
- Defined in:
- lib/legion/extensions/llm/ollama.rb,
lib/legion/extensions/llm/ollama/version.rb,
lib/legion/extensions/llm/ollama/provider.rb,
lib/legion/extensions/llm/ollama/actors/fleet_worker.rb,
lib/legion/extensions/llm/ollama/runners/fleet_worker.rb
Overview
Ollama provider extension namespace.
Defined Under Namespace
Modules: Actor, Runners Classes: Provider
Constant Summary collapse
- PROVIDER_FAMILY =
:ollama- VERSION =
'0.2.6'
Class Method Summary collapse
- .default_settings ⇒ Object
- .discover_instances ⇒ Object
- .normalize_instance_config(config) ⇒ Object
- .provider_class ⇒ Object
- .registry_publisher ⇒ Object
Class Method Details
.default_settings ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/legion/extensions/llm/ollama.rb', line 18 def self.default_settings ::Legion::Extensions::Llm.provider_settings( family: PROVIDER_FAMILY, instance: { endpoint: 'http://127.0.0.1:11434', default_model: 'qwen3.5:latest', tier: :local, transport: :http, credentials: {}, usage: { inference: true, embedding: true, image: false }, limits: { concurrency: 1 }, fleet: { enabled: false, respond_to_requests: false, capabilities: %i[chat stream_chat embed], lanes: [], concurrency: 1, queue_suffix: nil } } ) end |
.discover_instances ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/legion/extensions/llm/ollama.rb', line 49 def self.discover_instances instances = {} if CredentialSources.socket_open?('127.0.0.1', 11_434, timeout: 0.1) instances[:local] = { base_url: 'http://127.0.0.1:11434', tier: :local, capabilities: %i[completion embedding vision] } end configured = CredentialSources.setting(:extensions, :llm, :ollama, :instances) if configured.is_a?(Hash) configured.each do |name, config| instances[name.to_sym] = normalize_instance_config(config).merge( tier: :direct, capabilities: %i[completion embedding vision] ) end end instances end |
.normalize_instance_config(config) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/legion/extensions/llm/ollama.rb', line 73 def self.normalize_instance_config(config) normalized = config.to_h.transform_keys { |key| key.respond_to?(:to_sym) ? key.to_sym : key } normalized[:base_url] ||= normalized.delete(:ollama_api_base) normalized[:base_url] ||= normalized.delete(:api_base) normalized[:base_url] ||= normalized.delete(:endpoint) normalized.compact end |
.provider_class ⇒ Object
41 42 43 |
# File 'lib/legion/extensions/llm/ollama.rb', line 41 def self.provider_class Provider end |
.registry_publisher ⇒ Object
45 46 47 |
# File 'lib/legion/extensions/llm/ollama.rb', line 45 def self.registry_publisher @registry_publisher ||= Legion::Extensions::Llm::RegistryPublisher.new(provider_family: PROVIDER_FAMILY) end |