feat: tool router para LiteLLM (callback + guardrail)

- CustomToolRouter como callback (roda em todas as chamadas)
- ToolRouterGuardrail para ativação por request
- Modos: jaccard (offline) e embedding (API)
- Dockerfile + docker-compose prontos
- README com docs completas
- Teste offline validando ~74% redução de tokens
This commit is contained in:
CM Consultor
2026-08-06 22:03:29 +00:00
commit 476f4f954d
10 changed files with 1386 additions and 0 deletions

20
.env.example Normal file
View File

@@ -0,0 +1,20 @@
# Copie para .env e preencha:
# cp .env.example .env
# Obrigatórias para o proxy falar com o provider
OPENAI_API_KEY=sk-...
LITELLM_MASTER_KEY=sk-change-me
# Porta publicada (docker-compose)
PORT=4000
# ── Tool Router ──────────────────────────────────────────────────────────────
TOOL_ROUTER_SIMILARITY_MODE=jaccard
TOOL_ROUTER_TOP_K=3
TOOL_ROUTER_MIN_SIMILARITY=0.15
TOOL_ROUTER_ALWAYS_INCLUDE=get_time,help,list_tools
TOOL_ROUTER_EMBEDDING_MODEL=text-embedding-3-small
# ── Cache Valkey (opcional — só se habilitar no config.yaml) ─────────────────
# VALKEY_HOST=valkey
# VALKEY_PORT=6379