Skip to content

[BETA] Adaptive Router#43

Open
jeann2013 wants to merge 1 commit into
LiteLLM-Labs:mainfrom
jeann2013:feat/adaptive-router
Open

[BETA] Adaptive Router#43
jeann2013 wants to merge 1 commit into
LiteLLM-Labs:mainfrom
jeann2013:feat/adaptive-router

Conversation

@jeann2013

Copy link
Copy Markdown

[BETA] Adaptive Router

What it does: A virtual model (auto_router/adaptive_router) that classifies each request into one of seven types, chooses the best available real-world model by balancing learned quality versus cost, and learns from satisfaction signals in subsequent turns. Adapted to /v1/messages and /v1/responses (this project does not have /v1/chat/completions).

Added:

  • Config: model_info.adaptive_router_preferences, litellm_params.adaptive_router_config, with full validation.

  • Engine (src/sdk/adaptive_router/): Regex classifier, scoring with cold-start prior + online bandit (maximum 200 samples), conversation correlation without session ID (hash of the first message).

  • Persistence in Postgres (0003_adaptive_router_cells.sql), with proper degradation without a database.

  • Header x-litellm-adaptive-router-model + endpoint GET /adaptive_router/{router_name}/state.

  • docs/adaptive_router.md + example in config.yaml.example.

Testing:

  • 51 unit tests + 4 HTTP integration tests (wiremock).

  • fmt, clippy -D warnings, check_code_size.py — clean.

  • Manually verified with a real server: Real Postgres + Real Anthropic API. Confirmed end-to-end: classification → model selection → header → correlation between two requests → "thanks!" signal → bandit update (0.95→1.0, samples 0→1) — seen in both the HTTP response and the Postgres query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant