Skip to content

feat(provider): add moonshot#77

Merged
bzp2010 merged 2 commits into
mainfrom
bzp/feat-moonshot-provider
May 3, 2026
Merged

feat(provider): add moonshot#77
bzp2010 merged 2 commits into
mainfrom
bzp/feat-moonshot-provider

Conversation

@bzp2010
Copy link
Copy Markdown
Collaborator

@bzp2010 bzp2010 commented May 3, 2026

Summary by CodeRabbit

  • New Features
    • Added support for Moonshot AI ("moonshotai") and Moonshot AI CN ("moonshotai-cn") providers with OpenAI-compatible APIs.
    • Both providers use API-key authentication and optionally accept custom base URLs.
    • Providers are selectable in the UI (English and Simplified Chinese labels added).
    • Includes model-specific request handling and validation for improved compatibility.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f4d15afe-4b94-4323-95fc-235a6866d62d

📥 Commits

Reviewing files that changed from the base of the PR and between e01a2ad and 4b70bd7.

📒 Files selected for processing (2)
  • ui/src/i18n/locales/en.json
  • ui/src/i18n/locales/zh-CN.json
✅ Files skipped from review due to trivial changes (2)
  • ui/src/i18n/locales/zh-CN.json
  • ui/src/i18n/locales/en.json

📝 Walkthrough

Walkthrough

Adds Moonshot AI providers (moonshotai, moonshotai-cn) across schema, config types, gateway provider implementation (OpenAI-compatible request transform and validation), proxy auth/base-url routing, UI types, and localization strings.

Changes

Moonshot AI Provider Support

Layer / File(s) Summary
Schema / API types
src/config/entities/providers-schema.json, ui/src/lib/api/types.ts
Top-level provider type enum gains "moonshotai" and "moonshotai-cn". Conditional mapping routes these types to the openai_compatible config schema. TypeScript PROVIDER_TYPE_VARIANTS and Provider union include both variants with ApiBaseProviderConfig.
ProviderConfig & Config structs
src/config/entities/providers.rs, src/gateway/providers/moonshot.rs
ProviderConfig adds MoonshotAi and MoonshotAiCn serde-tagged variants. New provider config structs include api_key and optional api_base. Schema validation tests updated to include both variants.
Provider implementation
src/gateway/providers/moonshot.rs
Introduces provider module with IDENTIFIER / CN identifier, ProviderMeta and ChatTransform implementations, auth header builder, request transform pipeline that serializes requests, converts legacy functions/function_calltools/tool_choice, validates tool_choice, applies model-specific sampling-field removal for kimi-k2.6/kimi-k2.5, and enforces numeric constraints (temperature, top_p, n). Unit tests cover metadata, auth, legacy conversions, model quirks, and validations.
Registry & proxy wiring
src/gateway/providers/mod.rs, src/proxy/provider.rs
Exports new moonshot module and re-exports provider types/configs; adds MOONSHOT_AI and MOONSHOT_AI_CN identifiers; registers both providers in the default registry; proxy routing maps both variants to ProviderAuth::ApiKey and parses optional api_base. Tests added for registry and proxy auth/base-url behavior.
UI localization
ui/src/i18n/locales/en.json, ui/src/i18n/locales/zh-CN.json
Added English and Chinese display strings for moonshotai and moonshotai-cn in model/provider selection and provider-type lists.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
E2e Test Quality Review ⚠️ Warning PR adds Moonshot AI provider support with comprehensive unit tests but lacks E2E tests covering the full business flow and actual HTTP interactions. Add integration tests exercising complete provider flow with mock HTTP servers to simulate Moonshot API responses, error scenarios, and validate full request-response journey.
✅ 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 moonshot' clearly and concisely summarizes the main change: adding Moonshot AI 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 The PR adds Moonshot AI provider support following established codebase patterns with proper API key handling and no credential exposure in logs or test code.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bzp/feat-moonshot-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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ui/src/i18n/locales/en.json`:
- Around line 157-158: Update the label text for the "moonshotai-cn" locale key
so it is identical across all usages in the file: locate every "moonshotai-cn"
entry (including the other occurrence noted later in the file) and change its
value to the chosen canonical string "Moonshot AI (CN)" (or vice versa if your
project prefers no parentheses—ensure both occurrences match exactly).

In `@ui/src/i18n/locales/zh-CN.json`:
- Around line 157-158: Two entries for the same concept use inconsistent CN
label values; make the "moonshotai-cn" key consistent by updating both
occurrences of "moonshotai-cn" (and the related "moonshotai" pair if present) so
they share the identical string value (e.g., change the other instance to
"Moonshot AI (CN)" to match the first or vice versa) ensuring both keys
"moonshotai" and "moonshotai-cn" use the same CN label format across the file.
🪄 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: aad00d0e-a42f-48dd-9848-ebb7142dd0c2

📥 Commits

Reviewing files that changed from the base of the PR and between e4c5cfa and e01a2ad.

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

Comment thread ui/src/i18n/locales/en.json
Comment thread ui/src/i18n/locales/zh-CN.json
@bzp2010 bzp2010 merged commit 72d76ff into main May 3, 2026
3 checks passed
@bzp2010 bzp2010 deleted the bzp/feat-moonshot-provider branch May 3, 2026 10:52
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