Skip to content

Add Huawei Cloud MaaS provider #2415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add Huawei Cloud MaaS provider #2415

wants to merge 1 commit into from

Conversation

ddling
Copy link

@ddling ddling commented Jun 26, 2025

Description

Add Huawei Cloud MaaS as a new provider

https://console.huaweicloud.com/modelarts/?agencyId=5e8a9ac3d8b1455caa394e38e9225136&region=cn-southwest-2&locale=zh-cn#/model-studio/square

Get Apikey address:
https://console.huaweicloud.com/modelarts/?agencyId=5e8a9ac3d8b1455caa394e38e9225136&region=cn-southwest-2&locale=zh-cn#/model-studio/authmanage

Additional Notes

Screenshots

image

Contributor Agreement

By submitting this Pull Request, I confirm that I have read and agree to the following terms:

  • I agree to contribute all code submitted in this PR to the open-source community edition licensed under GPLv3 and the proprietary official edition without compensation.
  • I grant the official edition development team the rights to freely use, modify, and distribute this code, including for commercial purposes.
  • I confirm that this code is my original work, or I have obtained the appropriate authorization from the copyright holder to submit this code under these terms.
  • I understand that the submitted code will be publicly released under the GPLv3 license, and may also be used in the proprietary official edition.

Please check the box below to confirm:

[ ] I have read and agree with the above statement.

Summary by CodeRabbit

  • New Features

    • Added support for HuaweiCloudMaaS as a new AI model provider.
    • Users can now select and configure HuaweiCloudMaaS models, including DeepSeek and 千问 series, for chat and image generation.
    • Model capabilities such as reasoning and tool use are now available for supported HuaweiCloudMaaS models.
  • Chores

    • Updated provider lists and settings to include HuaweiCloudMaaS as an option.

Copy link
Contributor

coderabbitai bot commented Jun 26, 2025

Walkthrough

Support for HuaweiCloudMaaS as a new AI model provider is introduced. This includes updating type definitions, default provider settings, model instantiation logic, a dedicated model class, and utility classes for model settings. The integration enables selection, configuration, and usage of HuaweiCloudMaaS models within the application.

Changes

File(s) Change Summary
src/shared/types.ts Added HuaweiCloudMaaS to the ModelProviderEnum.
src/shared/defaults.ts Added HuaweiCloudMaaS to SystemProviders with default settings and model definitions.
src/renderer/packages/models/huaweicloud-maas.ts Introduced HuaweiCloudMaaS model class with configuration, helper methods, and fallback model listing.
src/renderer/packages/models/index.ts Added logic to instantiate HuaweiCloudMaaS in the getModel function.
src/renderer/packages/model-setting-utils/huaweicloud-maas-setting-util.ts Added HuaweiCloudMAASSettingUtil class for provider-specific model setting utilities.
src/renderer/packages/model-setting-utils/index.ts Registered HuaweiCloudMAASSettingUtil in the model setting utility factory.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant ModelSettingUtil
    participant HuaweiCloudMAASSettingUtil
    participant HuaweiCloudMaaS

    User->>App: Selects HuaweiCloudMaaS as provider
    App->>ModelSettingUtil: getModelSettingUtil(HuaweiCloudMaaS)
    ModelSettingUtil->>HuaweiCloudMAASSettingUtil: Instantiate
    App->>HuaweiCloudMAASSettingUtil: getLocalOptionGroups()
    HuaweiCloudMAASSettingUtil-->>App: Return grouped model options

    App->>HuaweiCloudMaaS: Instantiate with settings
    App->>HuaweiCloudMaaS: listModels()
    HuaweiCloudMaaS-->>App: Return available models (remote or fallback)
Loading

Poem

In fields of code, a cloud appears,
Huawei joins with bunny cheers!
New models hop into the mix,
Settings, helpers, clever tricks.
Now with options wide and vast,
This fluffy update’s built to last.
🐇☁️✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-26T10_02_21_991Z-debug-0.log

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ddling
Copy link
Author

ddling commented Jun 26, 2025

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jun 26, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@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: 1

🧹 Nitpick comments (3)
src/renderer/packages/model-setting-utils/huaweicloud-maas-setting-util.ts (1)

51-53: Stub implementation may need enhancement.

The listProviderModels method returns an empty array. Consider implementing actual model fetching or document why this is intentionally empty.

If remote model fetching is intended, consider implementing it similar to the HuaweiCloudMaaS class's listModels method, or document why returning an empty array is the intended behavior.

src/renderer/packages/models/huaweicloud-maas.ts (2)

8-21: Verify vision support and ensure language consistency in comments.

Two concerns with the helper functions:

  1. Vision support always returns false without explanation - verify if HuaweiCloudMaaS truly has no vision-capable models
  2. Mixed language comments (Chinese) may not align with codebase standards

Consider adding English translations or using consistent comment language:

  isModelSupportVision: (model: string) => {
-    // HuaweiCloudMaaS支持视觉的模型
+    // HuaweiCloudMaaS models that support vision (currently none)
    return false
  },
  isModelSupportToolUse: (model: string) => {
-    // HuaweiCloudMaaS支持工具使用的模型(除了纯图像生成和推理专用模型)
+    // HuaweiCloudMaaS models that support tool use (excluding image generation and reasoning-only models)
    const nonToolModels = [

83-93: Consider making fallback models configurable and improve error logging.

The hardcoded fallback model list should ideally be configurable, and error logging could be more informative for debugging.

  public async listModels(): Promise<string[]> {
    return fetchRemoteModels({
      apiHost: this.options.apiHost,
      apiKey: this.options.apiKey,
      useProxy: this.options.useProxy,
    }).catch((err) => {
-      console.error('HuaweiCloudMaaS models fetch error:', err)
+      console.error('HuaweiCloudMaaS models fetch error:', {
+        error: err.message,
+        apiHost: this.options.apiHost,
+        hasApiKey: !!this.options.apiKey
+      })
-      // 返回HuaweiCloudMaaS支持的常见模型作为备选
+      // Return commonly supported HuaweiCloudMaaS models as fallback
      return [
        'deepseek-r1-250528',
        'DeepSeek-V3',
        'DeepSeek-R1',
        'qwen3-235b-a22b',
        'qwen3-32b'
      ]
    })
  }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e6ebabe and 660f29d.

⛔ Files ignored due to path filters (1)
  • src/renderer/static/icons/providers/huaweicloud-maas.png is excluded by !**/*.png
📒 Files selected for processing (6)
  • src/renderer/packages/model-setting-utils/huaweicloud-maas-setting-util.ts (1 hunks)
  • src/renderer/packages/model-setting-utils/index.ts (2 hunks)
  • src/renderer/packages/models/huaweicloud-maas.ts (1 hunks)
  • src/renderer/packages/models/index.ts (2 hunks)
  • src/shared/defaults.ts (1 hunks)
  • src/shared/types.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
src/renderer/packages/model-setting-utils/index.ts (1)
src/renderer/packages/model-setting-utils/huaweicloud-maas-setting-util.ts (1)
  • HuaweiCloudMAASSettingUtil (6-62)
src/renderer/packages/models/index.ts (1)
src/renderer/packages/models/huaweicloud-maas.ts (1)
  • HuaweiCloudMaaS (32-95)
src/renderer/packages/model-setting-utils/huaweicloud-maas-setting-util.ts (3)
src/renderer/packages/model-setting-utils/interface.ts (1)
  • ModelSettingUtil (3-14)
src/shared/types.ts (3)
  • ModelProvider (235-235)
  • SessionType (121-121)
  • ProviderSettings (267-280)
src/renderer/packages/models/huaweicloud-maas.ts (1)
  • HuaweiCloudMaaS (32-95)
🔇 Additional comments (12)
src/shared/types.ts (1)

233-233: LGTM! Enum addition follows conventions.

The new HuaweiCloudMaaS provider entry follows the established naming pattern and enables type-safe usage throughout the codebase.

src/renderer/packages/model-setting-utils/index.ts (2)

19-19: LGTM! Import follows established pattern.

The import statement correctly adds the new HuaweiCloudMAASSettingUtil class.


37-37: LGTM! Factory mapping is correctly implemented.

The mapping entry properly associates the HuaweiCloudMaaS provider with its setting utility class, maintaining consistency with other providers.

src/renderer/packages/models/index.ts (1)

19-19: LGTM! Import is correctly added.

The import statement properly adds the HuaweiCloudMaaS model class.

src/shared/defaults.ts (1)

595-629: LGTM! Comprehensive provider configuration.

The HuaweiCloudMaaS provider configuration is well-structured and complete:

  • Correctly uses OpenAI-compatible type for integration
  • Provides appropriate default API host
  • Includes comprehensive model definitions with capabilities and context windows
  • Follows the established pattern used by other providers

The model list covers both DeepSeek and Qwen series with proper capability annotations.

src/renderer/packages/model-setting-utils/huaweicloud-maas-setting-util.ts (4)

6-8: LGTM! Class structure is correctly implemented.

The class properly extends BaseConfig and implements the ModelSettingUtil interface with the correct provider assignment.


9-15: LGTM! Display name formatting is appropriate.

The method correctly formats the display name and handles optional nickname fallback from provider settings.


55-61: LGTM! Capability checks properly delegate to helpers.

The capability check methods correctly delegate to the HuaweiCloudMaaS helper functions for consistent behavior.


17-49: Model list inconsistency with defaults.

The local option groups define only 3 DeepSeek models and 2 Qwen models, but src/shared/defaults.ts (lines 601-627) defines 5 models total. The lists should be consistent to avoid confusion.

Update the model lists to match the defaults configuration:

const deepseekModels = [
  'deepseek-r1-250528',
  'DeepSeek-V3',
- 'DeepSeek-R1'
+ 'DeepSeek-R1',
]

const qwenModels = [
  'qwen3-235b-a22b',
  'qwen3-32b'
]

Actually, looking at the defaults, all 5 models are present. The grouping is correct - no changes needed, but ensure the model IDs exactly match those in defaults.ts.

Likely an incorrect or invalid review comment.

src/renderer/packages/models/huaweicloud-maas.ts (3)

32-43: LGTM! Constructor properly handles default API host.

The constructor correctly sets up default configuration and calls the parent constructor appropriately.


49-56: LGTM! Provider creation follows OpenAI-compatible pattern.

The provider setup correctly uses the OpenAI-compatible SDK with proper configuration including conditional proxy support.


66-69: ```shell
#!/bin/bash
echo "=== huaweicloud-maas-setting-util.ts ==="
sed -n '1,200p' src/renderer/packages/model-setting-utils/huaweicloud-maas-setting-util.ts
echo
echo "=== huaweicloud-maas.ts ==="
sed -n '1,200p' src/renderer/packages/models/huaweicloud-maas.ts


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment on lines +130 to +137
case ModelProviderEnum.HuaweiCloudMaaS:
return new HuaweiCloudMaaS({
apiKey: providerSetting.apiKey || '',
apiHost: formattedApiHost,
model,
temperature: setting.temperature,
topP: setting.topP,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Model instantiation is correct but missing UI mappings.

The model instantiation follows the established pattern and uses appropriate constructor parameters. However, HuaweiCloudMaaS is missing from both aiProviderNameHash (lines 195-211) and AIModelProviderMenuOptionList (lines 213-285), which are likely used for UI display purposes.

Add the missing entries to enable proper UI display:

export const aiProviderNameHash: Record<ModelProvider, string> = {
  [ModelProviderEnum.OpenAI]: 'OpenAI API',
  [ModelProviderEnum.Azure]: 'Azure OpenAI API',
  [ModelProviderEnum.ChatGLM6B]: 'ChatGLM API',
  [ModelProviderEnum.ChatboxAI]: 'Chatbox AI',
  [ModelProviderEnum.Claude]: 'Claude API',
  [ModelProviderEnum.Gemini]: 'Google Gemini API',
  [ModelProviderEnum.Ollama]: 'Ollama API',
  [ModelProviderEnum.Groq]: 'Groq API',
  [ModelProviderEnum.DeepSeek]: 'DeepSeek API',
  [ModelProviderEnum.SiliconFlow]: 'SiliconFlow API',
  [ModelProviderEnum.VolcEngine]: 'VolcEngine API',
  [ModelProviderEnum.LMStudio]: 'LM Studio API',
  [ModelProviderEnum.Perplexity]: 'Perplexity API',
  [ModelProviderEnum.XAI]: 'xAI API',
+ [ModelProviderEnum.HuaweiCloudMaaS]: 'HuaweiCloudMaaS API',
  [ModelProviderEnum.Custom]: 'Custom Provider',
}

And add to the menu options list:

export const AIModelProviderMenuOptionList = [
  // ... existing entries ...
  {
    value: ModelProviderEnum.ChatGLM6B,
    label: aiProviderNameHash[ModelProviderEnum.ChatGLM6B],
    disabled: false,
  },
+ {
+   value: ModelProviderEnum.HuaweiCloudMaaS,
+   label: aiProviderNameHash[ModelProviderEnum.HuaweiCloudMaaS],
+   disabled: false,
+ },
]
🤖 Prompt for AI Agents
In src/renderer/packages/models/index.ts around lines 130 to 137, the
HuaweiCloudMaaS model is instantiated correctly but is missing from the
aiProviderNameHash mapping (lines 195-211) and the AIModelProviderMenuOptionList
array (lines 213-285). To fix this, add an entry for HuaweiCloudMaaS in
aiProviderNameHash with the appropriate display name and icon, and also add a
corresponding menu option object for HuaweiCloudMaaS in
AIModelProviderMenuOptionList to ensure it appears properly in the UI.

@ddling
Copy link
Author

ddling commented Jun 26, 2025

@wong2 can you help to review

@ddling
Copy link
Author

ddling commented Jun 27, 2025

@Bin-Huang help to review

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