feat(provider): add zhipu ai#78
Conversation
📝 WalkthroughWalkthroughThis PR adds support for the ZhipuAI provider across the backend and frontend. Changes extend the provider schema and configuration enum to recognize ChangesZhipuAI Provider Integration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Review rate limit: 4/5 reviews remaining, refill in 12 minutes. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/proxy/provider.rs (1)
357-371: ⚡ Quick winAdd an explicit
api_base: Noneassertion for ZhipuAI in tests.Current test only checks the override-present path. Adding the
Nonepath guards regression for optional base URL handling on this new variant.Proposed test addition
@@ fn provider_auth_and_base_url_returns_zhipuai_api_key_and_optional_base_url() { @@ assert_eq!( base_url_override.as_ref().map(Url::as_str), Some("https://open.bigmodel.cn/api/paas/v4") ); } + + #[test] + fn provider_auth_and_base_url_returns_zhipuai_api_key_without_base_url_override() { + let config = ProviderConfig::ZhipuAi(ZhipuAiProviderConfig { + api_key: "zhipu-key".into(), + api_base: None, + }); + + let (auth, base_url_override) = provider_auth_and_base_url(&config).unwrap(); + + assert_eq!(auth.api_key_for("zhipuai").unwrap(), "zhipu-key"); + assert_eq!(base_url_override, None); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/proxy/provider.rs` around lines 357 - 371, Add a test verifying the ZhipuAi variant when api_base is None: create a ProviderConfig::ZhipuAi with ZhipuAiProviderConfig { api_key: "zhipu-key".into(), api_base: None }, call provider_auth_and_base_url(&config).unwrap(), assert auth.api_key_for("zhipuai").unwrap() == "zhipu-key" and assert base_url_override.is_none(); this complements the existing test that covers the Some(api_base) path and prevents regressions in provider_auth_and_base_url handling of optional api_base.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/proxy/provider.rs`:
- Around line 357-371: Add a test verifying the ZhipuAi variant when api_base is
None: create a ProviderConfig::ZhipuAi with ZhipuAiProviderConfig { api_key:
"zhipu-key".into(), api_base: None }, call
provider_auth_and_base_url(&config).unwrap(), assert
auth.api_key_for("zhipuai").unwrap() == "zhipu-key" and assert
base_url_override.is_none(); this complements the existing test that covers the
Some(api_base) path and prevents regressions in provider_auth_and_base_url
handling of optional api_base.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2a4f55b2-a67d-4aaf-a9e9-2acc95f45ef4
📒 Files selected for processing (8)
src/config/entities/providers-schema.jsonsrc/config/entities/providers.rssrc/gateway/providers/mod.rssrc/gateway/providers/zhipuai.rssrc/proxy/provider.rsui/src/i18n/locales/en.jsonui/src/i18n/locales/zh-CN.jsonui/src/lib/api/types.ts
Summary by CodeRabbit