feat(api): add model loading, unloading, and uploading endpoints

This commit introduces new API endpoints for managing AI models:
- /models/{model_name}/load: Load a specific model into memory with validation
- /models/{model_name}/unload: Unload a specific model from memory
- /models/upload: Handle model file uploads via multipart form data

The implementation includes proper error handling, model existence validation, and integrates with the existing model manager system. The endpoints return structured JSON responses indicating success or failure states.

The changes also update dependencies to include actix-multipart and futures-util for handling multipart requests, and add path handling utilities for file operations.
This commit is contained in:
2026-03-03 17:34:37 +01:00
parent 027495829d
commit e5db9bc425
14 changed files with 1181 additions and 4 deletions

39
Cargo.toml Normal file
View File

@@ -0,0 +1,39 @@
[package]
name = "comfyui-rust"
version = "0.1.0"
edition = "2021"
[dependencies]
actix-web = { version = "4", features = ["openssl"] }
actix-multipart = "0.6"
futures-util = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio = { version = "1", features = ["full"] }
rayon = "1.5"
uuid = { version = "1.0", features = ["v4"] }
log = "0.4"
env_logger = "0.10"
thiserror = "1.0"
regex = "1.0"
chrono = { version = "0.4", features = ["serde"] }
eframe = "0.24"
egui = "0.24"
egui_extras = "0.24"
reqwest = { version = "0.11", features = ["json"] }
image = "0.24"
# For model loading capabilities
burn = { version = "0.21.0-pre.2", default-features = false }
burn-tch = { version = "0.21.0-pre.2" } # for torch backend
[dev-dependencies]
tokio-test = "0.4"
[[bin]]
name = "comfyui-rust-server"
path = "src/server.rs"
[[bin]]
name = "comfyui-rust-frontend"
path = "src/frontend.rs"