feat: initial commit for starlane-router (FastAPI + Gradient)

This commit is contained in:
greg
2025-08-25 20:08:09 -07:00
commit a991008666
13 changed files with 404 additions and 0 deletions

21
app/router.py Normal file
View File

@@ -0,0 +1,21 @@
from typing import Optional
from .config import get_route_keywords
def decide_route(*, message: str, explicit_hint: Optional[str] = None) -> str:
if explicit_hint:
hint = explicit_hint.strip().lower()
if hint in {"gradient", "local"}:
return hint
text = (message or "").strip().lower()
# Simple heuristic: if message is long or has keywords, use gradient
if len(text) > 120:
return "gradient"
for kw in get_route_keywords():
if kw in text:
return "gradient"
return "local"