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:
jimmy
2026-05-01 17:35:18 +08:00
committed by GitHub
parent 7f0c7b11e5
commit db66348ff8
6 changed files with 65 additions and 0 deletions
+25
View File
@@ -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();