Skip to content
Draft
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ MGit是一款基于Python的Markdown笔记应用,结合了直观的编辑体

## 主要特点

- **AI Copilot写作助手**:集成SiliconFlow大语言模型,提供智能写作辅助
- **AI Copilot写作助手**:集成大语言模型,提供智能写作辅助
- **多提供商支持**:支持SiliconFlow和ModelScope API-Inference两种服务提供商
- **行内补全**:根据上下文智能生成续写内容
- **编辑模式**:根据指令优化和修改文本
- **创作模式**:从提示词生成完整文档
Expand Down
128 changes: 113 additions & 15 deletions docs/copilot_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,118 @@ Typically located at: `~/.config/mgit/config.json` or similar location depending

## Configuration Keys

### SiliconFlow Provider (Default)

```json
{
"copilot": {
"enabled": true,
"provider": "siliconflow",
"api_key": "your-siliconflow-api-key-here",
"model": "Qwen/Qwen2.5-7B-Instruct"
}
}
```

### ModelScope API-Inference Provider

```json
{
"copilot": {
"enabled": true,
"provider": "modelscope",
"api_key": "your-modelscope-api-key-here",
"model": "qwen/Qwen2.5-7B-Instruct"
}
}
```

## Providers

MGit Copilot now supports two LLM service providers:

### 1. SiliconFlow (Default)
- **Website**: https://siliconflow.cn
- **API Documentation**: https://docs.siliconflow.cn
- **Features**: Fast inference, multiple models, competitive pricing
- **Provider ID**: `siliconflow`

### 2. ModelScope API-Inference (New!)
- **Website**: https://www.modelscope.cn
- **API Documentation**: https://www.modelscope.cn/docs/model-service/API-Inference/intro
- **Features**: Official Alibaba Cloud service, reliable infrastructure
- **Provider ID**: `modelscope`

## Available Models

### SiliconFlow Models

You can use any of these models with SiliconFlow:

### Qwen Series (Recommended)
#### Qwen Series (Recommended)
- `Qwen/Qwen2.5-7B-Instruct` - Best balance of speed and quality (default)
- `Qwen/Qwen2.5-14B-Instruct` - Higher quality, slightly slower
- `Qwen/Qwen2.5-32B-Instruct` - Highest quality, slower

### DeepSeek
#### DeepSeek
- `deepseek-ai/DeepSeek-V2.5` - Strong reasoning, good for technical content

### Meta LLaMA
#### Meta LLaMA
- `meta-llama/Meta-Llama-3.1-8B-Instruct` - Open source alternative

### ModelScope API-Inference Models

Available models with ModelScope:

#### Qwen Series
- `qwen/Qwen2.5-7B-Instruct` - Best balance of speed and quality (default)
- `qwen/Qwen2.5-14B-Instruct` - Higher quality
- `qwen/Qwen2.5-32B-Instruct` - Highest quality

**Note**: Model names use lowercase namespace with ModelScope (e.g., `qwen/` instead of `Qwen/`)

## Getting API Key

### For SiliconFlow

1. Visit https://siliconflow.cn
2. Register or login to your account
3. Navigate to API Keys section
4. Create a new API key
5. Copy the key to Copilot settings in MGit

### For ModelScope

1. Visit https://www.modelscope.cn
2. Register or login with your Alibaba Cloud account
3. Navigate to the API-Inference section
4. Create a new API key
5. Copy the key to Copilot settings in MGit

## Configuration via UI

The recommended way to configure Copilot is through the UI:

1. Open MGit
2. Go to menu: `Copilot > Copilot设置`
3. Enter your API key
4. Select your preferred model
5. Check "启用 Copilot"
6. Click "测试连接" to verify
7. Click "保存"
3. Select your preferred provider (SiliconFlow or ModelScope)
4. Enter your API key
5. Select your preferred model
6. Check "启用 Copilot"
7. Click "测试连接" to verify
8. Click "保存"

## Switching Between Providers

You can switch between SiliconFlow and ModelScope at any time:

1. Open Copilot settings
2. Select different provider from dropdown
3. Enter the API key for the new provider
4. Select an appropriate model for that provider
5. Test connection and save

**Note**: Each provider requires its own API key. Make sure to obtain and configure API keys for both providers if you plan to switch between them.

## Security Notes

Expand All @@ -65,29 +133,52 @@ The recommended way to configure Copilot is through the UI:

You can also set API key via environment variable:

### For SiliconFlow
```bash
export SILICONFLOW_API_KEY="your-api-key-here"
```

### For ModelScope
```bash
export MODELSCOPE_API_KEY="your-api-key-here"
```

Note: UI configuration takes precedence over environment variables.

## Troubleshooting

### API Key Not Working
- Verify key is correct (no extra spaces)
- Check account balance on SiliconFlow
- Check account balance on your provider's website
- Ensure network connectivity
- Try "测试连接" in settings dialog
- Verify you're using the correct API key for the selected provider

### Model Not Available
- Some models may require specific API tier
- Check SiliconFlow documentation for model availability
- Some models may require specific API tier or region
- Check provider documentation for model availability
- Try using default model first
- For ModelScope: Ensure model name uses correct case (lowercase namespace)
- For SiliconFlow: Ensure model name uses correct case (uppercase namespace)

### Connection Timeout
- Check internet connection
- Verify firewall settings
- Try increasing timeout in code if needed
- Some regions may have slower access to certain providers

### Provider-Specific Issues

#### SiliconFlow
- Check status at https://siliconflow.cn
- Verify API tier and quotas
- Review rate limits

#### ModelScope
- Check Alibaba Cloud account status
- Verify API-Inference service is enabled
- Review service quotas and limits
- Check region availability

## Advanced Configuration

Expand All @@ -99,15 +190,22 @@ For advanced users, you can modify additional parameters by editing the source c

## Rate Limits

Be aware of SiliconFlow API rate limits:
Be aware of API rate limits from your provider:

### SiliconFlow
- Free tier: Limited requests per minute
- Paid tiers: Higher limits
- Check your plan at https://siliconflow.cn

Check your plan at https://siliconflow.cn
### ModelScope API-Inference
- Limits depend on your Alibaba Cloud account tier
- Check quotas in your ModelScope console
- Visit https://www.modelscope.cn for details

## Support

For issues or questions:
- Check the [Copilot Guide](./copilot_guide.md)
- Submit GitHub issue
- Contact SiliconFlow support for API issues
- Submit GitHub issue for MGit-related problems
- Contact SiliconFlow support for SiliconFlow API issues
- Contact Alibaba Cloud support for ModelScope API issues
41 changes: 33 additions & 8 deletions docs/copilot_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,29 @@ MGit Copilot 是一个专注于写作的AI助手,集成了最新的大语言

### 1. 配置API密钥

MGit Copilot 支持两种大模型服务提供商:

#### 选项1: SiliconFlow (默认)
1. 访问 [SiliconFlow官网](https://siliconflow.cn) 注册账号并获取API密钥
2. 在MGit中打开 `Copilot > Copilot设置`
3. 输入API密钥
4. 选择模型(推荐使用 Qwen/Qwen2.5-7B-Instruct)
5. 勾选"启用Copilot"
6. 点击"测试连接"验证配置
7. 点击"保存"
3. 选择 "SiliconFlow" 作为提供商
4. 输入API密钥
5. 选择模型(推荐使用 Qwen/Qwen2.5-7B-Instruct)
6. 勾选"启用Copilot"
7. 点击"测试连接"验证配置
8. 点击"保存"

#### 选项2: ModelScope API-Inference (新增!)
1. 访问 [ModelScope官网](https://www.modelscope.cn) 注册账号并获取API密钥
2. 在MGit中打开 `Copilot > Copilot设置`
3. 选择 "ModelScope" 作为提供商
4. 输入API密钥
5. 选择模型(推荐使用 qwen/Qwen2.5-7B-Instruct)
6. 勾选"启用Copilot"
7. 点击"测试连接"验证配置
8. 点击"保存"

**注意**: 两个提供商的模型名称格式略有不同(ModelScope使用小写命名空间)

### 2. 显示Copilot面板

Expand Down Expand Up @@ -208,8 +224,9 @@ MGit Copilot 是一个专注于写作的AI助手,集成了最新的大语言
**A**:
1. 检查API密钥是否正确
2. 确认网络连接正常
3. 验证SiliconFlow账户余额
4. 查看错误信息,按提示操作
3. 验证服务提供商账户余额(SiliconFlow或ModelScope)
4. 确保选择的提供商与API密钥匹配
5. 查看错误信息,按提示操作

### Q: 生成的内容质量不理想?

Expand Down Expand Up @@ -253,12 +270,20 @@ MGit Copilot 是一个专注于写作的AI助手,集成了最新的大语言
## 技术支持

- **文档**: 参考本指南和项目README
- **配置指南**: [Copilot配置文档](./copilot_config.md)
- **问题反馈**: 提交GitHub Issue
- **功能建议**: 通过PR或Issue提出
- **API文档**: https://docs.siliconflow.cn
- **SiliconFlow API文档**: https://docs.siliconflow.cn
- **ModelScope API文档**: https://www.modelscope.cn/docs/model-service/API-Inference/intro

## 更新日志

### Version 1.1.0 (2026-01-07)

- 新增ModelScope API-Inference服务提供商支持
- 支持在SiliconFlow和ModelScope之间切换
- 更新配置文档,详细说明两个提供商的使用

### Version 1.0.0 (2026-01-03)

- 初始版本发布
Expand Down
Loading