mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 21:30:17 +08:00
feat(providers): add Baidu Qianfan Coding Plan for Claude Code (#2322)
* feat(providers): add baidu qianfan coding plan presets * refactor(providers): align qianfan presets with existing format * chore(providers): narrow qianfan coding plan scope
This commit is contained in:
@@ -789,6 +789,15 @@ impl StreamCheckService {
|
||||
return None;
|
||||
}
|
||||
let lower = body.to_lowercase();
|
||||
let qianfan_quota_indicators = [
|
||||
"coding_plan_hour_quota_exceeded",
|
||||
"coding_plan_week_quota_exceeded",
|
||||
"coding_plan_month_quota_exceeded",
|
||||
];
|
||||
if qianfan_quota_indicators.iter().any(|s| lower.contains(s)) {
|
||||
return Some("quotaExceeded");
|
||||
}
|
||||
|
||||
// 必须提到 "model",避免通用 404 / 400 被误判
|
||||
if !lower.contains("model") {
|
||||
return None;
|
||||
@@ -1733,6 +1742,22 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_detect_qianfan_coding_plan_quota_errors() {
|
||||
let cases = [
|
||||
r#"{"error":{"code":"coding_plan_hour_quota_exceeded","message":"hour quota exceeded"}}"#,
|
||||
r#"{"error":{"code":"coding_plan_week_quota_exceeded","message":"week quota exceeded"}}"#,
|
||||
r#"{"error":{"code":"coding_plan_month_quota_exceeded","message":"month quota exceeded"}}"#,
|
||||
];
|
||||
|
||||
for body in cases {
|
||||
assert_eq!(
|
||||
StreamCheckService::detect_error_category(429, body),
|
||||
Some("quotaExceeded")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_os_name() {
|
||||
let os_name = StreamCheckService::get_os_name();
|
||||
|
||||
Reference in New Issue
Block a user