Skip to main content

A toolkit for managing and testing LM Studio models with automatic context limit discovery

Project description

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 test command.
  • Full Model Management: Programmatically list available models and scan for 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 rich and fire.
  • 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

Changelog

All notable changes to this project are documented in the CHANGELOG.md file.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lmstrix-1.0.35.tar.gz (45.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lmstrix-1.0.35-py3-none-any.whl (32.8 kB view details)

Uploaded Python 3

File details

Details for the file lmstrix-1.0.35.tar.gz.

File metadata

  • Download URL: lmstrix-1.0.35.tar.gz
  • Upload date:
  • Size: 45.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for lmstrix-1.0.35.tar.gz
Algorithm Hash digest
SHA256 fdddda8762eb0a5830362ae6de874f93c1229da4e006531904f3e9543ab19ee7
MD5 50800bfd4df397635474168918fd6d52
BLAKE2b-256 13d1ef7c29b484b96265a42d829f322802c97ce6b38ff76c3e9ca344498d07ae

See more details on using hashes here.

File details

Details for the file lmstrix-1.0.35-py3-none-any.whl.

File metadata

  • Download URL: lmstrix-1.0.35-py3-none-any.whl
  • Upload date:
  • Size: 32.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for lmstrix-1.0.35-py3-none-any.whl
Algorithm Hash digest
SHA256 499426716e213d0af1a256f2d96e25be039c05a10a04bdf19636bc29c08939a0
MD5 bb6114ed098b0cbed2eddf0c5d9324e3
BLAKE2b-256 6a45f2a5faaf7d28e12b9841678c315cf2e289478842432c13a8a9d90388303e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page