[model_routes] 1466-line route file exceeds AGENTS.md ~400 line limit #701

Closed
opened 2026-06-02 23:55:32 +02:00 by sleepy · 0 comments
Owner

File: routes/model_routes.py (1466 lines)

AGENTS.md rule: Split files that exceed ~400 lines or contain multiple concerns.

This file mixes:

  1. Provider-specific URL helpers_anthropic_api_root, _ollama_api_root, _models_url, _provider_headers (lines 25–70, duplicates from llm_core.py and endpoint_resolver.py)
  2. Model curation/filtering_PROVIDER_CURATED, _curate_models, _is_chat_model, _NON_CHAT_* constants (lines 73–214)
  3. Endpoint probing_probe_endpoint, _ping_endpoint, _probe_single_model, _classify_endpoint (lines 217–425)
  4. Model cache management_refresh_caches_bg, _fetch_models (lines 427–586)
  5. Model listing API/api/models (lines 588–629)
  6. Local endpoint probing/api/model-endpoints/probe-local (lines 638–687)
  7. CRUD endpoints — create, read, update, delete model endpoints (lines 886–1466)
  8. Settings management_settings_using_endpoint, _clear_settings_for_endpoint, _clear_sessions_for_endpoint (lines 1328–1408)
  9. Tool management/api/tools (lines 1441–1464)

Suggested split:

  • routes/model_routes.py — thin router, setup function, route handlers only
  • src/model_probing.py_probe_endpoint, _ping_endpoint, _probe_single_model
  • src/model_curation.py — curated lists, filtering, classification
  • src/model_cache.py — background refresh, per-user cache management

The duplicated helpers (_anthropic_api_root, _ollama_api_root, _provider_headers) should be removed in favor of the originals in endpoint_resolver.py.

**File:** `routes/model_routes.py` (1466 lines) **AGENTS.md rule:** Split files that exceed ~400 lines or contain multiple concerns. This file mixes: 1. **Provider-specific URL helpers** — `_anthropic_api_root`, `_ollama_api_root`, `_models_url`, `_provider_headers` (lines 25–70, duplicates from `llm_core.py` and `endpoint_resolver.py`) 2. **Model curation/filtering** — `_PROVIDER_CURATED`, `_curate_models`, `_is_chat_model`, `_NON_CHAT_*` constants (lines 73–214) 3. **Endpoint probing** — `_probe_endpoint`, `_ping_endpoint`, `_probe_single_model`, `_classify_endpoint` (lines 217–425) 4. **Model cache management** — `_refresh_caches_bg`, `_fetch_models` (lines 427–586) 5. **Model listing API** — `/api/models` (lines 588–629) 6. **Local endpoint probing** — `/api/model-endpoints/probe-local` (lines 638–687) 7. **CRUD endpoints** — create, read, update, delete model endpoints (lines 886–1466) 8. **Settings management** — `_settings_using_endpoint`, `_clear_settings_for_endpoint`, `_clear_sessions_for_endpoint` (lines 1328–1408) 9. **Tool management** — `/api/tools` (lines 1441–1464) Suggested split: - `routes/model_routes.py` — thin router, setup function, route handlers only - `src/model_probing.py` — `_probe_endpoint`, `_ping_endpoint`, `_probe_single_model` - `src/model_curation.py` — curated lists, filtering, classification - `src/model_cache.py` — background refresh, per-user cache management The duplicated helpers (`_anthropic_api_root`, `_ollama_api_root`, `_provider_headers`) should be removed in favor of the originals in `endpoint_resolver.py`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sleepy/odysseus#701
No description provided.