Skip to main content

SLM Orchestrator 🧠🚀

slm_orchestrator is a lightweight, local semantic routing orchestrator powered entirely by a Small Language Model (SLM) running on CPU. It enables you to route user prompts dynamically to a custom list of agents with strict structured output constraints.


Key Features

  • Local & Private: Runs completely on CPU / RAM. Zero API keys, zero network latency, and complete data privacy.
  • Dynamic Grammar Routing: Automatically constructs a GBNF (GGML Backus-Naur Form) grammar on-the-fly to constrain the model's output to exactly one of the agent names you provide.
  • Transparent Model Download: Scans your local directory or automatically downloads and caches the required 1B parameter instruct model on first execution.
  • Highly Configurable: Perfect for multi-agent systems, intent classification, and fallback routing.

Installation

Install directly via pip:

pip install slm-orchestrator

Note: Requires llama-cpp-python and huggingface_hub.


Quick Start

from slm_orchestrator import SLMOrchestrator

# Initialize the orchestrator (auto-downloads/loads the model)
orchestrator = SLMOrchestrator()

# Define your list of agents
agents = [
    {
        "name": "Billing Support", 
        "description": "Handles payments, invoices, refunds, and subscriptions."
    },
    {
        "name": "Technical Support", 
        "description": "Handles software installation, bug reports, and system crashes."
    },
    {
        "name": "General Chat", 
        "description": "Handles greetings, casual conversations, and general questions."
    }
]

# Route query
selected_agent = orchestrator.route(
    agents=agents,
    question="I need help with my monthly invoice payment"
)

print(f"Selected: {selected_agent}") 
# Output: Billing Support

Configuration API

SLMOrchestrator(
    model_path=None,   # Explicit path to a .gguf file (optional)
    cache_dir=None,    # Where to download the model (defaults to ~/.cache/slm_orchestrator)
    n_ctx=1024,        # Context size (default: 1024)
    n_threads=4        # CPU threads to run model generation (default: 4)
)

License

MIT License.

Download files

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

Source Distribution

slm_orchestrator-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

slm_orchestrator-0.1.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file slm_orchestrator-0.1.0.tar.gz.

File metadata

  • Download URL: slm_orchestrator-0.1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for slm_orchestrator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a8a37cd34a368a0ff5df0d3235301a1adb869a52fcc130544390178b0671e32d
MD5 65c724d3ecca49a1812653cbfbe9b18b
BLAKE2b-256 280c7394192e1f94535bb76490b49fcff8065058c879294cc3c9a289601ad179

See more details on using hashes here.

File details

Details for the file slm_orchestrator-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for slm_orchestrator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2594c3ec2ff35f8e90bb7945b27ca4c078cfaf0421b8526bba54e3aab0821315
MD5 742d119bf012bb77f85e09d9f766f375
BLAKE2b-256 d905a4614a74c9677314964edf13957e69eb96144bbf32f26ee676b4588aae06

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 Sentry Error logging StatusPage Status page