-
-
Notifications
You must be signed in to change notification settings - Fork 13.8k
✨ feat: Support ModelScope Provider #8026
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
56767d8
feat: support modelscop
hedeqiang 5719613
feat: support modelscop
hedeqiang cf6e906
style: update llm.ts
hedeqiang a218542
Merge branch 'main' into modelscope
hedeqiang f750f84
Merge branch 'main' into modelscope
hedeqiang 9c110e8
style: update modelscope
hedeqiang da93ca5
Merge branch 'main' into modelscope
hedeqiang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 使用情况 | ||
- 部分高级模型可能需要付费使用 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
hedeqiang marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.