mixvideo-v2/cargos/uni-comfyui-sdk
imeepos e4eb2ce00f feat: 实现UniComfyUI工作流管理功能
新功能:
- 添加UniComfyUI工作流管理页面,支持工作流列表、搜索和执行
- 实现单次和批量工作流执行功能
- 添加美观的JSON Schema表单,支持文件上传、参数配置
- 集成文件上传到云端功能,自动获取HTTP URL
- 添加实时任务状态监控和进度显示

 技术实现:
- 新增UniComfyUI API层和服务层
- 实现数据库模型和Repository模式
- 添加数据库迁移脚本支持uni_comfyui_task表
- 集成react-hook-form和tailwind-scrollbar
- 实现健壮的日期时间解析,支持多种格式

 修复:
- 修复get_task_status接口参数名不匹配问题
- 修复日期时间解析错误,支持毫秒精度格式
- 修复表单提交流程,正确处理执行状态
- 修复文件上传使用本地路径问题,改为云端URL

 UI优化:
- 现代化的工作流卡片设计
- 美观的表单样式,支持文件拖拽上传
- 响应式布局,自适应滚动
- 清晰的状态指示和错误提示
2025-08-20 14:21:05 +08:00
..
examples feat: add uni-comfyui-sdk - Rust SDK for ComfyUI API 2025-08-15 15:31:33 +08:00
src feat: add uni-comfyui-sdk - Rust SDK for ComfyUI API 2025-08-15 15:31:33 +08:00
tests feat: add uni-comfyui-sdk - Rust SDK for ComfyUI API 2025-08-15 15:31:33 +08:00
.gitignore feat: add uni-comfyui-sdk - Rust SDK for ComfyUI API 2025-08-15 15:31:33 +08:00
Cargo.toml feat: 实现UniComfyUI工作流管理功能 2025-08-20 14:21:05 +08:00
README.md feat: add uni-comfyui-sdk - Rust SDK for ComfyUI API 2025-08-15 15:31:33 +08:00
unicomfy.json feat: add uni-comfyui-sdk - Rust SDK for ComfyUI API 2025-08-15 15:31:33 +08:00

README.md

uni-comfyui-sdk

A Rust SDK for ComfyUI Workflow Service & Management API.

Features

  • Status Management: Get metrics, server status, and file listings
  • Workflow Management: Create, retrieve, and delete workflows
  • Workflow Execution: Run workflows and monitor their status
  • Server Management: Register, unregister, and manage ComfyUI servers
  • Monitoring: Health checks, system stats, and task monitoring
  • Type Safety: Strongly typed API with comprehensive error handling

Installation

Add this to your Cargo.toml:

[dependencies]
uni-comfyui-sdk = "0.1.0"

Quick Start

use uni_comfyui_sdk::{UniComfyUIClient, Result};
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
    // Create a client
    let client = UniComfyUIClient::new("http://localhost:8000")?;

    // Get system metrics
    let metrics = client.get_metrics().await?;
    println!("Metrics: {:#?}", metrics);

    // Get all workflows
    let workflows = client.get_all_workflows().await?;
    println!("Found {} workflows", workflows.len());

    // Run a workflow
    let mut data = HashMap::new();
    data.insert("input".to_string(), serde_json::json!("test input"));
    let result = client.run_workflow("my_workflow", None, data).await?;
    println!("Workflow result: {:#?}", result);

    Ok(())
}

API Coverage

Status Endpoints

  • get_metrics() - Get queue status overview
  • get_servers_status() - Get all configured ComfyUI servers status
  • list_server_files(server_index) - List files in server input/output folders

Workflow Endpoints

  • get_all_workflows() - Get all workflows
  • publish_workflow(data) - Publish a new workflow
  • delete_workflow(workflow_name) - Delete a workflow
  • get_one_workflow(base_name, version) - Get workflow specification

Run Endpoints

  • run_workflow(name, version, data) - Execute workflow asynchronously
  • get_run_status(workflow_run_id) - Get workflow execution status

RunX Endpoints

  • model_with_multi_dress(version, data) - Model with multiple dresses workflow
  • model_with_multi_dress_json_schema() - Get workflow definition

Monitor Endpoints

  • monitor_dashboard() - Get monitoring dashboard HTML
  • get_system_stats() - Get system statistics
  • get_task_stats() - Get task statistics
  • get_monitor_server_status() - Get server status information
  • get_recent_tasks(limit) - Get recent tasks list
  • health_check() - Health check endpoint

ComfyUI Server Management Endpoints

  • register_server(request) - Register ComfyUI server
  • update_heartbeat(request) - Update server heartbeat
  • unregister_server(request) - Unregister ComfyUI server
  • get_server_status(server_name) - Get specific server status
  • list_all_servers() - Get all servers list
  • get_system_health() - Get system overall health status
  • force_health_check() - Force health check execution

Error Handling

The SDK provides comprehensive error handling through the ComfyUIError enum:

use uni_comfyui_sdk::{UniComfyUIClient, ComfyUIError};

match client.get_metrics().await {
    Ok(metrics) => println!("Success: {:#?}", metrics),
    Err(ComfyUIError::Http(e)) => println!("HTTP error: {}", e),
    Err(ComfyUIError::Api { status, message }) => {
        println!("API error {}: {}", status, message)
    }
    Err(e) => println!("Other error: {}", e),
}

Data Models

The SDK includes strongly typed models for all API requests and responses:

  • ServerRegistrationRequest - Server registration data
  • ServerHeartbeatRequest - Server heartbeat data
  • ServerStatusResponse - Server status information
  • ServerFiles - Server file listings
  • FileDetails - Individual file information
  • And more...

Examples

See the examples/ directory for more usage examples.

License

MIT