Class: Legion::Extensions::Llm::Mlx::Provider
- Inherits:
-
Provider
- Object
- Provider
- Legion::Extensions::Llm::Mlx::Provider
- Includes:
- Provider::OpenAICompatible
- Defined in:
- lib/legion/extensions/llm/mlx/provider.rb
Overview
MLX provider implementation for local OpenAI-compatible servers.
Defined Under Namespace
Modules: Capabilities
Class Attribute Summary collapse
Class Method Summary collapse
- .capabilities ⇒ Object
- .configuration_options ⇒ Object
- .configuration_requirements ⇒ Object
- .local? ⇒ Boolean
- .slug ⇒ Object
Instance Method Summary collapse
- #api_base ⇒ Object
- #headers ⇒ Object
- #health ⇒ Object
- #health_url ⇒ Object
- #list_models ⇒ Object
- #readiness(live: false) ⇒ Object
Class Attribute Details
.registry_publisher ⇒ Object
22 23 24 |
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 22 def registry_publisher @registry_publisher ||= RegistryPublisher.new end |
Class Method Details
.capabilities ⇒ Object
20 |
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 20 def capabilities = Capabilities |
.configuration_options ⇒ Object
18 |
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 18 def = %i[mlx_api_base mlx_api_key] |
.configuration_requirements ⇒ Object
19 |
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 19 def configuration_requirements = [] |
.local? ⇒ Boolean
17 |
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 17 def local? = true |
.slug ⇒ Object
16 |
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 16 def slug = 'mlx' |
Instance Method Details
#api_base ⇒ Object
51 52 53 |
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 51 def api_base config.mlx_api_base || 'http://localhost:8000' end |
#headers ⇒ Object
55 56 57 58 59 60 |
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 55 def headers token = config.mlx_api_key return {} if token.nil? || token.to_s.empty? { 'Authorization' => "Bearer #{token}" } end |
#health ⇒ Object
64 65 66 |
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 64 def health connection.get(health_url).body end |
#health_url ⇒ Object
62 |
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 62 def health_url = '/health' |
#list_models ⇒ Object
74 75 76 77 78 |
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 74 def list_models super.tap do |models| self.class.registry_publisher.publish_models_async(models, readiness: readiness(live: false)) end end |
#readiness(live: false) ⇒ Object
68 69 70 71 72 |
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 68 def readiness(live: false) super.tap do || self.class.registry_publisher.publish_readiness_async() if live end end |