Class: Legion::Extensions::Llm::Mlx::Provider

Inherits:
LexLLM::Provider
  • Object
show all
Includes:
LexLLM::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 Method Summary collapse

Instance Method Summary collapse

Class Method Details

.capabilitiesObject



18
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 18

def capabilities = Capabilities

.configuration_optionsObject



16
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 16

def configuration_options = %i[mlx_api_base mlx_api_key]

.configuration_requirementsObject



17
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 17

def configuration_requirements = []

.local?Boolean

Returns:

  • (Boolean)


15
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 15

def local? = true

.slugObject



14
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 14

def slug = 'mlx'

Instance Method Details

#api_baseObject



36
37
38
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 36

def api_base
  config.mlx_api_base || 'http://localhost:8000'
end

#headersObject



40
41
42
43
44
45
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 40

def headers
  token = config.mlx_api_key
  return {} if token.nil? || token.to_s.empty?

  { 'Authorization' => "Bearer #{token}" }
end

#healthObject



49
50
51
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 49

def health
  connection.get(health_url).body
end

#health_urlObject



47
# File 'lib/legion/extensions/llm/mlx/provider.rb', line 47

def health_url = '/health'