Skip to content

feat(provider): add modelscope#81

Merged
bzp2010 merged 1 commit into
mainfrom
bzp/feat-modelscope-provider
May 4, 2026
Merged

feat(provider): add modelscope#81
bzp2010 merged 1 commit into
mainfrom
bzp/feat-modelscope-provider

Conversation

@bzp2010
Copy link
Copy Markdown
Collaborator

@bzp2010 bzp2010 commented May 4, 2026

Summary by CodeRabbit

  • New Features
    • Added ModelScope and ModelScope (CN) as new provider options for OpenAI-compatible API integration.
    • Configurable API keys and custom API base URLs for both providers.
    • Complete UI support with localization in English and Chinese.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

📝 Walkthrough

Walkthrough

This PR adds support for two new OpenAI-compatible providers: ModelScope (global) and ModelScope (CN). Changes include schema updates, Rust configuration entities, a new provider module with metadata and authentication, proxy request handling, and UI translations and type definitions.

Changes

ModelScope Provider Addition

Layer / File(s) Summary
Schema Definition
src/config/entities/providers-schema.json
Provider type enum extended with modelscope and modelscope-cn; conditional routing both types to openai_compatible config schema.
Config Entities
src/config/entities/providers.rs
ProviderConfig enum gains ModelScope and ModelScopeCn variants mapped to their respective config types; provider_type() method extended to return identifiers for new variants. Schema validation tests added for both providers.
Provider Implementation
src/gateway/providers/modelscope.rs
New module defines provider identifiers, configuration structs (with api_key and optional api_base), and provider types implementing ProviderMeta for metadata/headers and ChatTransform/ProviderCapabilities traits. Includes tests for metadata, header construction, and request transformation.
Gateway Integration
src/gateway/providers/mod.rs
Module declaration and re-exports for new providers; identifiers added to identifiers namespace; provider configs included in configs re-exports; both providers registered in default_provider_registry() with test coverage.
Proxy Request Handling
src/proxy/provider.rs
provider_auth_and_base_url() function extended with match arms for both new variants to extract api_key and parse optional api_base into auth and URL. Unit tests added to verify auth and base URL handling for each variant.
UI Types and Translations
ui/src/lib/api/types.ts, ui/src/i18n/locales/en.json, ui/src/i18n/locales/zh-CN.json
PROVIDER_TYPE_VARIANTS extended with new literal types; Provider union gains new variants using ApiBaseProviderConfig. Translations added for both providers in English and Simplified Chinese locales; unrelated label fix for zhipuai provider in zh-CN.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • feat(provider): add groq #71: Adds a different provider following the same code-level integration pattern (schema enum, ProviderConfig variant, gateway provider module, proxy auth handling, UI types).
  • feat(provider): add azure openai #62: Adds a new provider with parallel code changes across schema, config entities, gateway providers, and proxy authentication layers.
  • feat(provider): add cohere #75: Adds another OpenAI-compatible provider using identical code paths (ProviderConfig enum, schema updates, gateway registry, proxy auth/base-url logic).
🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
E2e Test Quality Review ⚠️ Warning PR lacks end-to-end test coverage. Only unit tests exist for individual components; no tests validate complete business flow or external API interactions. Implement E2E tests validating full request/response cycles, error handling, schema validation, and UI integration with actual or properly mocked external dependencies.
✅ 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 modelscope' directly and clearly describes the main change: adding ModelScope provider support across the 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 PR adds ModelScope provider types following secure patterns used by existing providers. API keys properly encapsulated, HTTPS-enforced, credentials never logged.

✏️ 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-modelscope-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/modelscope.rs (1)

22-45: ⚡ Quick win

Add item-level rustdoc for newly exported provider symbols.

The new public constants/structs are exported but currently undocumented. Please add /// docs for IDENTIFIER, CN_IDENTIFIER, ModelScopeProviderConfig, ModelScopeCnProviderConfig, ModelScope, and ModelScopeCn.

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/modelscope.rs` around lines 22 - 45, Add item-level
Rust doc comments (use ///) for the exported symbols IDENTIFIER, CN_IDENTIFIER,
ModelScopeProviderConfig, ModelScopeCnProviderConfig, ModelScope, and
ModelScopeCn: put a short one-line description above each constant and type
explaining its purpose (e.g., IDENTIFIER and CN_IDENTIFIER are provider IDs for
default and China endpoints), document the struct purpose for
ModelScopeProviderConfig and ModelScopeCnProviderConfig and include docs on
their public fields (api_key: API key string; api_base: optional custom base
URL, mention the default base URLs DEFAULT_BASE_URL and DEFAULT_CN_BASE_URL),
and add brief docs for the marker structs ModelScope and ModelScopeCn indicating
they represent the respective providers. Ensure all comments use /// and appear
immediately above the corresponding item.
🤖 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/modelscope.rs`:
- Around line 22-45: Add item-level Rust doc comments (use ///) for the exported
symbols IDENTIFIER, CN_IDENTIFIER, ModelScopeProviderConfig,
ModelScopeCnProviderConfig, ModelScope, and ModelScopeCn: put a short one-line
description above each constant and type explaining its purpose (e.g.,
IDENTIFIER and CN_IDENTIFIER are provider IDs for default and China endpoints),
document the struct purpose for ModelScopeProviderConfig and
ModelScopeCnProviderConfig and include docs on their public fields (api_key: API
key string; api_base: optional custom base URL, mention the default base URLs
DEFAULT_BASE_URL and DEFAULT_CN_BASE_URL), and add brief docs for the marker
structs ModelScope and ModelScopeCn indicating they represent the respective
providers. Ensure all comments use /// and appear immediately above the
corresponding item.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 14ead145-4fa5-43da-a69e-fe77a03ceca1

📥 Commits

Reviewing files that changed from the base of the PR and between 4311ae9 and 82f42bc.

📒 Files selected for processing (8)
  • src/config/entities/providers-schema.json
  • src/config/entities/providers.rs
  • src/gateway/providers/mod.rs
  • src/gateway/providers/modelscope.rs
  • src/proxy/provider.rs
  • ui/src/i18n/locales/en.json
  • ui/src/i18n/locales/zh-CN.json
  • ui/src/lib/api/types.ts

@bzp2010 bzp2010 merged commit 24603e0 into main May 4, 2026
3 checks passed
@bzp2010 bzp2010 deleted the bzp/feat-modelscope-provider branch May 4, 2026 04:27
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