feat(provider): add openrouter#63
Conversation
📝 WalkthroughWalkthroughThe pull request adds support for a new "openrouter" provider type across the backend and UI layers, including JSON schema updates, Rust configuration models, provider gateway implementation, proxy authentication handling, and localization strings in English and Chinese. Changes
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)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/gateway/providers/mod.rs (1)
41-50: Add tracing to this public function.
default_provider_registryis public but currently missing#[fastrace::trace].Suggested patch
+#[fastrace::trace] pub fn default_provider_registry() -> Result<ProviderRegistry> {As per coding guidelines "
src/**/*.rs: Use #[fastrace::trace] decorator for distributed tracing on public functions".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/gateway/providers/mod.rs` around lines 41 - 50, The public function default_provider_registry is missing the #[fastrace::trace] attribute required for distributed tracing; add the #[fastrace::trace] attribute directly above the pub fn default_provider_registry() -> Result<ProviderRegistry> declaration (keeping the function public and unchanged) so the function and its builder/register calls (AnthropicDef, AzureDef, BedrockDef, DeepSeek, GoogleDef, OpenAIDef, OpenRouter, and ProviderRegistry::builder) are traced; ensure the fastrace crate is available in scope (crate features/imports) if needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/gateway/providers/mod.rs`:
- Line 67: Replace the standard assert_eq! used in the test with
pretty_assertions::assert_eq! so test failures show unified diffs; specifically
change the assertion comparing registry.get("openrouter").unwrap().name() to use
pretty_assertions::assert_eq! (or add a top-level `use
pretty_assertions::assert_eq;` and keep the call as assert_eq!) to locate the
improved macro while leaving the rest of the test unchanged.
In `@src/proxy/provider.rs`:
- Around line 206-220: Replace the two standard assert_eq! calls inside the test
function
provider_auth_and_base_url_returns_openrouter_api_key_and_optional_base_url with
pretty_assertions::assert_eq! so the test uses pretty_assertions for better diff
output (update both assertions that compare auth.api_key_for("openrouter") and
base_url_override.as_ref().map(Url::as_str) accordingly).
---
Nitpick comments:
In `@src/gateway/providers/mod.rs`:
- Around line 41-50: The public function default_provider_registry is missing
the #[fastrace::trace] attribute required for distributed tracing; add the
#[fastrace::trace] attribute directly above the pub fn
default_provider_registry() -> Result<ProviderRegistry> declaration (keeping the
function public and unchanged) so the function and its builder/register calls
(AnthropicDef, AzureDef, BedrockDef, DeepSeek, GoogleDef, OpenAIDef, OpenRouter,
and ProviderRegistry::builder) are traced; ensure the fastrace crate is
available in scope (crate features/imports) if needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 764ab87f-c8f3-45c4-9bf9-bd25cde9a5b0
📒 Files selected for processing (9)
src/config/entities/providers-schema.jsonsrc/config/entities/providers.rssrc/gateway/providers/mod.rssrc/gateway/providers/openrouter.rssrc/proxy/provider.rsui/src/components/providers/provider-form.tsxui/src/i18n/locales/en.jsonui/src/i18n/locales/zh-CN.jsonui/src/lib/api/types.ts
Summary by CodeRabbit