feat(classifier): optional GigaChat-2-Lite hybrid tier classify
LLM classify via LiteLLM gigachat-classifier when heuristic confidence is low. CLASSIFIER_MODE=heuristic|hybrid|llm. Metrics classifier_source.
This commit is contained in:
@@ -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`:
|
||||
|
||||
Reference in New Issue
Block a user