80faead7eb
📁 Files changed: 18 📝 Lines changed: 494 • deploy.md • TASK.md • justfile • deploy.sh • config.py • __init__.py • generate_routes.py • models_routes.py • routes.py • sd_client.py • index-CcuP2dTH.css • index-DmOZ-7Sw.js • index-J_qzb7Jl.js • index-QncGJEyk.css • index.html • client.ts • GenerateView.vue • app.ts
2.9 KiB
2.9 KiB
Tensors Refactoring Task
Goal
Transform tensors from a "sd-server wrapper" to a pure client (CLI + UI) that talks to sd-server API directly.
- Default API URL:
https://sd-api.saiden.dev - API key auth via config:
sd_server_api_key - No wrapping/proxying/restarting of sd-server
Current Architecture
CLI Commands
| Command | What it does | Talks to |
|---|---|---|
tsr info <file> |
Read safetensor metadata, fetch CivitAI info | Local file + CivitAI API |
tsr search |
Search CivitAI models | CivitAI API |
tsr get <id> |
Fetch model info from CivitAI | CivitAI API |
tsr dl <id> |
Download model from CivitAI | CivitAI API |
tsr config |
Manage config (API keys, remotes) | Local config |
tsr generate |
Generate images | sd-server API (direct or via wrapper) |
tsr status |
Show wrapper status | tensors wrapper API |
tsr reload |
Reload sd-server with new model | tensors wrapper API |
tsr serve |
Start wrapper API (proxies to sd-server) | Starts FastAPI server |
tsr db |
Manage local models DB | Local SQLite |
tsr images |
Manage remote gallery | tensors wrapper API |
tsr models |
List models on remote | tensors wrapper API |
tsr remote |
Manage remote server config | Local config |
Server (tsr serve)
Starts a FastAPI server that:
- Proxies all requests to sd-server (catch-all route)
- Serves Vue UI at
/ - Adds features: gallery, CivitAI search, model listing, downloads
- Has a
/reloadendpoint that proxies to sd-server
What to Remove
| Remove | Reason |
|---|---|
tsr reload command |
sd-server manages its own models |
/reload route in server |
Same |
switch_model in client.py |
Same |
| Proxy wrapper concept | tensors should call API directly, not proxy |
What to Keep/Refactor
| Keep | Change |
|---|---|
tsr serve |
Just serve Vue UI, no proxying |
tsr generate |
Call sd-server API directly with API key |
| Vue UI | Call sd-server API directly (already does via /api/*) |
tsr models |
List models from sd-server API directly |
Already Done
- Added
get_sd_server_api_key()to config.py - Added
sd_server_api_keyto app state in server/__init__.py - Created
sd_client.pywithget_sd_headers()helper - Updated
generate_routes.pyto use API key headers - Updated
routes.pyto use API key headers - Updated
models_routes.pyto use API key headers - Created local config at
~/.xdg/tensors/config.tomlwith sd-api.saiden.dev
Still TODO
- Remove
tsr reloadcommand from cli.py - Remove
/reloadroute if it exists - Remove
switch_modelfrom client.py - Decide: keep
tsr serveas UI server or remove entirely? - Update Vue UI to call sd-server API directly (not via
/api/*proxy) - Clean up unused wrapper/proxy code