Conversation
📝 WalkthroughWalkthroughAdds a declarative Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Gateway
participant ProviderRegistry
participant Provider
participant LLM_API
Client->>Gateway: Send request (provider name, payload)
Gateway->>ProviderRegistry: lookup(provider name)
ProviderRegistry-->>Gateway: provider type/instance
Gateway->>Provider: request API key via ProviderAuth::api_key_for
Provider-->>Gateway: API key or validation error
Gateway->>Provider: Provider::build_auth_headers(api_key)
Provider-->>Gateway: HeaderMap (Authorization)
Gateway->>LLM_API: Forward request with headers
LLM_API-->>Gateway: Response
Gateway-->>Client: Return response
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Introduces a new gateway::providers module with built-in provider definitions and a provider!() macro to generate small OpenAI-compatible provider implementations.
Changes:
- Added
provider!()macro to generateProviderMeta+ defaultChatTransform+ emptyProviderCapabilities. - Added built-in providers (
OpenAIDefhand-written,DeepSeekmacro-generated) and adefault_provider_registry(). - Added
ProviderAuth::api_key()helper and updated internal docs describing the provider/macro layering.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/gateway/providers/openai.rs | Adds a concrete OpenAI provider definition + tests (auth headers, default quirks). |
| src/gateway/providers/deepseek.rs | Adds a macro-generated DeepSeek provider definition. |
| src/gateway/providers/macros.rs | Introduces provider!() macro for declarative provider definitions + tests. |
| src/gateway/providers/mod.rs | Exposes provider modules/exports and adds default_provider_registry() + test. |
| src/gateway/provider_instance.rs | Adds ProviderAuth::api_key() helper + unit test. |
| src/gateway/mod.rs | Exposes new gateway::providers module. |
| docs/internals/llm-types.md | Documents the new provider macro and provider layering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/gateway/providers/mod.rs (1)
10-15: Consider adding documentation for the public function.The
default_provider_registry()function is public and would benefit from a///documentation comment explaining its purpose and return value.📝 Proposed documentation
+/// Creates a provider registry pre-populated with all built-in providers. +/// +/// Returns an error if provider registration fails (e.g., duplicate names). pub fn default_provider_registry() -> Result<ProviderRegistry> { let builder = ProviderRegistry::builder() .register(OpenAIDef)? .register(DeepSeek)?; Ok(builder.build()) }As per coding guidelines: "Use /// documentation comments on public items".
🤖 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 10 - 15, The public function default_provider_registry lacks a /// doc comment; add a concise Rust documentation comment above the function that explains what default_provider_registry() returns (a Result<ProviderRegistry> containing a registry pre-registered with OpenAIDef and DeepSeek), describes any error conditions, and notes its typical usage; reference the ProviderRegistry builder and the registered providers (OpenAIDef, DeepSeek) in the comment so callers understand what the default registry contains.
🤖 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/gateway/providers/mod.rs`:
- Around line 10-15: The public function default_provider_registry lacks a ///
doc comment; add a concise Rust documentation comment above the function that
explains what default_provider_registry() returns (a Result<ProviderRegistry>
containing a registry pre-registered with OpenAIDef and DeepSeek), describes any
error conditions, and notes its typical usage; reference the ProviderRegistry
builder and the registered providers (OpenAIDef, DeepSeek) in the comment so
callers understand what the default registry contains.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: dbb54683-7905-40a2-b733-401eb4fd8ef6
📒 Files selected for processing (7)
docs/internals/llm-types.mdsrc/gateway/mod.rssrc/gateway/provider_instance.rssrc/gateway/providers/deepseek.rssrc/gateway/providers/macros.rssrc/gateway/providers/mod.rssrc/gateway/providers/openai.rs
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/gateway/providers/macros.rs (1)
1-1: Consider adding documentation for macro usage.The macro is well-implemented but lacks documentation comments. Adding
///docs with a usage example would help future maintainers understand the expected syntax and available options.📖 Proposed documentation
+/// Generates a provider marker type with [`ProviderMeta`], [`ProviderCapabilities`], +/// and [`ChatTransform`] implementations. +/// +/// # Example +/// ```ignore +/// provider!(MyProvider { +/// display_name: "my-provider", +/// base_url: "https://api.example.com", +/// chat_path: "/v1/chat", // optional, defaults to "/v1/chat/completions" +/// stream: StreamReaderKind::Sse, // optional, defaults to Sse +/// auth: bearer, // or: api_key_header("x-api-key") +/// quirks: { // optional block +/// unsupported_params: &["seed"], +/// } +/// }); +/// ``` macro_rules! provider {Also applies to: 146-146
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/gateway/providers/macros.rs` at line 1, Add doc comments above the provider! macro to describe its purpose, expected input syntax, and available options; specifically add /// comments before the macro_rules! provider declaration that include a short description and a usage example showing fields like display_name, base_url, optional chat_path, optional stream (e.g., StreamReaderKind::Sse), auth variants (bearer or api_key_header), and the optional quirks block (unsupported_params). Ensure the docs use triple-slash comments (///) and keep the example concise and accurate to the macro's accepted keys so future maintainers can quickly understand how to invoke provider!.
🤖 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/gateway/providers/macros.rs`:
- Line 1: Add doc comments above the provider! macro to describe its purpose,
expected input syntax, and available options; specifically add /// comments
before the macro_rules! provider declaration that include a short description
and a usage example showing fields like display_name, base_url, optional
chat_path, optional stream (e.g., StreamReaderKind::Sse), auth variants (bearer
or api_key_header), and the optional quirks block (unsupported_params). Ensure
the docs use triple-slash comments (///) and keep the example concise and
accurate to the macro's accepted keys so future maintainers can quickly
understand how to invoke provider!.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 99d02a9e-a130-4489-bed7-bfd9dda4fcbb
📒 Files selected for processing (3)
src/gateway/provider_instance.rssrc/gateway/providers/macros.rssrc/gateway/providers/openai.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- src/gateway/provider_instance.rs
- src/gateway/providers/openai.rs
As the 5th part of the major refactoring of the provider, we will add a macro for easily registering OpenAI-compatible providers and create a new deepseek provider to verify this.
Summary by CodeRabbit
New Features
Documentation