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.
- Robust Semantic Routing: Utilizes dynamic few-shot prompt mapping and a 5-tier fallback parser to reliably map inputs to agents.
- Agentic Tool Use: Optional ReAct loop support. Pass custom tools (like Vector DB search) for the orchestrator to execute autonomously before routing.
- Resource Efficient: Uses a 1.5B parameter model (
Qwen 2.5 1.5B Instruct ONNX), consuming only 1.5 GB to 2.0 GB of RAM and taking 1.1 GB of disk storage. - Highly Configurable: Perfect for multi-agent systems, intent classification, and fallback routing.
Installation
Install directly via pip:
pip install slm_orchestrator
Or install locally for development:
# 1. Create a fresh virtual environment
python3 -m venv .venv
source .venv/bin/activate
# 2. Install the package in editable mode
pip install -e .
Note: Requires onnxruntime-genai, huggingface_hub, and pyyaml.
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
Tool Use Example
from slm_orchestrator import SLMOrchestrator
orchestrator = SLMOrchestrator()
agents = [
{"name": "RAG Agent", "description": "Searches and retrieves information from a knowledge base."},
{"name": "Code Agent", "description": "Writes and executes Python code."},
{"name": "General Agent", "description": "Handles general questions and conversations."}
]
tools = [
{
"name": "get_user_intent",
"description": "Fetches more context about the user's intent from a database.",
"parameters": {"query": "string"}
}
]
def my_tool_executor(tool_name, args):
if tool_name == "get_user_intent":
return f"User intent context: {args.get('query')}"
return "Unknown tool"
selected = orchestrator.route(
agents=agents,
question="Find all Python files that import pandas",
tools=tools,
tool_executor=my_tool_executor
)
print(f"Selected: {selected}")
Configuration API
SLMOrchestrator(
model_path=None, # Explicit path to an ONNX model directory (optional)
cache_dir=None, # Where to download the model
n_ctx=2048, # Context size (default: 2048)
n_threads=4 # CPU threads (default: 4)
)
Routing API
orchestrator.route(
agents: list, # List of agent dicts with 'name' and 'description'
question: str, # User query / question
tools: list = None, # Optional JSON schemas for tool use
tool_executor: callable = None, # Optional callback function to execute tools
max_iterations: int = 5 # Max ReAct tool execution loops
) -> str # Returns the exact name of the selected agent
Agent dict format:
{
"name": "Agent Name", # str — must be unique
"description": "What it does." # str — used for routing decision
}
Environment Variables
All constructor parameters can be overridden via environment variables:
| Variable | Description | Default |
|---|---|---|
SLM_ORCHESTRATOR_CONFIG |
Path to a custom config.yaml file |
— |
SLM_ORCHESTRATOR_CACHE_DIR |
Override model download/cache directory | — |
SLM_ORCHESTRATOR_N_THREADS |
Number of CPU threads | 4 |
SLM_ORCHESTRATOR_N_CTX |
Context window size | 2048 |
License
MIT License.
Metadata
Release files for slm-orchestrator 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| slm_orchestrator-0.1.3.tar.gz | 10.1 kB | Without provenance | Details for slm_orchestrator-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| slm_orchestrator-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for slm_orchestrator-0.1.3-py3-none-any.whl |
Total release size: 19.1 kB
Release files / slm_orchestrator-0.1.3.tar.gz
| Download URL | slm_orchestrator-0.1.3.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e56a41275c7378ef239c6e692ef7f9a3ae623a6098f92d34cfa6584996a4c022
|
|
BLAKE2b-256 checksum How to use checksums |
2fcb035a5cedbe909c82d099996640cf3dd5a26977616f8b615310c2a3e61993
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / slm_orchestrator-0.1.3-py3-none-any.whl
| Download URL | slm_orchestrator-0.1.3-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
239511bd1bd49249695d26d637891e0448abb13e918401a01ee8f77d1b4a4a78
|
|
BLAKE2b-256 checksum How to use checksums |
f77795cacb8bb59f6277daeb922f823de4e679f2a45802bb45b8298445f46b48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for slm-orchestrator 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.