-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughSupport 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
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)
Poem
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
npm error Exit handler never called! ✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this 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:
- Vision support always returns
false
without explanation - verify if HuaweiCloudMaaS truly has no vision-capable models- 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
⛔ 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 -->
case ModelProviderEnum.HuaweiCloudMaaS: | ||
return new HuaweiCloudMaaS({ | ||
apiKey: providerSetting.apiKey || '', | ||
apiHost: formattedApiHost, | ||
model, | ||
temperature: setting.temperature, | ||
topP: setting.topP, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@wong2 can you help to review |
@Bin-Huang help to review |
Description
Add Huawei Cloud MaaS as a new provider
https://console.huaweicloud.com/modelarts/?agencyId=5e8a9ac3d8b1455caa394e38e9225136®ion=cn-southwest-2&locale=zh-cn#/model-studio/square
Get Apikey address:
https://console.huaweicloud.com/modelarts/?agencyId=5e8a9ac3d8b1455caa394e38e9225136®ion=cn-southwest-2&locale=zh-cn#/model-studio/authmanage
Additional Notes
Screenshots
Contributor Agreement
By submitting this Pull Request, I confirm that I have read and agree to the following terms:
Please check the box below to confirm:
[ ] I have read and agree with the above statement.
Summary by CodeRabbit
New Features
Chores