Skip to content

feat(provider): add siliconflow#82

Merged
bzp2010 merged 1 commit intomainfrom
bzp/feat-siliconflow-provider
May 4, 2026
Merged

feat(provider): add siliconflow#82
bzp2010 merged 1 commit intomainfrom
bzp/feat-siliconflow-provider

Conversation

@bzp2010
Copy link
Copy Markdown
Collaborator

@bzp2010 bzp2010 commented May 4, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Added SiliconFlow provider integration with both global and CN regional variants, featuring OpenAI-compatible API support and enhanced DeepSeek model compatibility.
  • UI/UX Improvements

    • Refactored provider type labels to use a centralized localization system, improving consistency and maintainability across the interface.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

📝 Walkthrough

Walkthrough

This pull request adds support for two new OpenAI-compatible provider types—siliconflow and siliconflow-cn—by extending the JSON schema, Rust configuration, gateway provider registry, proxy auth handling, and frontend type definitions. It includes a custom ChatTransform rule for DeepSeek-V3.1 models that injects or validates the enable_thinking parameter based on tool presence.

Changes

SiliconFlow Provider Addition

Layer / File(s) Summary
Schema Definition
src/config/entities/providers-schema.json
Root type enum and OpenAI-compatible conditional selector now include "siliconflow" and "siliconflow-cn".
Configuration Types
src/config/entities/providers.rs
ProviderConfig enum gains SiliconFlow and SiliconFlowCn variants; provider_type() match returns corresponding identifier constants.
Provider Implementation
src/gateway/providers/siliconflow.rs
New module defines config structs, implements ProviderMeta for URL/auth, and implements ChatTransform with DeepSeek-V3.1 compatibility (injects/rejects enable_thinking when tools present) and EmbedTransform for embeddings conversion.
Gateway/Proxy Integration
src/gateway/providers/mod.rs, src/proxy/provider.rs
Gateway registers both SiliconFlow providers and exposes identifier/config types; proxy adds auth and base URL handling for both variants.
Frontend Types & i18n
ui/src/lib/api/types.ts, ui/src/i18n/locales/{en,zh-CN}.json, ui/src/components/{models,providers}/\*-form.tsx, ui/src/routes/_layout/providers/index.tsx
Added siliconflow and siliconflow-cn to PROVIDER_TYPE_VARIANTS and Provider union; centralized provider type labels in top-level providerTypes translation object; updated UI components to use new i18n key structure.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Gateway as Gateway Provider
    participant Transform as SiliconFlow Transform
    participant API as SiliconFlow API

    Client->>Gateway: POST chat request<br/>(model, tools, enable_thinking)
    Gateway->>Transform: Route to SiliconFlow provider
    
    alt model == "deepseek-ai/DeepSeek-V3.1" AND tools present
        alt enable_thinking == true
            Transform-->>Gateway: Reject request<br/>(incompatible)
        else enable_thinking missing
            Transform->>Transform: Inject enable_thinking: false
        else enable_thinking == false
            Transform->>Transform: Keep as-is
        end
    end
    
    Transform->>API: Forward transformed request
    API-->>Transform: Response
    Transform-->>Gateway: Response
    Gateway-->>Client: Response
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Possibly related PRs

  • feat(provider): add openrouter #63: Parallel provider type addition using identical code-level patterns across schema, ProviderConfig, gateway registry, proxy auth, and UI types.
  • feat(provider): add groq #71: Similar OpenAI-compatible provider implementation with matching schema enum, ProviderConfig variant/match, gateway module, and proxy auth changes.
  • feat(provider): add moonshot #77: Another new OpenAI-compatible provider following the same architectural pattern (schema, ProviderConfig, gateway registration, proxy handling, and UI i18n).
🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
E2e Test Quality Review ⚠️ Warning PR introduces unit tests for siliconflow provider but completely lacks E2E tests required by custom check specification. Add E2E tests in admin/models.test.ts, proxy/chat-completions.test.ts, and proxy/embeddings.test.ts to verify complete siliconflow provider workflows.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(provider): add siliconflow' directly and clearly summarizes the main change—adding support for the SiliconFlow provider across the backend and frontend codebase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Check ✅ Passed SiliconFlow provider implementation securely handles API keys without deriving Debug, uses proper Authorization header injection at request time, and follows established patterns from similar providers.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bzp/feat-siliconflow-provider

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/gateway/providers/siliconflow.rs (1)

31-55: ⚡ Quick win

Add /// doc comments for newly introduced public items.

IDENTIFIER, CN_IDENTIFIER, SiliconFlowProviderConfig, SiliconFlowCnProviderConfig, SiliconFlow, and SiliconFlowCn are public API surface and should be documented consistently.

📝 Proposed patch
-pub const IDENTIFIER: &str = "siliconflow";
-pub const CN_IDENTIFIER: &str = "siliconflow-cn";
+/// Provider identifier for SiliconFlow global endpoint.
+pub const IDENTIFIER: &str = "siliconflow";
+/// Provider identifier for SiliconFlow China endpoint.
+pub const CN_IDENTIFIER: &str = "siliconflow-cn";

 #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
+/// Configuration for SiliconFlow global endpoint.
 pub struct SiliconFlowProviderConfig {
     pub api_key: String,
@@
 #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
+/// Configuration for SiliconFlow China endpoint.
 pub struct SiliconFlowCnProviderConfig {
     pub api_key: String,
@@
-pub struct SiliconFlow;
-pub struct SiliconFlowCn;
+/// SiliconFlow global provider definition.
+pub struct SiliconFlow;
+/// SiliconFlow China provider definition.
+pub struct SiliconFlowCn;
As per coding guidelines "`**/*.rs`: Use /// for doc comments on public items in Rust".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/gateway/providers/siliconflow.rs` around lines 31 - 55, Public items
IDENTIFIER, CN_IDENTIFIER, SiliconFlowProviderConfig,
SiliconFlowCnProviderConfig, SiliconFlow, and SiliconFlowCn lack /// doc
comments; add concise triple-slash documentation for each public constant,
struct, and the two provider structs (including short descriptions for fields
api_key and api_base) and for the marker types SiliconFlow and SiliconFlowCn so
the public API is documented; use /// on top of each item (e.g., above
IDENTIFIER, CN_IDENTIFIER, the SiliconFlowProviderConfig and
SiliconFlowCnProviderConfig definitions and their fields, and above the
SiliconFlow and SiliconFlowCn struct declarations) following existing project
style.
🤖 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/siliconflow.rs`:
- Around line 31-55: Public items IDENTIFIER, CN_IDENTIFIER,
SiliconFlowProviderConfig, SiliconFlowCnProviderConfig, SiliconFlow, and
SiliconFlowCn lack /// doc comments; add concise triple-slash documentation for
each public constant, struct, and the two provider structs (including short
descriptions for fields api_key and api_base) and for the marker types
SiliconFlow and SiliconFlowCn so the public API is documented; use /// on top of
each item (e.g., above IDENTIFIER, CN_IDENTIFIER, the SiliconFlowProviderConfig
and SiliconFlowCnProviderConfig definitions and their fields, and above the
SiliconFlow and SiliconFlowCn struct declarations) following existing project
style.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0e1de010-1405-42d0-b530-32f2542e1af9

📥 Commits

Reviewing files that changed from the base of the PR and between 24603e0 and 7387f48.

📒 Files selected for processing (11)
  • src/config/entities/providers-schema.json
  • src/config/entities/providers.rs
  • src/gateway/providers/mod.rs
  • src/gateway/providers/siliconflow.rs
  • src/proxy/provider.rs
  • ui/src/components/models/model-form.tsx
  • ui/src/components/providers/provider-form.tsx
  • ui/src/i18n/locales/en.json
  • ui/src/i18n/locales/zh-CN.json
  • ui/src/lib/api/types.ts
  • ui/src/routes/_layout/providers/index.tsx

@bzp2010 bzp2010 merged commit 8d9c7af into main May 4, 2026
3 checks passed
@bzp2010 bzp2010 deleted the bzp/feat-siliconflow-provider branch May 4, 2026 05:24
@coderabbitai coderabbitai Bot mentioned this pull request May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant