Uh oh!
There was an error while loading. Please reload this page.
feat(core): add Adapter enum (skeleton for issue #302 Phase A) - #297
Conversation
Introduces a new closed `Adapter` enum (Openai, Anthropic, Bedrock, Vertex, AzureOpenai) alongside the existing `Provider` enum, plus a `From<Provider> for Adapter` mapping. This is the first sub-PR of issue api7/AISIX-Cloud#302 Phase A — the broader effort renames DP's `Provider` to `Adapter` (closed wire-shape set) and adds a separate open-string vendor identity on the control plane. Behavior is unchanged in this PR: - `Provider` still exists, still drives all dispatch. - No entity field references `Adapter`. - No schema, no Hub, no Bridge changes. The Adapter uses `kebab-case` so AzureOpenai serializes as "azure-openai"; Provider keeps `lowercase` because all its values are single tokens. From<Provider> mapping rationale (also documented inline): - Openai → Openai (direct) - Anthropic → Anthropic (direct) - Google → Vertex (Vertex AI wire shape is the production target; no separate AI Studio adapter) - Deepseek → Openai (OpenAI-compatible chat completions) - Cohere → Openai (gateway uses Cohere OpenAI-compat endpoints; #213 Phase 1 — rerank-only) - Jina → Openai (rerank identity-mapped to OpenAI-compat shape; #213 Phase 2) Tests: - Every Provider variant has its mapped Adapter pinned. - Adapter serialize/deserialize pinned for all 5 variants, with azure-openai as the load-bearing kebab-case case. - Unknown variant strings (e.g. "gemini", "azureopenai") rejected.
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a new public ChangesAdapter type and public export
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Note 🎁 Summarized by CodeRabbit FreeYour organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above. Comment |
moonming
commented
May 16, 2026
Independent audit (CLAUDE.md §8)Cold review by an audit pass with no shared context. Brief: skeleton PR adding Verdict per angle
FindingsMEDIUM-1: |
…dback Address audit MEDIUM-1 and LOW-1 on PR #297 without changing the mapping itself (per Phase A plan): - LOW-1: drop the word 'legacy' on Provider — Provider is still the source of truth across Phase A; 'legacy' was misleading. - MEDIUM-1: spell out that Provider::Google → Adapter::Vertex is a forward-looking mapping that intentionally diverges from current runtime behavior (Provider::Google today speaks OpenAI-compat against /v1beta/openai). Any downstream PR that flips dispatch onto Adapter must either also migrate the Google bridge to native Vertex AI encoding or revisit this arm before merging. No code/runtime change; only the doc-comment for the From impl.
moonming
commented
May 16, 2026
Audit responseAddressed in 5d76cc0:
cargo fmt / cargo test / cargo clippy all still clean. |
moonming
commented
May 16, 2026
Independent third-party audit (separate from author self-review)Cold review pass by an audit agent with no shared context. Brief: skeleton PR adding closed Note: I have read the author self-review (the "Independent audit (CLAUDE.md §8)" comment above) and the follow-up commit 5d76cc0. This audit is independent of that pass and verifies the mitigation actually landed plus checks the angles the self-review may not have covered. Verdict per §8 angle
Independent verification steps I ran
FindingsMEDIUM-1 (author-disclosed, mitigation verified)Author already disclosed and addressed in commit 5d76cc0. I confirm:
LOW-1: |
Uh oh!
There was an error while loading. Please reload this page.
Summary
First sub-PR of api7/AISIX-Cloud#302 Phase A (DP-side Provider→Adapter refactor).
Adds a new closed
Adapterenum onaisix-corealongside the existingProviderenum, plus aFrom<Provider> for Adaptermapping.This PR is intentionally zero-behavior-change — it only introduces new types. Nothing in the gateway dispatches off
Adapteryet, no entity field references it, andProvidercontinues to drive 100% of runtime behavior. Follow-up sub-PRs in Phase A migrate entities, schema, the Hub, and Bridges to consumeAdapterdirectly.What this PR does
Adapterenum incrates/aisix-core/src/models/model.rs:Openai,Anthropic,Bedrock,Vertex,AzureOpenaiProvider(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)#[serde(rename_all = "kebab-case")]soAzureOpenaiserializes as"azure-openai"From<Provider> for Adaptermapping:Openai→OpenaiAnthropic→AnthropicGoogle→Vertex(Vertex AI wire shape; the currentProvider::Googlewas renamed fromGeminiin refactor: rename provider 'gemini' to 'google' to match models.dev #279)Deepseek→Openai(OpenAI-compatible chat completions)Cohere→Openai(gateway uses Cohere OpenAI-compat endpoints; feat: expand /v1/rerank, /v1/images/generations, /v1/responses beyond OpenAI-only #213 Phase 1, rerank-only)Jina→Openai(rerank identity-mapped to OpenAI-compat shape; feat: expand /v1/rerank, /v1/images/generations, /v1/responses beyond OpenAI-only #213 Phase 2)Adapterfromaisix_core::modelsand the crate root, mirroringProvider.What this PR does NOT do
ProviderProviderKeystructschema.rs/ JSON SchemaSerde casing note
The Adapter uses
kebab-casewhileProvideruseslowercase. This is intentional:Provider's values are all single tokens (no hyphens or underscores to disambiguate), but Adapter needsazure-openaito remain readable on the wire. Both are pinned by tests so future edits are surfaced loudly.Test plan
cargo test -p aisix-core— 136 passed, 0 failed (includes 4 new Adapter tests)cargo clippy --workspace --all-targets -- -D warnings— cleancargo fmt --all -- --check— cleanProvidervariants covered byFrom<Provider>mapping testAdaptervariants pinned by serialize/deserialize round-trip tests"gemini","azureopenai","azure_openai") rejected by deserializeReferences
Summary by CodeRabbit
New Features
Tests