feat(classifier): optional GigaChat-2-Lite hybrid tier classify
CI / build-gateway (push) Successful in 3s
CI / sync-config (push) Successful in 1s

LLM classify via LiteLLM gigachat-classifier when heuristic confidence
is low. CLASSIFIER_MODE=heuristic|hybrid|llm. Metrics classifier_source.
This commit is contained in:
2026-08-07 22:21:27 +03:00
parent 83d516afa1
commit 6fd2f0e689
11 changed files with 213 additions and 7 deletions
+20
View File
@@ -88,6 +88,26 @@ Novita always direct (`NO_PROXY=api.novita.ai`).
Header `X-AI-Quality: auto|economy|balanced|max` or `metadata.quality_mode` in request body. Default: `auto` (start lane A/B by tier, escalate on retry/5xx).
## LLM classifier (GigaChat, optional)
When `CLASSIFIER_MODE=hybrid` (default) and `GIGACHAT_CREDENTIALS` is set:
1. **Heuristic** classify first (0 cost)
2. If `confidence < 0.6` → one call to **GigaChat-2-Lite** via LiteLLM (`gigachat-classifier`)
3. Lane orchestration unchanged (A/B/C, Redis, budget)
| `CLASSIFIER_MODE` | Behavior |
|-------------------|----------|
| `heuristic` | Keywords only (no GigaChat) |
| `hybrid` | GigaChat only on low confidence |
| `llm` | Always GigaChat for text (except vision) |
Freemium GigaChat — для личного некомmercial теста; prod — юр. тариф Сбера.
Setup: [developers.sber.ru](https://developers.sber.ru/docs/ru/gigachat/quickstart/ind-create-project) → Authorization key → `.env` `GIGACHAT_CREDENTIALS`.
Response field: `x_router_meta.classifier_source` = `heuristic` | `gigachat` | `heuristic_fallback`.
## Response metadata
Each chat response includes `x_router_meta`: