Project

lex-mlx

0.0
The project is in a healthy, maintained state
Connects LegionIO to Apple MLX local LLM server
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 2.0
 Project Readme

lex-mlx

LegionIO extension for Apple MLX local LLM inference server (mlx_lm.server).

Installation

gem 'lex-mlx'

Usage

require 'legion/extensions/mlx'

client = Legion::Extensions::Mlx::Client.new
# or with custom host:
# client = Legion::Extensions::Mlx::Client.new(host: 'http://localhost:8080')

# Chat
result = client.chat(model: 'mlx-community/Llama-3-8B-Instruct-4bit',
                     messages: [{ role: 'user', content: 'Hello!' }])

# Streaming chat
client.chat_stream(model: 'mlx-community/Llama-3-8B-Instruct-4bit',
                   messages: [{ role: 'user', content: 'Hello!' }]) do |event|
  print event[:text] if event[:type] == :delta
end

# Completions
result = client.complete(model: 'mlx-community/Llama-3-8B-Instruct-4bit',
                         prompt: 'Once upon a time')

# Embeddings
result = client.embed(model: 'mlx-community/Llama-3-8B-Instruct-4bit',
                      input: 'Hello world')

# List models
result = client.list_models

License

MIT