Update BossAI workflow and workspace experience
This commit is contained in:
@@ -108,8 +108,11 @@ impl UsageTracker {
|
||||
return Err(AppError::Forbidden("API key is disabled".into()));
|
||||
}
|
||||
if let Some(max_cost) = max_cost {
|
||||
if used_cost.unwrap_or(0.0) >= max_cost {
|
||||
return Err(AppError::RateLimited);
|
||||
if max_cost <= 0.0 || used_cost.unwrap_or(0.0) >= max_cost {
|
||||
return Err(AppError::RateLimitedWithRetry {
|
||||
message: "下游密钥成本额度已用完".into(),
|
||||
retry_after_secs: 60,
|
||||
});
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
@@ -260,7 +263,7 @@ mod tests {
|
||||
.unwrap();
|
||||
assert!(matches!(
|
||||
tracker.check_rate_limit(1).await,
|
||||
Err(AppError::RateLimited)
|
||||
Err(AppError::RateLimitedWithRetry { .. })
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,10 @@ impl ComfyUIProcess {
|
||||
let base_url = self.internal_base_url();
|
||||
let mode = if self.config.uses_docker_backend() {
|
||||
"docker"
|
||||
} else if self.config.uses_cloud_backend() {
|
||||
"cloud"
|
||||
} else if self.config.uses_runninghub_backend() {
|
||||
"runninghub"
|
||||
} else if self.config.enabled {
|
||||
"embedded"
|
||||
} else {
|
||||
|
||||
@@ -21,8 +21,17 @@ pub async fn enforce_key_request_limit(
|
||||
return Err(AppError::Forbidden("API key is disabled".into()));
|
||||
}
|
||||
if let Some(max_requests) = max_requests {
|
||||
if max_requests <= 0 {
|
||||
return Err(AppError::RateLimitedWithRetry {
|
||||
message: "下游密钥请求额度已用完".into(),
|
||||
retry_after_secs: 60,
|
||||
});
|
||||
}
|
||||
if used_requests.unwrap_or(0) + increment > max_requests {
|
||||
return Err(AppError::RateLimited);
|
||||
return Err(AppError::RateLimitedWithRetry {
|
||||
message: "下游密钥请求额度已用完".into(),
|
||||
retry_after_secs: 60,
|
||||
});
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user