lemonade-router-builder
Turns a natural-language description of routing intent into a valid Lemonade `collection.router` policy JSON. The skill generates and validates the JSON only - it does not register it or call the live server. Use when the user wants to route requests between models ("route sensitive queries to X and everything else to Y"), generate a router/hybrid-router config or policy, author a collection.router JSON, split traffic between a small local model and a big/cloud model, add PII/jailbreak/topic classifiers to routing, or mentions Lemonade Router, routing rules, routing.router, candidates/default_model, keywords_any, semantic_similarity, or LLM-as-router. Fills every field the user did not specify with safe defaults.
amd · 已有 AI 审核记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add amd/skills --skill lemonade-router-builder技能说明
name: lemonade-router-builder
description: >-
Turns a natural-language description of routing intent into a valid Lemonade
collection.router policy JSON. The skill generates and validates the JSON
only - it does not register it or call the live server.
Use when the user wants to route requests between models ("route sensitive
queries to X and everything else to Y"), generate a router/hybrid-router
config or policy, author a collection.router JSON, split traffic between a
small local model and a big/cloud model, add PII/jailbreak/topic classifiers
to routing, or mentions Lemonade Router, routing rules, routing.router,
candidates/default_model, keywords_any, semantic_similarity, or LLM-as-router.
Fills every field the user did not specify with safe defaults.
Lemonade Router Config Generator
Generate a collection.router policy JSON from a plain-English description
of how requests should be routed. The skill produces and validates the JSON
only - it does not call the live server, register the policy, or run requests
through it. The JSON is accepted by the strict server-side parser on the first
try and stays editable in the desktop app's Hybrid Router editor.
Prerequisites
- Lemonade Server v11.5.0+ running locally (
lemonade server start). Required only to register and test the generated policy - the skill itself (JSON generation + offline validation) works without a live server. - No GPU or ROCm dependency for authoring. The router policy is a JSON document; no hardware is needed to generate or validate it.
- Python (any 3.x) in PATH - used by the bundled offline validator
(
scripts/validate.py). No extra packages required.
The router picks one candidate model per request. Two authoring modes exist, and choosing the right one is the first decision:
| Mode | JSON shape | When |
|---|---|---|
| LLM-as-router | routing.router block | The user describes intent only by meaning ("sensitive", "hard questions", "creative writing") with no concrete signals. A small LLM reads each prompt and picks the candidate. |
| Rules | routing.rules (+ optional routing.classifiers) | The user names any concrete signal: keywords, regex, length, tools, images, metadata, PII/topic classifiers, thresholds, "first match", fallback logic. Deterministic, no extra LLM call for simple conditions. |
routing.router is mutually exclusive with routing.rules and
routing.classifiers - never emit both.
Step 1 - Extract from the user's words
- Candidates: the models that may answer requests. Verbatim model names
(e.g.
Gemma-3-4b-it-GGUF). If the user names none, ask - never invent model names.lemonade listorGET /api/v1/modelsshows what's available. A name the user did give may still not exist on the target host - the offline validator can't check that (Step 8b closes the gap). - Default / fallback: which candidate gets everything that matches nothing. If unstated, use the model the user framed as "local", "small", or "safe"; otherwise the first candidate mentioned.
- Signals: every condition mentioned (keywords, patterns, length, images, tools, topics, PII, safety) and which model each one routes to.
- Classifier models: models named for detection rather than answering (BERT-style encoders, embedding models, an LLM used as judge).
Step 2 - Scaffold
Always exactly this envelope (the parser rejects unknown or missing keys):
{
"version": "1",
"model_name": "user.MyHybridRouter",
"recipe": "collection.router",
"components": [],
"routing": { }
}
versionis the literal string"1".model_namemust start withuser.; slug from the user's description if they gave a name (user.<Name>using only[A-Za-z0-9._-]). If they didn't name it, derive one from context instead of a fixed literal - e.g.user.<slug-of-default-candidate>-Router- so two different policies don't collide by default./pullis idempotent permodel_name: registering a second policy under the same name silently overwrites the first. If this conversation already produced an unnamed router, don't reuse the same derived name for the next one - ask, or pick a visibly different name.
Step 3 - Candidates and default
"candidates": ["<answering models>"],
"default_model": "<one of candidates>"
default_model MUST be listed in candidates. Candidates should be
chat-capable LLMs - not embedding, classification, or image models.
Step 4 - Mode A: LLM-as-router
"router": {
"type": "llm",
"model": "<small chat LLM>",
"prompt": "You route user requests to the best model. <one sentence per candidate: when to pick it, using the exact model name>."
}
modeldefaults to the most capable candidate, not the cheapest one. The router judges every single request that flows through the policy, so a weak judge silently misrouting everything is a worse default than the extra cost of a stronger one. State the choice in the summary you give the user -router.model: <chosen>(most capable candidate available; pick a smaller dedicated judge model yourself for lower per-request cost, at the risk of the failure mode below). If the user already named a separate model for this role, use that instead of a candidate.- If
default_usedstaystrueacross varied test prompts even after fixing the prompt (see the bullet below and Step 9), the fix is a more capablerouter.model, not a further prompt edit - this is a judge-model-capability limit, not something prompt wording alone can solve. - Write intent only - never specify a reply format and never use imperative
"Pick X" phrasing. The engine unconditionally appends its own contract
after your prompt: it lists the candidate names and demands a strict JSON
reply
{"model": "<name>", "rationale": "<one sentence>"}, then falls back to `default_mo