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 { .. })
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user