Skip to content

Commit

Permalink
✨ feat: add ModelScope as model provider
Browse files Browse the repository at this point in the history
  • Loading branch information
justmywyw committed Dec 31, 2024
1 parent 21b6610 commit 639b5e8
Show file tree
Hide file tree
Showing 28 changed files with 300 additions and 0 deletions.
7 changes: 7 additions & 0 deletions locales/ar/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"title": "رمز HuggingFace"
}
},
"modelscope": {
"accessToken": {
"desc": "أدخل رمز الوصول الخاص بك لـ ModelScope، انقر [هنا](https://www.modelscope.cn/my/myaccesstoken) للحصول عليه",
"placeholder": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"title": "رمز الوصول لـ ModelScope"
}
},
"ollama": {
"checker": {
"desc": "اختبر ما إذا تم إدخال عنوان الوكيل بشكل صحيح",
Expand Down
7 changes: 7 additions & 0 deletions locales/bg-BG/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"title": "HuggingFace токен"
}
},
"modelscope": {
"accessToken": {
"desc": "Въведете своя токен за достъп до ModelScope, кликнете [тук](https://www.modelscope.cn/my/myaccesstoken), за да го получите",
"placeholder": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"title": "Токен за достъп до ModelScope"
}
},
"ollama": {
"checker": {
"desc": "Тестване дали адресът на прокси е попълнен правилно",
Expand Down
7 changes: 7 additions & 0 deletions locales/de-DE/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"title": "HuggingFace-Token"
}
},
"modelscope": {
"accessToken": {
"desc": "Geben Sie Ihren ModelScope-Zugriffstoken ein. Klicken Sie [hier](https://www.modelscope.cn/my/myaccesstoken), um ihn zu erhalten.",
"placeholder": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"title": "ModelScope-Zugriffstoken"
}
},
"ollama": {
"checker": {
"desc": "Testen Sie, ob die Proxy-Adresse korrekt eingetragen wurde",
Expand Down
7 changes: 7 additions & 0 deletions locales/en-US/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"title": "HuggingFace Token"
}
},
"modelscope": {
"accessToken": {
"desc": "Enter your ModelScope access token, click [here](https://www.modelscope.cn/my/myaccesstoken) to obtain it",
"placeholder": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"title": "ModelScope Access Token"
}
},
"ollama": {
"checker": {
"desc": "Test if the proxy address is correctly filled in",
Expand Down
7 changes: 7 additions & 0 deletions locales/es-ES/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"title": "Token de HuggingFace"
}
},
"modelscope": {
"accessToken": {
"desc": "Enter your ModelScope access token, click [here](https://www.modelscope.cn/my/myaccesstoken) to obtain it",
"placeholder": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"title": "ModelScope Access Token"
}
},
"ollama": {
"checker": {
"desc": "Prueba si la dirección del proxy de la interfaz se ha introducido correctamente",
Expand Down
7 changes: 7 additions & 0 deletions locales/fa-IR/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"title": "توکن HuggingFace"
}
},
"modelscope": {
"accessToken": {
"desc": "توکن دسترسی ModelScope خود را وارد کنید، برای دریافت آن [اینجا](https://www.modelscope.cn/my/myaccesstoken) را کلیک کنید",
"placeholder": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"title": "توکن دسترسی ModelScope"
}
},
"ollama": {
"checker": {
"desc": "آزمایش کنید که آیا آدرس پروکسی به درستی وارد شده است",
Expand Down
7 changes: 7 additions & 0 deletions locales/fr-FR/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"title": "Jeton HuggingFace"
}
},
"modelscope": {
"accessToken": {
"desc": "Entrez votre jeton d'accès ModelScope, cliquez [ici](https://www.modelscope.cn/my/myaccesstoken) pour l'obtenir",
"placeholder": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"title": "Jeton d'accès ModelScope"
}
},
"ollama": {
"checker": {
"desc": "Vérifiez si l'adresse du proxy est correctement saisie",
Expand Down
7 changes: 7 additions & 0 deletions locales/it-IT/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"title": "Token HuggingFace"
}
},
"modelscope": {
"accessToken": {
"desc": "Inserisci il tuo token di accesso ModelScope, clicca [qui](https://www.modelscope.cn/my/myaccesstoken) per ottenerlo",
"placeholder": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"title": "Token di accesso ModelScope"
}
},
"ollama": {
"checker": {
"desc": "Verifica se l'indirizzo del proxy è stato compilato correttamente",
Expand Down
7 changes: 7 additions & 0 deletions locales/ja-JP/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"title": "HuggingFace トークン"
}
},
"modelscope": {
"accessToken": {
"desc": "ModelScope アクセストークンを入力してください。取得するには、[こちら](https://www.modelscope.cn/my/myaccesstoken) をクリックしてください",
"placeholder": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"title": "ModelScope アクセストークン"
}
},
"ollama": {
"checker": {
"desc": "プロキシアドレスが正しく入力されているかをテストします",
Expand Down
7 changes: 7 additions & 0 deletions locales/ko-KR/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"title": "HuggingFace 토큰"
}
},
"modelscope": {
"accessToken": {
"desc": "ModelScope 액세스 토큰을 입력하세요. 토큰을 얻으려면 [여기](https://www.modelscope.cn/my/myaccesstoken)를 클릭하세요",
"placeholder": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"title": "ModelScope 액세스 토큰"
}
},
"ollama": {
"checker": {
"desc": "프록시 주소가 올바르게 입력되었는지 테스트합니다",
Expand Down
7 changes: 7 additions & 0 deletions locales/nl-NL/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"title": "HuggingFace Token"
}
},
"modelscope": {
"accessToken": {
"desc": "Voer je ModelScope toegangstoken in, klik [hier](https://www.modelscope.cn/my/myaccesstoken) om het te verkrijgen",
"placeholder": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"title": "ModelScope Toegangstoken"
}
},
"ollama": {
"checker": {
"desc": "Test of het proxyadres correct is ingevuld",
Expand Down
7 changes: 7 additions & 0 deletions locales/pl-PL/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"title": "Token HuggingFace"
}
},
"modelscope": {
"accessToken": {
"desc": "Wprowadź swój token dostępu ModelScope, kliknij [tutaj](https://www.modelscope.cn/my/myaccesstoken), aby uzyskać",
"placeholder": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"title": "Token dostępu ModelScope"
}
},
"ollama": {
"checker": {
"desc": "Test czy adres proxy jest poprawnie wypełniony",
Expand Down
7 changes: 7 additions & 0 deletions locales/pt-BR/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"title": "Token do HuggingFace"
}
},
"modelscope": {
"accessToken": {
"desc": "Insira seu token de acesso do ModelScope, clique [aqui](https://www.modelscope.cn/my/myaccesstoken) para obter",
"placeholder": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"title": "Token de Acesso do ModelScope"
}
},
"ollama": {
"checker": {
"desc": "Teste se o endereço do proxy está corretamente preenchido",
Expand Down
7 changes: 7 additions & 0 deletions locales/ru-RU/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"title": "Токен HuggingFace"
}
},
"modelscope": {
"accessToken": {
"desc": "Введите токен доступа ModelScope, нажмите [здесь](https://www.modelscope.cn/my/myaccesstoken), чтобы получить",
"placeholder": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"title": "Токен доступа ModelScope"
}
},
"ollama": {
"checker": {
"desc": "Проверить правильность адреса прокси",
Expand Down
7 changes: 7 additions & 0 deletions locales/tr-TR/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"title": "HuggingFace Token"
}
},
"modelscope": {
"accessToken": {
"desc": "ModelScope erişim belirtecini girin, almak için [buraya](https://www.modelscope.cn/my/myaccesstoken) tıklayın",
"placeholder": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"title": "ModelScope Erişim Belirteci"
}
},
"ollama": {
"checker": {
"desc": "Proxy adresinin doğru girilip girilmediğini test edin",
Expand Down
7 changes: 7 additions & 0 deletions locales/vi-VN/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"title": "Mã thông báo HuggingFace"
}
},
"modelscope": {
"accessToken": {
"desc": "Nhập mã thông báo truy cập ModelScope của bạn, nhấp vào [đây](https://www.modelscope.cn/my/myaccesstoken) để lấy",
"placeholder": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"title": "Mã thông báo truy cập ModelScope"
}
},
"ollama": {
"checker": {
"desc": "Kiểm tra địa chỉ proxy có được nhập chính xác không",
Expand Down
7 changes: 7 additions & 0 deletions locales/zh-CN/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"title": "HuggingFace Token"
}
},
"modelscope": {
"accessToken": {
"desc": "填入你的 ModelScope 访问令牌,点击 [这里](https://www.modelscope.cn/my/myaccesstoken) 获取",
"placeholder": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"title": "ModelScope 访问令牌"
}
},
"ollama": {
"checker": {
"desc": "测试代理地址是否正确填写",
Expand Down
7 changes: 7 additions & 0 deletions locales/zh-TW/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
"title": "HuggingFace Token"
}
},
"modelscope": {
"accessToken": {
"desc": "填入你的 ModelScope 訪問令牌,點擊 [這裡](https://www.modelscope.cn/my/myaccesstoken) 獲取",
"placeholder": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"title": "ModelScope 訪問令牌"
}
},
"ollama": {
"checker": {
"desc": "測試代理地址是否正確填寫",
Expand Down
53 changes: 53 additions & 0 deletions src/app/(main)/settings/llm/ProviderList/ModelScope/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
'use client';

import { Markdown } from '@lobehub/ui';
import { Input } from 'antd';
import { createStyles } from 'antd-style';
import { useTranslation } from 'react-i18next';

import { ModelScopeProviderCard } from '@/config/modelProviders';
import { GlobalLLMProviderKey } from '@/types/user/settings';

import { KeyVaultsConfigKey, LLMProviderApiTokenKey } from '../../const';
import { ProviderItem } from '../../type';

const useStyles = createStyles(({ css, token }) => ({
markdown: css`
p {
color: ${token.colorTextDescription} !important;
}
`,
tip: css`
font-size: 12px;
color: ${token.colorTextDescription};
`,
}));

const providerKey: GlobalLLMProviderKey = 'modelscope';

// Same as OpenAIProvider, but replace API Key with ModelScope Access Token
export const useModelScopeProvider = (): ProviderItem => {
const { t } = useTranslation('modelProvider');
const { styles } = useStyles();

return {
...ModelScopeProviderCard,
apiKeyItems: [
{
children: (
<Input.Password
autoComplete={'new-password'}
placeholder={t(`${providerKey}.accessToken.placeholder`)}
/>
),
desc: (
<Markdown className={styles.markdown} fontSize={12} variant={'chat'}>
{t(`${providerKey}.accessToken.desc`)}
</Markdown>
),
label: t(`${providerKey}.accessToken.title`),
name: [KeyVaultsConfigKey, providerKey, LLMProviderApiTokenKey],
},
],
};
};
5 changes: 5 additions & 0 deletions src/app/(main)/settings/llm/ProviderList/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
InternLMProviderCard,
MinimaxProviderCard,
MistralProviderCard,
ModelScopeProviderCard,
MoonshotProviderCard,
NovitaProviderCard,
OpenRouterProviderCard,
Expand All @@ -38,6 +39,7 @@ import { useBedrockProvider } from './Bedrock';
import { useCloudflareProvider } from './Cloudflare';
import { useGithubProvider } from './Github';
import { useHuggingFaceProvider } from './HuggingFace';
import { useModelScopeProvider } from './ModelScope';
import { useOllamaProvider } from './Ollama';
import { useOpenAIProvider } from './OpenAI';
import { useWenxinProvider } from './Wenxin';
Expand All @@ -51,6 +53,7 @@ export const useProviderList = (): ProviderItem[] => {
const GithubProvider = useGithubProvider();
const HuggingFaceProvider = useHuggingFaceProvider();
const WenxinProvider = useWenxinProvider();
const ModelScopeProvider = useModelScopeProvider();

return useMemo(
() => [
Expand Down Expand Up @@ -91,6 +94,7 @@ export const useProviderList = (): ProviderItem[] => {
SiliconCloudProviderCard,
HigressProviderCard,
GiteeAIProviderCard,
ModelScopeProviderCard,
],
[
AzureProvider,
Expand All @@ -101,6 +105,7 @@ export const useProviderList = (): ProviderItem[] => {
GithubProvider,
WenxinProvider,
HuggingFaceProvider,
ModelScopeProvider,
],
);
};
6 changes: 6 additions & 0 deletions src/config/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ export const getLLMConfig = () => {

ENABLED_HIGRESS: z.boolean(),
HIGRESS_API_KEY: z.string().optional(),

ENABLED_MODELSCOPE: z.boolean(),
MODELSCOPE_API_KEY: z.string().optional(),
},
runtimeEnv: {
API_KEY_SELECT_MODE: process.env.API_KEY_SELECT_MODE,
Expand Down Expand Up @@ -244,6 +247,9 @@ export const getLLMConfig = () => {

ENABLED_HIGRESS: !!process.env.HIGRESS_API_KEY,
HIGRESS_API_KEY: process.env.HIGRESS_API_KEY,

ENABLED_MODELSCOPE: !!process.env.MODELSCOPE_API_KEY,
MODELSCOPE_API_KEY: process.env.MODELSCOPE_API_KEY,
},
});
};
Expand Down
4 changes: 4 additions & 0 deletions src/config/modelProviders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import HunyuanProvider from './hunyuan';
import InternLMProvider from './internlm';
import MinimaxProvider from './minimax';
import MistralProvider from './mistral';
import ModelScopeProvider from './modelscope';
import MoonshotProvider from './moonshot';
import NovitaProvider from './novita';
import OllamaProvider from './ollama';
Expand Down Expand Up @@ -49,6 +50,7 @@ export const LOBE_DEFAULT_MODEL_LIST: ChatModelCard[] = [
GithubProvider.chatModels,
MinimaxProvider.chatModels,
MistralProvider.chatModels,
ModelScopeProvider.chatModels,
MoonshotProvider.chatModels,
OllamaProvider.chatModels,
OpenRouterProvider.chatModels,
Expand Down Expand Up @@ -106,6 +108,7 @@ export const DEFAULT_MODEL_PROVIDER_LIST = [
ZeroOneProvider,
SenseNovaProvider,
StepfunProvider,
ModelScopeProvider,
MoonshotProvider,
BaichuanProvider,
MinimaxProvider,
Expand Down Expand Up @@ -145,6 +148,7 @@ export { default as HunyuanProviderCard } from './hunyuan';
export { default as InternLMProviderCard } from './internlm';
export { default as MinimaxProviderCard } from './minimax';
export { default as MistralProviderCard } from './mistral';
export { default as ModelScopeProviderCard } from './modelscope';
export { default as MoonshotProviderCard } from './moonshot';
export { default as NovitaProviderCard } from './novita';
export { default as OllamaProviderCard } from './ollama';
Expand Down
Loading

0 comments on commit 639b5e8

Please sign in to comment.