Merge branch 'feature/comfyui-sdk-rewrite' of gitee.com:meepo_vip/mixvideo into feature/comfyui-sdk-rewrite
This commit is contained in:
commit
6e1e825369
|
|
@ -331,7 +331,7 @@ impl AppState {
|
|||
}
|
||||
|
||||
/// 初始化 ComfyUI Infrastructure 服务
|
||||
pub fn initialize_comfyui_service(&self, config: crate::data::models::comfyui::ComfyuiConfig) -> anyhow::Result<()> {
|
||||
pub fn initialize_comfyui_service(&self, config: crate::data::models::comfyui::ComfyUIConfig) -> anyhow::Result<()> {
|
||||
let service = ComfyuiInfrastructureService::new(config)?;
|
||||
|
||||
let mut comfyui_service = self.comfyui_infrastructure_service.lock()
|
||||
|
|
@ -355,7 +355,7 @@ impl AppState {
|
|||
}
|
||||
|
||||
/// 更新 ComfyUI Infrastructure 服务配置
|
||||
pub async fn update_comfyui_config(&self, config: crate::data::models::comfyui::ComfyuiConfig) -> anyhow::Result<()> {
|
||||
pub async fn update_comfyui_config(&self, config: crate::data::models::comfyui::ComfyUIConfig) -> anyhow::Result<()> {
|
||||
// 创建新的服务实例
|
||||
let new_service = ComfyuiInfrastructureService::new(config)?;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use crate::config::{AppConfig, ComfyUISettings};
|
|||
use crate::data::models::comfyui::{ComfyUIConfig, ValidationResult};
|
||||
|
||||
/// 环境类型
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub enum Environment {
|
||||
/// 开发环境
|
||||
Development,
|
||||
|
|
@ -158,7 +158,7 @@ impl ConfigManager {
|
|||
|
||||
/// 验证应用配置
|
||||
async fn validate_app_config(&self, config: &AppConfig) -> Result<ValidationResult> {
|
||||
use crate::data::models::comfyui::{ValidationResult, ValidationError};
|
||||
use crate::data::models::comfyui::{ValidationResult, SDKValidationError as ValidationError};
|
||||
|
||||
let mut result = ValidationResult::success();
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ impl ConfigManager {
|
|||
}
|
||||
|
||||
/// 配置统计信息
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct ConfigStats {
|
||||
pub environment: Environment,
|
||||
pub config_path: Option<String>,
|
||||
|
|
|
|||
|
|
@ -368,7 +368,7 @@ impl ExecutionEngine {
|
|||
}
|
||||
|
||||
/// 执行统计信息
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct ExecutionStats {
|
||||
pub running_count: usize,
|
||||
pub running_executions: Vec<String>,
|
||||
|
|
|
|||
|
|
@ -445,7 +445,7 @@ impl RealtimeMonitor {
|
|||
}
|
||||
|
||||
/// 监控统计信息
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct MonitorStats {
|
||||
pub is_running: bool,
|
||||
pub websocket_connected: bool,
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ impl TemplateEngine {
|
|||
}
|
||||
|
||||
/// 缓存统计信息
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct CacheStats {
|
||||
pub cached_templates: usize,
|
||||
pub cache_keys: Vec<String>,
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ impl ComfyUISettings {
|
|||
|
||||
/// 验证配置
|
||||
pub fn validate(&self) -> crate::data::models::comfyui::ValidationResult {
|
||||
use crate::data::models::comfyui::{ValidationResult, ValidationError};
|
||||
use crate::data::models::comfyui::{ValidationResult, SDKValidationError as ValidationError};
|
||||
|
||||
let mut result = ValidationResult::success();
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use uuid::Uuid;
|
|||
// 重新导出 SDK 类型
|
||||
pub use comfyui_sdk::types::{
|
||||
ComfyUIWorkflow, ParameterSchema, ParameterType, ParameterValues,
|
||||
ValidationResult, ValidationError, TemplateMetadata, WorkflowTemplateData,
|
||||
ValidationResult, ValidationError as SDKValidationError, TemplateMetadata, WorkflowTemplateData,
|
||||
QueueStatus, SystemStats, ObjectInfo
|
||||
};
|
||||
|
||||
|
|
@ -435,6 +435,33 @@ pub struct QueueStatistics {
|
|||
pub average_wait_time: Option<u64>,
|
||||
}
|
||||
|
||||
/// 旧版 ComfyUI 配置(用于 Infrastructure 服务)
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ComfyuiConfig {
|
||||
/// 服务基础 URL
|
||||
pub base_url: String,
|
||||
/// 连接超时时间(秒)
|
||||
pub timeout: Option<u64>,
|
||||
/// 重试次数
|
||||
pub retry_attempts: Option<u32>,
|
||||
/// 是否启用缓存
|
||||
pub enable_cache: Option<bool>,
|
||||
/// 最大并发数
|
||||
pub max_concurrency: Option<u32>,
|
||||
}
|
||||
|
||||
impl Default for ComfyuiConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
base_url: "http://localhost:8188".to_string(),
|
||||
timeout: Some(300),
|
||||
retry_attempts: Some(3),
|
||||
enable_cache: Some(true),
|
||||
max_concurrency: Some(4),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// ComfyUI 服务配置
|
||||
/// 基于 SDK 的统一配置结构
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
|
@ -490,26 +517,26 @@ impl ComfyUIConfig {
|
|||
|
||||
// 验证 URL
|
||||
if self.base_url.is_empty() {
|
||||
result.add_error(ValidationError::new("base_url", "Base URL cannot be empty"));
|
||||
result.add_error(SDKValidationError::new("base_url".to_string(), "Base URL cannot be empty".to_string(), None));
|
||||
} else if url::Url::parse(&self.base_url).is_err() {
|
||||
result.add_error(ValidationError::new("base_url", "Invalid URL format"));
|
||||
result.add_error(SDKValidationError::new("base_url".to_string(), "Invalid URL format".to_string(), None));
|
||||
}
|
||||
|
||||
// 验证超时时间
|
||||
if self.timeout_seconds == 0 {
|
||||
result.add_error(ValidationError::new("timeout_seconds", "Timeout must be greater than 0"));
|
||||
result.add_error(SDKValidationError::new("timeout_seconds".to_string(), "Timeout must be greater than 0".to_string(), None));
|
||||
}
|
||||
|
||||
// 验证重试次数
|
||||
if self.retry_attempts > 10 {
|
||||
result.add_error(ValidationError::new("retry_attempts", "Retry attempts should not exceed 10"));
|
||||
result.add_error(SDKValidationError::new("retry_attempts".to_string(), "Retry attempts should not exceed 10".to_string(), None));
|
||||
}
|
||||
|
||||
// 验证并发数
|
||||
if self.max_concurrency == 0 {
|
||||
result.add_error(ValidationError::new("max_concurrency", "Max concurrency must be greater than 0"));
|
||||
result.add_error(SDKValidationError::new("max_concurrency".to_string(), "Max concurrency must be greater than 0".to_string(), None));
|
||||
} else if self.max_concurrency > 100 {
|
||||
result.add_error(ValidationError::new("max_concurrency", "Max concurrency should not exceed 100"));
|
||||
result.add_error(SDKValidationError::new("max_concurrency".to_string(), "Max concurrency should not exceed 100".to_string(), None));
|
||||
}
|
||||
|
||||
result
|
||||
|
|
@ -686,7 +713,7 @@ pub struct ApiRootResponse {
|
|||
|
||||
/// HTTP 验证错误详情
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ValidationError {
|
||||
pub struct HttpValidationError {
|
||||
/// 错误位置
|
||||
pub loc: Vec<serde_json::Value>,
|
||||
/// 错误消息
|
||||
|
|
@ -700,7 +727,7 @@ pub struct ValidationError {
|
|||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct HTTPValidationError {
|
||||
/// 错误详情列表
|
||||
pub detail: Vec<ValidationError>,
|
||||
pub detail: Vec<HttpValidationError>,
|
||||
}
|
||||
|
||||
/// ComfyUI API 错误类型
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ impl ComfyuiInfrastructureService {
|
|||
}
|
||||
|
||||
/// 获取配置信息
|
||||
pub fn get_config(&self) -> &ComfyuiConfig {
|
||||
pub fn get_config(&self) -> &ComfyUIConfig {
|
||||
&self.config
|
||||
}
|
||||
|
||||
|
|
@ -346,7 +346,7 @@ impl ComfyuiInfrastructureService {
|
|||
}
|
||||
|
||||
/// 更新服务配置
|
||||
pub fn update_config(&mut self, config: ComfyuiConfig) -> Result<()> {
|
||||
pub fn update_config(&mut self, config: ComfyUIConfig) -> Result<()> {
|
||||
// 验证新配置
|
||||
let temp_service = Self::new(config.clone())?;
|
||||
temp_service.validate_config()?;
|
||||
|
|
|
|||
|
|
@ -765,12 +765,15 @@ pub fn run() {
|
|||
}
|
||||
|
||||
// 初始化 ComfyUI 服务 - 使用本地 ComfyUI 服务器
|
||||
let comfyui_config = data::models::comfyui::ComfyuiConfig {
|
||||
let comfyui_config = data::models::comfyui::ComfyUIConfig {
|
||||
base_url: "https://bowongai-dev--waas-demo-fastapi-webapp.modal.run".to_string(),
|
||||
timeout: Some(600), // 10分钟超时,适应 ComfyUI 工作流的长时间处理
|
||||
retry_attempts: Some(3),
|
||||
enable_cache: Some(true),
|
||||
max_concurrency: Some(8),
|
||||
timeout_seconds: 600, // 10分钟超时,适应 ComfyUI 工作流的长时间处理
|
||||
retry_attempts: 3,
|
||||
retry_delay_ms: 1000,
|
||||
enable_websocket: true,
|
||||
enable_cache: true,
|
||||
max_concurrency: 8,
|
||||
custom_headers: None,
|
||||
};
|
||||
|
||||
if let Err(e) = state.initialize_comfyui_service(comfyui_config) {
|
||||
|
|
|
|||
|
|
@ -397,7 +397,7 @@ pub async fn comfyui_node_get_data(
|
|||
#[tauri::command]
|
||||
pub async fn comfyui_get_config(
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<ComfyuiConfig, String> {
|
||||
) -> Result<ComfyUIConfig, String> {
|
||||
info!("Command: comfyui_get_config");
|
||||
|
||||
let app_state = state.inner();
|
||||
|
|
@ -424,7 +424,7 @@ pub async fn comfyui_get_config(
|
|||
/// ```
|
||||
#[tauri::command]
|
||||
pub async fn comfyui_update_config(
|
||||
config: ComfyuiConfig,
|
||||
config: ComfyUIConfig,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<bool, String> {
|
||||
info!("Command: comfyui_update_config");
|
||||
|
|
|
|||
|
|
@ -129,14 +129,14 @@ pub enum VariableSyntax {
|
|||
}
|
||||
|
||||
/// Template validation result
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct ValidationResult {
|
||||
pub valid: bool,
|
||||
pub errors: Vec<ValidationError>,
|
||||
}
|
||||
|
||||
/// Validation error
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct ValidationError {
|
||||
pub path: String,
|
||||
pub message: String,
|
||||
|
|
|
|||
Loading…
Reference in New Issue