feat: complete Rust backend UI compatibility
This commit is contained in:
+46
-1
@@ -3,6 +3,7 @@ use figment::{
|
||||
Figment,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct AppConfig {
|
||||
@@ -10,6 +11,8 @@ pub struct AppConfig {
|
||||
pub db: DbConfig,
|
||||
pub auth: AuthConfig,
|
||||
pub proxy: ProxyConfig,
|
||||
#[serde(default)]
|
||||
pub comfyui: ComfyUIConfig,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
@@ -46,11 +49,53 @@ pub struct ProxyConfig {
|
||||
pub proxy_log_retention_days: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct ComfyUIConfig {
|
||||
pub enabled: bool,
|
||||
pub install_dir: Option<PathBuf>,
|
||||
pub python_bin: String,
|
||||
pub port: u16,
|
||||
pub extra_args: Vec<String>,
|
||||
pub max_restarts: u32,
|
||||
pub external_url: Option<String>,
|
||||
pub base_url: Option<String>,
|
||||
pub agent_model: String,
|
||||
}
|
||||
|
||||
impl Default for ComfyUIConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
enabled: false,
|
||||
install_dir: None,
|
||||
python_bin: "python3".to_string(),
|
||||
port: 8188,
|
||||
extra_args: Vec::new(),
|
||||
max_restarts: 5,
|
||||
external_url: None,
|
||||
base_url: Some("http://127.0.0.1:8188".to_string()),
|
||||
agent_model: "gpt-4o".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ComfyUIConfig {
|
||||
pub fn target_base_url(&self) -> String {
|
||||
self.external_url
|
||||
.as_deref()
|
||||
.or(self.base_url.as_deref())
|
||||
.map(str::trim)
|
||||
.filter(|url| !url.is_empty())
|
||||
.unwrap_or("http://127.0.0.1:8188")
|
||||
.trim_end_matches('/')
|
||||
.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
impl AppConfig {
|
||||
pub fn load() -> anyhow::Result<Self> {
|
||||
dotenvy::dotenv().ok();
|
||||
Ok(Figment::new()
|
||||
.merge(Toml::file("config.toml").nested())
|
||||
.merge(Toml::file("config.toml"))
|
||||
.merge(Env::prefixed("BOOSAPI_").split("__"))
|
||||
.extract()?)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user