Repository navigation
fix(models): honor model_name on /models/load and /models/unload (fixes #977) - #988
SEPURI-SAI-KRISHNA wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe model management API now accepts optional model names for loading and unloading. Named models use registry resolution and backend dispatch. Requests without a model name retain default Qwen behavior. Tests and documentation cover the new routing. ChangesModel routing
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant ModelsRoute
participant ModelRegistry
participant BackendLoader
Client->>ModelsRoute: POST /models/load with model_name
ModelsRoute->>ModelRegistry: Resolve model configuration
ModelRegistry-->>ModelsRoute: Return model configuration
ModelsRoute->>BackendLoader: Load resolved model
BackendLoader-->>ModelsRoute: Return load result
ModelsRoute-->>Client: Return response
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
docs/content/docs/developer/model-management.mdx (1)
120-133: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winAlign the endpoint table with the registry scope.
Line 120 states that
/models/loadaccepts TTS, Whisper, and LLM model IDs. TheManual Model Operationstable at Lines 105-106 still describes/models/loadand/models/unloadas TTS-only. Change both descriptions to registered-model operations.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docs/content/docs/developer/model-management.mdx` around lines 120 - 133, Update the Manual Model Operations table entries for /models/load and /models/unload to describe operations on registered models rather than TTS-only models, matching the registry scope documented in the surrounding model-management section.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/routes/models.py`:
- Around line 85-86: Explicit empty model names are being treated as omitted,
incorrectly triggering the default Qwen load/unload paths. In
backend/routes/models.py lines 85-86 and 117-118, change both requested_name
checks to distinguish None from an empty string; in
backend/tests/test_models_load_by_name.py lines 89-96 and 130-134, add
empty-string cases asserting 400 responses and no named or Qwen load/unload
calls.
---
Outside diff comments:
In `@docs/content/docs/developer/model-management.mdx`:
- Around line 120-133: Update the Manual Model Operations table entries for
/models/load and /models/unload to describe operations on registered models
rather than TTS-only models, matching the registry scope documented in the
surrounding model-management section.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 4cffc99d-cf00-430e-89b7-15ff23228460
📒 Files selected for processing (4)
backend/models.pybackend/routes/models.pybackend/tests/test_models_load_by_name.pydocs/content/docs/developer/model-management.mdx
Fixes #977. Also addresses #448.
Problem
POST /models/loaddeclared only amodel_sizequery parameter and always dispatched to the default Qwen backend:Because no body model is declared, FastAPI silently discards any JSON body. So
POST /models/load {"model_name": "kokoro"}returns 200 OK and then starts a 3.6 GB Qwen 1.7B download. There was no way to load Kokoro, Chatterbox, LuxTTS, Whisper, or the LLM through this endpoint — even though/models/download,/models/{name}/unload, andDELETE /models/{name}all dispatch correctly viaget_model_config/get_model_load_func.This is a documented-contract violation, not a feature request.
docs/content/docs/developer/model-management.mdxalready specifies:/models/unloadhad the identical bug. The same doc page documentsPOST /models/unload {"model_name": "chatterbox-tts"}→unload_model_by_config(config). That body was ignored too, so a user following the docs to free VRAM for Chatterbox would silently unload Qwen instead. Unfiled, same shape, same file, same doc page — fixed alongside.Fix
Both routes now accept an optional
ModelLoadRequestbody. Withmodel_namethey resolve through the registry; an unknown name returns a 400 listing the valid ids instead of silently loading Qwen. Without one, behaviour is unchanged.Backward compatibility was verified by request, not just by reading:
POST /models/load(no body)1.7BPOST /models/load?model_size=0.6B0.6BPOST /models/load?model_size=0.6B+ empty body +Content-Type: application/json0.6BPOST /models/load {"model_name":"kokoro"}POST /models/unload(no body)POST /models/kokoro/unloadNo frontend change is needed: the app never calls
/models/load, andapiClient.unloadModeluses the path-param route.Tests
backend/tests/test_models_load_by_name.py— 12 tests covering per-engine dispatch across TTS/STT/LLM families, the unknown-model 400, and every legacy calling form.6 of the 12 fail on
main. The rest of the backend suite is unaffected.Notes
docs/openapi.jsonandapp/src/lib/api/services/DefaultService.tsare generated artifacts and are now stale for this route. Left alone — regenerating requires a running backend, and recent merged PRs that changed routes (e.g. fix(export): disambiguate export filenames with generation id #956) didn't touch them either. Happy to include a regenerated pair if you'd prefer.CHANGELOG.mdis deliberately untouched — its header states it is compiled automatically during the release workflow.Summary by CodeRabbit
Release Notes
New Features
Documentation