#!/usr/bin/env bash # Sync model_list fragment from config/*.yaml set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" export ROOT python3 <<'PY' import os import yaml from pathlib import Path root = Path(os.environ["ROOT"]) rules = yaml.safe_load((root / "config/routing_rules.yaml").read_text(encoding="utf-8")) matrix = yaml.safe_load((root / "config/model_matrix.yaml").read_text(encoding="utf-8")) entries = [] for name, cfg in matrix.get("models", {}).items(): novita = cfg.get("novita") if not novita: continue entry = { "model_name": name, "litellm_params": { "model": novita, "api_key": "os.environ/NOVITA_API_KEY", }, } if cfg.get("rpm"): entry["litellm_params"]["rpm"] = cfg["rpm"] entries.append(entry) for name, cfg in matrix.get("optional_providers", {}).items(): entries.append({ "model_name": name, "litellm_params": { "model": cfg["model"], "api_key": cfg.get("api_key", "os.environ/GROQ_API_KEY"), }, }) litellm_rules = rules.get("litellm", {}) entries.append({ "model_name": "smart-router-internal", "litellm_params": { "model": "auto_router/complexity_router", "drop_params": True, "complexity_router_default_model": "a-medium-ops", "complexity_router_config": { "tiers": { "SIMPLE": "a-simple", "MEDIUM": "a-medium-ops", "MEDIUM_CODE": "a-medium-code", "COMPLEX": "a-complex", "REASONING": "a-reasoning", }, "classifier_fallback": "heuristic", "keyword_tier_rules": litellm_rules.get("keyword_tier_rules", []), "custom_technical_keywords": litellm_rules.get("custom_technical_keywords", []), "token_thresholds": {"simple": 20, "complex": 500}, "tier_boundaries": { "simple_medium": 0.18, "medium_complex": 0.38, "complex_reasoning": 0.62, }, "session_affinity": True, "session_affinity_ttl_seconds": 1800, }, }, }) out = root / "litellm_config.generated.yaml" out.write_text( yaml.dump({"model_list": entries}, allow_unicode=True, sort_keys=False), encoding="utf-8", ) print(f"Wrote {out} ({len(entries)} models)") PY