A toolkit for managing and testing LM Studio models with automatic context limit discovery
Project description
LMStrix: The Unofficial Toolkit for Mastering LM Studio
LMStrix is a professional, installable Python toolkit designed to supercharge your interaction with LM Studio. It provides a powerful command-line interface (CLI) and a clean Python API for managing, testing, and running local language models, with a standout feature: the Adaptive Context Optimizer.
For the full documentation, please visit the LMStrix GitHub Pages site.
Key Features
- Automatic Context Optimization: Discover the true context limit of any model with the
optimizecommand. - Full Model Management: Programmatically
listavailable models andscanfor newly downloaded ones. - Flexible Inference Engine: Run inference with a powerful two-phase prompt templating system that separates prompt structure from its content.
- Rich CLI: A beautiful and intuitive command-line interface built with
richandfire. - Modern Python API: An
async-first API designed for high-performance, concurrent applications.
Installation
# Using pip
pip install lmstrix
# Using uv (recommended)
uv pip install lmstrix
For more detailed installation instructions, see the Installation page.
Quick Start
Command-Line Interface (CLI)
# First, scan for available models in LM Studio
lmstrix scan
# List all models with their test status
lmstrix list
# Test the context limit for a specific model
lmstrix test "model-id-here"
# Run inference on a model
lmstrix infer "Your prompt here" --model "model-id" --max-tokens 150
Python API
import asyncio
from lmstrix import LMStrix
async def main():
# Initialize the client
lms = LMStrix()
# Scan for available models
await lms.scan_models()
# List all models
models = await lms.list_models()
print(models)
# Test a specific model's context limits
model_id = models[0].id if models else None
if model_id:
result = await lms.test_model(model_id)
print(result)
# Run inference
if model_id:
response = await lms.infer(
prompt="What is the meaning of life?",
model_id=model_id,
max_tokens=100
)
print(response.content)
if __name__ == "__main__":
asyncio.run(main())
For more detailed usage instructions and examples, see the Usage page and the API Reference.
Development
# Clone the repository
git clone https://github.com/twardoch/lmstrix
cd lmstrix
# Install in development mode with all dependencies
pip install -e ".[dev]"
# Run the test suite
pytest
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lmstrix-1.0.27.tar.gz.
File metadata
- Download URL: lmstrix-1.0.27.tar.gz
- Upload date:
- Size: 44.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc8aac2a5f46a783f8872e03cf2063902bcff102ce6427db14f94efc4a5b3bea
|
|
| MD5 |
8ea3ed73fedeeed6095ae6dc9691d30c
|
|
| BLAKE2b-256 |
3f714427d232b5f40177aa944a538c86e7825693a6536351f6af6ca3a2c06350
|
File details
Details for the file lmstrix-1.0.27-py3-none-any.whl.
File metadata
- Download URL: lmstrix-1.0.27-py3-none-any.whl
- Upload date:
- Size: 31.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74d5bb452f26f595ef1cb10d9a8b118a5c3e8d664e445e1ff4168bc1180cadc9
|
|
| MD5 |
cf21a735940ef06ae12f3dab67ecbc5e
|
|
| BLAKE2b-256 |
25be763b58e8f6c716db7e774fc83b9cd9e2de69c454f78e67d4afa303b81aba
|