Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ ENV \
MINIMAX_API_KEY="" MINIMAX_MODEL_LIST="" \
# Mistral
MISTRAL_API_KEY="" MISTRAL_MODEL_LIST="" \
# ModelScope
MODELSCOPE_API_KEY="" MODELSCOPE_MODEL_LIST="" MODELSCOPE_PROXY_URL="" \
# Moonshot
MOONSHOT_API_KEY="" MOONSHOT_MODEL_LIST="" MOONSHOT_PROXY_URL="" \
# Novita
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile.database
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ ENV \
MINIMAX_API_KEY="" MINIMAX_MODEL_LIST="" \
# Mistral
MISTRAL_API_KEY="" MISTRAL_MODEL_LIST="" \
# ModelScope
MODELSCOPE_API_KEY="" MODELSCOPE_MODEL_LIST="" MODELSCOPE_PROXY_URL="" \
# Moonshot
MOONSHOT_API_KEY="" MOONSHOT_MODEL_LIST="" MOONSHOT_PROXY_URL="" \
# Novita
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile.pglite
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ ENV \
MINIMAX_API_KEY="" MINIMAX_MODEL_LIST="" \
# Mistral
MISTRAL_API_KEY="" MISTRAL_MODEL_LIST="" \
# ModelScope
MODELSCOPE_API_KEY="" MODELSCOPE_MODEL_LIST="" MODELSCOPE_PROXY_URL="" \
# Moonshot
MOONSHOT_API_KEY="" MOONSHOT_MODEL_LIST="" MOONSHOT_PROXY_URL="" \
# Novita
Expand Down
113 changes: 113 additions & 0 deletions docs/usage/providers/modelscope.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
title: ModelScope Provider Setup
description: Learn how to configure and use ModelScope provider in LobeChat
tags:
- ModelScope
---

# ModelScope Provider Setup

ModelScope (魔塔社区) is Alibaba's open-source model community that provides access to various AI models. This guide will help you set up the ModelScope provider in LobeChat.

## Prerequisites

Before using ModelScope API, you need to:

1. **Create a ModelScope Account**
- Visit [ModelScope](https://www.modelscope.cn/)
- Register for an account

2. **Bind Alibaba Cloud Account**
- **Important**: ModelScope API requires binding with an Alibaba Cloud account
- Visit your [ModelScope Access Token page](https://www.modelscope.cn/my/myaccesstoken)
- Follow the instructions to bind your Alibaba Cloud account
- This step is mandatory for API access

3. **Get API Token**
- After binding your Alibaba Cloud account, generate an API token
- Copy the token for use in LobeChat

## Configuration

### Environment Variables

Add the following environment variables to your `.env` file:

```bash
# Enable ModelScope provider
ENABLED_MODELSCOPE=1

# ModelScope API key (required)
MODELSCOPE_API_KEY=your_modelscope_api_token

# Optional: Custom model list (comma-separated)
MODELSCOPE_MODEL_LIST=deepseek-ai/DeepSeek-V3-0324,Qwen/Qwen3-235B-A22B

# Optional: Proxy URL if needed
MODELSCOPE_PROXY_URL=https://your-proxy-url
```

### Docker Configuration

If using Docker, add the ModelScope environment variables to your `docker-compose.yml`:

```yaml
environment:
- ENABLED_MODELSCOPE=1
- MODELSCOPE_API_KEY=your_modelscope_api_token
- MODELSCOPE_MODEL_LIST=deepseek-ai/DeepSeek-V3-0324,Qwen/Qwen3-235B-A22B
```

## Available Models

ModelScope provides access to various models including:

- **DeepSeek Models**: DeepSeek-V3, DeepSeek-R1 series
- **Qwen Models**: Qwen3 series, Qwen2.5 series
- **Llama Models**: Meta-Llama-3 series
- **Other Models**: Various open-source models

## Troubleshooting

### Common Issues

1. **"Please bind your Alibaba Cloud account before use" Error**
- This means you haven't bound your Alibaba Cloud account to ModelScope
- Visit [ModelScope Access Token page](https://www.modelscope.cn/my/myaccesstoken)
- Complete the Alibaba Cloud account binding process

2. **401 Authentication Error**
- Check if your API token is correct
- Ensure the token hasn't expired
- Verify that your Alibaba Cloud account is properly bound

3. **Model Not Available**
- Some models may require additional permissions
- Check the model's page on ModelScope for access requirements

### Debug Mode

Enable debug mode to see detailed logs:

```bash
DEBUG_MODELSCOPE_CHAT_COMPLETION=1
```

## Notes

- ModelScope API is compatible with OpenAI API format
- The service is primarily designed for users in China
- Some models may have usage limitations or require additional verification
- API responses are in Chinese by default for some models

## Support

For ModelScope-specific issues:

- Visit [ModelScope Documentation](https://www.modelscope.cn/docs)
- Check [ModelScope Community](https://www.modelscope.cn/community)

For LobeChat integration issues:

- Check our [GitHub Issues](https://github.com/lobehub/lobe-chat/issues)
- Join our community discussions
133 changes: 133 additions & 0 deletions docs/usage/providers/modelscope.zh-CN.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
title: ModelScope 提供商配置
description: 学习如何在 LobeChat 中配置和使用 ModelScope 提供商
tags:
- ModelScope
---

# ModelScope 提供商配置

ModelScope(魔塔社区)是阿里巴巴的开源模型社区,提供各种 AI 模型的访问服务。本指南将帮助您在 LobeChat 中设置 ModelScope 提供商。

## 前置条件

在使用 ModelScope API 之前,您需要:

1. **创建 ModelScope 账户**
- 访问 [ModelScope](https://www.modelscope.cn/)
- 注册账户

2. **绑定阿里云账户**
- **重要**:ModelScope API 需要绑定阿里云账户
- 访问您的 [ModelScope 访问令牌页面](https://www.modelscope.cn/my/myaccesstoken)
- 按照说明绑定您的阿里云账户
- 此步骤是 API 访问的必要条件

3. **获取 API 令牌**
- 绑定阿里云账户后,生成 API 令牌
- 复制令牌以在 LobeChat 中使用

## 配置

### 环境变量

在您的 `.env` 文件中添加以下环境变量:

```bash
# 启用 ModelScope 提供商
ENABLED_MODELSCOPE=1

# ModelScope API 密钥(必需)
MODELSCOPE_API_KEY=your_modelscope_api_token

# 可选:自定义模型列表(逗号分隔)
MODELSCOPE_MODEL_LIST=deepseek-ai/DeepSeek-V3-0324,Qwen/Qwen3-235B-A22B

# 可选:代理 URL(如需要)
MODELSCOPE_PROXY_URL=https://your-proxy-url
```

### Docker 配置

如果使用 Docker,请在您的 `docker-compose.yml` 中添加 ModelScope 环境变量:

```yaml
environment:
- ENABLED_MODELSCOPE=1
- MODELSCOPE_API_KEY=your_modelscope_api_token
- MODELSCOPE_MODEL_LIST=deepseek-ai/DeepSeek-V3-0324,Qwen/Qwen3-235B-A22B
```

## 可用模型

ModelScope 提供各种模型的访问,包括:

- **DeepSeek 模型**:DeepSeek-V3、DeepSeek-R1 系列
- **Qwen 模型**:Qwen3 系列、Qwen2.5 系列
- **Llama 模型**:Meta-Llama-3 系列
- **其他模型**:各种开源模型

## 故障排除

### 常见问题

1. **"请先绑定阿里云账户后使用" 错误**
- 这意味着您还没有将阿里云账户绑定到 ModelScope
- 访问 [ModelScope 访问令牌页面](https://www.modelscope.cn/my/myaccesstoken)
- 完成阿里云账户绑定流程

2. **401 认证错误**
- 检查您的 API 令牌是否正确
- 确保令牌没有过期
- 验证您的阿里云账户是否正确绑定

3. **模型不可用**
- 某些模型可能需要额外权限
- 查看 ModelScope 上模型页面的访问要求

### 调试模式

启用调试模式以查看详细日志:

```bash
DEBUG_MODELSCOPE_CHAT_COMPLETION=1
```

## 注意事项

- ModelScope API 与 OpenAI API 格式兼容
- 该服务主要面向中国用户设计
- 某些模型可能有使用限制或需要额外验证
- 某些模型的 API 响应默认为中文

## 支持

对于 ModelScope 特定问题:

- 访问 [ModelScope 文档](https://www.modelscope.cn/docs)
- 查看 [ModelScope 社区](https://www.modelscope.cn/community)

对于 LobeChat 集成问题:

- 查看我们的 [GitHub Issues](https://github.com/lobehub/lobe-chat/issues)
- 加入我们的社区讨论

## 模型 ID 格式

ModelScope 使用命名空间前缀格式的模型 ID,例如:

```
deepseek-ai/DeepSeek-V3-0324
deepseek-ai/DeepSeek-R1-0528
Qwen/Qwen3-235B-A22B
Qwen/Qwen3-32B
```

在配置模型列表时,请使用完整的模型 ID 格式。

## API 限制

- ModelScope API 有速率限制
- 某些模型可能需要特殊权限
- 建议在生产环境中监控 API 使用情况
- 部分高级模型可能需要付费使用
3 changes: 3 additions & 0 deletions src/config/aiModels/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { default as jina } from './jina';
import { default as lmstudio } from './lmstudio';
import { default as minimax } from './minimax';
import { default as mistral } from './mistral';
import { default as modelscope } from './modelscope';
import { default as moonshot } from './moonshot';
import { default as novita } from './novita';
import { default as nvidia } from './nvidia';
Expand Down Expand Up @@ -97,6 +98,7 @@ export const LOBE_DEFAULT_MODEL_LIST = buildDefaultModelList({
lmstudio,
minimax,
mistral,
modelscope,
moonshot,
novita,
nvidia,
Expand Down Expand Up @@ -151,6 +153,7 @@ export { default as jina } from './jina';
export { default as lmstudio } from './lmstudio';
export { default as minimax } from './minimax';
export { default as mistral } from './mistral';
export { default as modelscope } from './modelscope';
export { default as moonshot } from './moonshot';
export { default as novita } from './novita';
export { default as nvidia } from './nvidia';
Expand Down
63 changes: 63 additions & 0 deletions src/config/aiModels/modelscope.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { AIChatModelCard } from '@/types/aiModel';

const modelscopeChatModels: AIChatModelCard[] = [
{
abilities: {
functionCall: true,
},
contextWindowTokens: 131_072,
description: 'DeepSeek-V3是DeepSeek第三代模型,在多项基准测试中表现优异。',
displayName: 'DeepSeek-V3-0324',
enabled: true,
id: 'deepseek-ai/DeepSeek-V3-0324',
type: 'chat',
},
{
abilities: {
functionCall: true,
},
contextWindowTokens: 131_072,
description: 'DeepSeek-V3是DeepSeek第三代模型的最新版本,具有强大的推理和对话能力。',
displayName: 'DeepSeek-V3',
enabled: true,
id: 'deepseek-ai/DeepSeek-V3',
type: 'chat',
},
{
abilities: {
functionCall: true,
},
contextWindowTokens: 131_072,
description: 'DeepSeek-R1是DeepSeek最新的推理模型,专注于复杂推理任务。',
displayName: 'DeepSeek-R1',
enabled: true,
id: 'deepseek-ai/DeepSeek-R1',
type: 'chat',
},
{
abilities: {
functionCall: true,
},
contextWindowTokens: 131_072,
description: 'Qwen3-235B-A22B是通义千问3代超大规模模型,提供顶级的AI能力。',
displayName: 'Qwen3-235B-A22B',
enabled: true,
id: 'Qwen/Qwen3-235B-A22B',
type: 'chat',
},
{
abilities: {
functionCall: true,
},
contextWindowTokens: 131_072,
description: 'Qwen3-32B是通义千问3代模型,具有强大的推理和对话能力。',
displayName: 'Qwen3-32B',
enabled: true,
id: 'Qwen/Qwen3-32B',
type: 'chat',
},
];

export const allModels = [...modelscopeChatModels];

export default allModels;
6 changes: 6 additions & 0 deletions src/config/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ export const getLLMConfig = () => {

ENABLED_INFINIAI: z.boolean(),
INFINIAI_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 @@ -322,6 +325,9 @@ export const getLLMConfig = () => {

ENABLED_INFINIAI: !!process.env.INFINIAI_API_KEY,
INFINIAI_API_KEY: process.env.INFINIAI_API_KEY,

ENABLED_MODELSCOPE: !!process.env.MODELSCOPE_API_KEY,
MODELSCOPE_API_KEY: process.env.MODELSCOPE_API_KEY,
},
});
};
Expand Down
Loading
Loading