From 252ca8ef7b1e08cd75b77bd6c10cd077b5437153 Mon Sep 17 00:00:00 2001
From: yrk111222 <2493404415@qq.com>
Date: Thu, 28 Aug 2025 12:37:54 +0800
Subject: [PATCH] feat: modelscope provider (#493)
---
README.md | 1 +
.../pages/settings/providers/modelscope.vue | 107 ++++++++++++++++++
.../pages/settings/providers/modelscope.vue | 107 ++++++++++++++++++
docs/README.ja-JP.md | 1 +
docs/README.zh-CN.md | 1 +
packages/i18n/src/locales/en/settings.yaml | 3 +
packages/i18n/src/locales/es/settings.yaml | 3 +
.../i18n/src/locales/zh-Hans/settings.yaml | 3 +
.../Dialogs/Onboarding/Onboarding.vue | 1 +
packages/stage-ui/src/stores/providers.ts | 44 +++++++
10 files changed, 271 insertions(+)
create mode 100644 apps/stage-tamagotchi/src/pages/settings/providers/modelscope.vue
create mode 100644 apps/stage-web/src/pages/settings/providers/modelscope.vue
diff --git a/README.md b/README.md
index bfff44398..d87994e4f 100644
--- a/README.md
+++ b/README.md
@@ -207,6 +207,7 @@ npx bumpp --no-commit --no-tag
- [x] [Baichuan](https://platform.baichuan-ai.com)
- [x] [Minimax](https://api.minimax.chat/)
- [x] [Moonshot AI](https://platform.moonshot.cn/)
+- [x] [ModelScope](https://modelscope.cn/docs/model-service/API-Inference/intro)
- [x] [Player2](https://player2.game/)
- [x] [Tencent Cloud](https://cloud.tencent.com/document/product/1729)
- [ ] [Sparks](https://www.xfyun.cn/doc/spark/Web.html) (PR welcome)
diff --git a/apps/stage-tamagotchi/src/pages/settings/providers/modelscope.vue b/apps/stage-tamagotchi/src/pages/settings/providers/modelscope.vue
new file mode 100644
index 000000000..208c4e1ef
--- /dev/null
+++ b/apps/stage-tamagotchi/src/pages/settings/providers/modelscope.vue
@@ -0,0 +1,107 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ meta:
+ layout: settings
+ stageTransition:
+ name: slide
+
diff --git a/apps/stage-web/src/pages/settings/providers/modelscope.vue b/apps/stage-web/src/pages/settings/providers/modelscope.vue
new file mode 100644
index 000000000..208c4e1ef
--- /dev/null
+++ b/apps/stage-web/src/pages/settings/providers/modelscope.vue
@@ -0,0 +1,107 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ meta:
+ layout: settings
+ stageTransition:
+ name: slide
+
diff --git a/docs/README.ja-JP.md b/docs/README.ja-JP.md
index 6666058f7..26b4a240f 100644
--- a/docs/README.ja-JP.md
+++ b/docs/README.ja-JP.md
@@ -182,6 +182,7 @@ pnpm dev:docs
- [x] [Baichuan](https://platform.baichuan-ai.com)
- [x] [Minimax](https://api.minimax.chat/)
- [x] [Moonshot AI](https://platform.moonshot.cn/)
+- [x] [ModelScope](https://modelscope.cn/docs/model-service/API-Inference/intro)
- [x] [Player2](https://player2.game/)
- [x] [Tencent Cloud](https://cloud.tencent.com/document/product/1729)
- [ ] [Sparks](https://www.xfyun.cn/doc/spark/Web.html)(PR歓迎)
diff --git a/docs/README.zh-CN.md b/docs/README.zh-CN.md
index 27e61e589..e5cd90940 100644
--- a/docs/README.zh-CN.md
+++ b/docs/README.zh-CN.md
@@ -174,6 +174,7 @@ pnpm -F @proj-airi/docs dev
- [x] [百川](https://platform.baichuan-ai.com)
- [x] [Minimax](https://api.minimax.chat/)
- [x] [月之暗面](https://platform.moonshot.cn/)
+- [x] [魔搭社区](https://modelscope.cn/docs/model-service/API-Inference/intro)
- [x] [Player2](https://player2.game/)
- [x] [腾讯混元](https://cloud.tencent.com/document/product/1729)
- [ ] [讯飞星火](https://www.xfyun.cn/doc/spark/Web.html)
diff --git a/packages/i18n/src/locales/en/settings.yaml b/packages/i18n/src/locales/en/settings.yaml
index 004040738..517105f0d 100644
--- a/packages/i18n/src/locales/en/settings.yaml
+++ b/packages/i18n/src/locales/en/settings.yaml
@@ -406,6 +406,9 @@ pages:
moonshot:
description: moonshot.ai
title: Moonshot AI
+ modelscope:
+ description: modelscope.cn
+ title: ModelScope
novita:
description: novita.ai
title: Novita
diff --git a/packages/i18n/src/locales/es/settings.yaml b/packages/i18n/src/locales/es/settings.yaml
index c077c33a1..dc0620ff7 100644
--- a/packages/i18n/src/locales/es/settings.yaml
+++ b/packages/i18n/src/locales/es/settings.yaml
@@ -403,6 +403,9 @@ pages:
moonshot:
description: moonshot.ai
title: Moonshot AI
+ modelscope:
+ description: modelscope.cn
+ title: ModelScope
novita:
description: novita.ai
title: Novita
diff --git a/packages/i18n/src/locales/zh-Hans/settings.yaml b/packages/i18n/src/locales/zh-Hans/settings.yaml
index bf1f8b9d9..dce87df2b 100644
--- a/packages/i18n/src/locales/zh-Hans/settings.yaml
+++ b/packages/i18n/src/locales/zh-Hans/settings.yaml
@@ -375,6 +375,9 @@ pages:
moonshot:
description: Moonshot.ai
title: 月之暗面
+ modelscope:
+ description: modelscope.cn
+ title: 魔搭社区 ModelScope
novita:
description: novita.ai
title: Novita
diff --git a/packages/stage-ui/src/components/Scenarios/Dialogs/Onboarding/Onboarding.vue b/packages/stage-ui/src/components/Scenarios/Dialogs/Onboarding/Onboarding.vue
index 34a8bca5a..ac6f44827 100644
--- a/packages/stage-ui/src/components/Scenarios/Dialogs/Onboarding/Onboarding.vue
+++ b/packages/stage-ui/src/components/Scenarios/Dialogs/Onboarding/Onboarding.vue
@@ -119,6 +119,7 @@ function getApiKeyPlaceholder(_providerId: string): string {
'together-ai': 'togetherapi-...',
'mistral-ai': 'mis-...',
'moonshot-ai': 'ms-...',
+ 'modelscope': 'ms-...',
'fireworks-ai': 'fw-...',
'featherless-ai': 'fw-...',
'novita-ai': 'nvt-...',
diff --git a/packages/stage-ui/src/stores/providers.ts b/packages/stage-ui/src/stores/providers.ts
index 72873b061..8e62e13dc 100644
--- a/packages/stage-ui/src/stores/providers.ts
+++ b/packages/stage-ui/src/stores/providers.ts
@@ -2140,6 +2140,50 @@ export const useProvidersStore = defineStore('providers', () => {
},
},
},
+ 'modelscope': {
+ id: 'modelscope',
+ category: 'chat',
+ tasks: ['text-generation'],
+ nameKey: 'settings.pages.providers.provider.modelscope.title',
+ name: 'ModelScope',
+ descriptionKey: 'settings.pages.providers.provider.modelscope.description',
+ description: 'modelscope',
+ icon: 'i-lobe-icons:modelscope',
+ defaultOptions: () => ({
+ baseUrl: 'https://api-inference.modelscope.cn/v1/',
+ }),
+ createProvider: async config => createOpenAI((config.apiKey as string).trim(), (config.baseUrl as string).trim()),
+ capabilities: {
+ listModels: async (config) => {
+ return (await listModels({
+ ...createOpenAI((config.apiKey as string).trim(), (config.baseUrl as string).trim()).model(),
+ })).map((model) => {
+ return {
+ id: model.id,
+ name: model.id,
+ provider: 'modelscope',
+ description: '',
+ contextLength: 0,
+ deprecated: false,
+ } satisfies ModelInfo
+ })
+ },
+ },
+ validators: {
+ validateProviderConfig: (config) => {
+ const errors = [
+ !config.apiKey && new Error('API key is required.'),
+ !config.baseUrl && new Error('Base URL is required.'),
+ ].filter(Boolean)
+
+ return {
+ errors,
+ reason: errors.filter(e => e).map(e => String(e)).join(', ') || '',
+ valid: !!config.apiKey && !!config.baseUrl,
+ }
+ },
+ },
+ },
'player2': {
id: 'player2',
category: 'chat',