s1d1-router / tutorials /01-http-and-curl.md
scombat's picture
LiteLLM Auto Router classifier server (serve_litellm.py), launchers, tutorial update
4ff8679 verified
|
Raw History Blame Contribute Delete
1.14 kB
# The router as a local HTTP service (works with anything)
```bash
pip install "transformers>=5" torch pyyaml
python integrations/serve.py --model scombat/s1d1-router --policy integrations/policy.example.yaml --port 8787
```
```bash
curl -s localhost:8787/route -H 'content-type: application/json' \
-d '{"prompt": "Fix the failing test in utils/", "profile": "generic", "session_id": "demo"}'
```
Response: `route` (complexity_score, complexity_tier, task, needs_tools, needs_tools_probability, prompt_tokens) and
`decision` (tier, model, effort, rule, reason). Profiles are in the policy file (`claude_code`, `codex`, `generic`).
Status: run with the real model on a Mac (PyTorch on `mps`): the server starts, answers and logs, 10 to 19 ms per
request after the first one. Without installing anything, `integrations/serve_variant.sh MODEL` starts it with the
packages the variant needs (requires [uv](https://docs.astral.sh/uv/); MODEL is a Hub repo id or a local folder).
Python, without the server:
```python
from s1d1_router import Router
print(Router("scombat/s1d1-router").route(["Summarise this contract in five bullets."]))
```