04db423416
- 70 skills with code and documentation - Add .gitignore (ignore __pycache__, output/, temp/, venv/) - Clean up test intermediates and caches
291 lines
7.0 KiB
Markdown
291 lines
7.0 KiB
Markdown
---
|
||
name: llm-hub
|
||
description: LLM资源中心。管理多供应商大模型API、本地Ollama模型、额度监控、自动切换配置。当用户需要查询模型、切换API、管理额度时使用此技能。
|
||
---
|
||
|
||
# LLM Hub - 大模型资源管理中心
|
||
|
||
## 概述
|
||
|
||
此技能用于统一管理多供应商的大模型API和本地Ollama模型,提供额度监控、自动切换、账号管理等功能。
|
||
|
||
## 触发场景
|
||
|
||
当用户提及以下内容时激活此技能:
|
||
- "查一下额度"、"看看各平台剩余"
|
||
- "切换模型"、"换一个API"
|
||
- "本地有什么模型"、"Ollama在跑什么"
|
||
- "帮我注册"、"申请新账号"
|
||
- "API配置"、"模型对比"
|
||
|
||
## 功能模块
|
||
|
||
### 1. 模型发现
|
||
|
||
#### 本地模型(Ollama)
|
||
|
||
```bash
|
||
# 列出本地模型
|
||
ollama list
|
||
|
||
# 查看运行状态
|
||
ollama ps
|
||
|
||
# 拉取模型
|
||
ollama pull <model-name>
|
||
```
|
||
|
||
**配置文件位置**: `%USERPROFILE%\.ollama\models`
|
||
|
||
#### 云端模型
|
||
|
||
支持的供应商和免费额度:
|
||
|
||
| 供应商 | 特点 | 推荐模型 | API端点 |
|
||
|-------|------|---------|---------|
|
||
| **火山方舟** | Coding Plan ¥7.9/月 | doubao-seed-2.0-pro, doubao-seed-code (视觉) | `https://ark.cn-beijing.volces.com/api/coding/v3` |
|
||
| DeepSeek | 价格屠夫 | deepseek-v3, deepseek-coder | `https://api.deepseek.com/v1` |
|
||
| Groq | 免费额度充足 | mixtral-8x7b-32768, llama-3.1-70b | `https://api.groq.com/openai/v1` |
|
||
| OpenRouter | 有限免费 | deepseek/deepseek-r1 | `https://openrouter.ai/api/v1` |
|
||
|
||
### 2. 额度监控
|
||
|
||
#### 检查各平台额度
|
||
|
||
```bash
|
||
# 火山方舟 - 通过API查询
|
||
curl -H "Authorization: Bearer $VOLCENGINE_API_KEY" \
|
||
https://ark.cn-beijing.volces.com/api/coding/v3/usage
|
||
|
||
# OpenRouter - 通过API查询
|
||
curl -H "Authorization: Bearer $OPENROUTER_API_KEY" \
|
||
https://openrouter.ai/api/v1/credits
|
||
|
||
# DeepSeek - 通过API查询
|
||
curl -H "Authorization: Bearer $DEEPSEEK_API_KEY" \
|
||
https://api.deepseek.com/v1/remaining_quota
|
||
```
|
||
|
||
#### 额度记录
|
||
|
||
每次使用后更新 `references/usage_records.md`,记录:
|
||
- 日期时间
|
||
- 供应商
|
||
- 模型
|
||
- 消耗token数
|
||
- 剩余额度
|
||
|
||
### 3. 自动切换配置
|
||
|
||
#### 配置文件
|
||
|
||
配置文件: `config/providers.json`
|
||
|
||
```json
|
||
{
|
||
"providers": [
|
||
{
|
||
"name": "volcengine",
|
||
"priority": 1,
|
||
"api_key_env": "VOLCENGINE_API_KEY",
|
||
"base_url": "https://ark.cn-beijing.volces.com/api/coding/v3",
|
||
"models": ["doubao-seed-2.0-pro", "doubao-seed-code"],
|
||
"enabled": true
|
||
},
|
||
{
|
||
"name": "deepseek",
|
||
"priority": 2,
|
||
"api_key_env": "DEEPSEEK_API_KEY",
|
||
"base_url": "https://api.deepseek.com/v1",
|
||
"models": ["deepseek-v3", "deepseek-coder"],
|
||
"enabled": true
|
||
},
|
||
{
|
||
"name": "groq",
|
||
"priority": 3,
|
||
"api_key_env": "GROQ_API_KEY",
|
||
"base_url": "https://api.groq.com/openai/v1",
|
||
"models": ["mixtral-8x7b-32768", "llama-3.1-70b"],
|
||
"enabled": true
|
||
}
|
||
],
|
||
"current_provider": "volcengine",
|
||
"fallback_enabled": true
|
||
}
|
||
```
|
||
|
||
#### 切换逻辑
|
||
|
||
当检测到当前供应商额度不足或API报错时:
|
||
1. 自动切换到下一个可用的provider
|
||
2. 记录切换事件到日志
|
||
3. 发送通知(可选)
|
||
|
||
### 4. 账号管理
|
||
|
||
#### 火山方舟账号
|
||
|
||
当前使用火山方舟 Coding Plan:
|
||
|
||
```bash
|
||
VOLCENGINE_API_KEY=b0359bed-09f2-49e2-a53c-32ba057412e3
|
||
```
|
||
|
||
**账号记录**: `references/accounts.md`
|
||
|
||
| 账号 | API Key | 套餐 | 状态 |
|
||
|-----|---------|------|------|
|
||
| Coding Plan | b0359...412e3 | ¥7.9/月 | 正常 |
|
||
|
||
#### 新账号注册指引
|
||
|
||
**火山方舟 Coding Plan**:
|
||
1. 访问 https://console.volcengine.com/ark/
|
||
2. 注册/登录账号
|
||
3. 开通 Coding Plan 套餐
|
||
4. 获取 API Key
|
||
|
||
### 5. 模型对比
|
||
|
||
| 场景 | 推荐模型 | 原因 |
|
||
|-----|---------|------|
|
||
| 代码生成 | doubao-seed-code, deepseek-coder | 专用模型 |
|
||
| 中文对话 | doubao-pro, deepseek-v3 | 中文优化 |
|
||
| 快速响应 | groq+mixtral, llama-3.1-8b | 延迟低 |
|
||
| 多模态/视觉 | doubao-seed-code | Coding Plan唯一视觉模型 |
|
||
| 免费优先 | groq, openrouter免费层 | 成本最低 |
|
||
|
||
## 使用流程
|
||
|
||
### 首次使用
|
||
|
||
1. 配置环境变量(见下方)
|
||
2. 运行 `python scripts/init_config.py` 初始化配置
|
||
3. 查询各平台额度:`python scripts/check_quotas.py`
|
||
|
||
### 日常使用
|
||
|
||
1. 查询额度: "帮我查一下各平台额度"
|
||
2. 切换模型: "切换到Groq"
|
||
3. 添加账号: "添加一个新的阿里云账号"
|
||
|
||
## 环境变量配置
|
||
|
||
在系统环境变量或 `.env` 文件中配置:
|
||
|
||
```bash
|
||
# 火山方舟 (Coding Plan)
|
||
VOLCENGINE_API_KEY=b0359bed-09f2-49e2-a53c-32ba057412e3
|
||
|
||
# DeepSeek
|
||
DEEPSEEK_API_KEY=sk-xxx
|
||
|
||
# Groq
|
||
GROQ_API_KEY=gsk_xxx
|
||
|
||
# OpenRouter
|
||
OPENROUTER_API_KEY=sk-xxx
|
||
```
|
||
|
||
## OpenCode 配置
|
||
|
||
要在 OpenCode 的 /models 中添加火山方舟:
|
||
|
||
### 方法1:使用环境变量
|
||
|
||
```bash
|
||
# 在系统环境变量中设置
|
||
VOLCENGINE_API_KEY=b0359bed-09f2-49e2-a53c-32ba057412e3
|
||
```
|
||
|
||
### 方法2:配置文件(推荐)
|
||
|
||
火山方舟已在 `~/.config/opencode/config.json` 中配置:
|
||
|
||
```jsonc
|
||
{
|
||
"provider": {
|
||
"volcengine": {
|
||
"npm": "@ai-sdk/openai-compatible",
|
||
"options": {
|
||
"baseURL": "https://ark.cn-beijing.volces.com/api/coding/v3",
|
||
"apiKey": "b0359bed-09f2-49e2-a53c-32ba057412e3"
|
||
},
|
||
"models": {
|
||
"doubao-seed-2.0-pro": {},
|
||
"doubao-seed-2.0-code": {},
|
||
"doubao-seed-2.0-lite": {},
|
||
"doubao-seed-code": {}
|
||
}
|
||
},
|
||
"deepseek": {
|
||
"npm": "@ai-sdk/openai-compatible",
|
||
"options": {
|
||
"baseURL": "https://api.deepseek.com/v1"
|
||
},
|
||
"models": {
|
||
"deepseek-chat": {},
|
||
"deepseek-coder": {}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
### 配置步骤
|
||
|
||
1. 创建/编辑配置文件:
|
||
```bash
|
||
# Windows
|
||
notepad %USERPROFILE%\.config\opencode\opencode.json
|
||
|
||
# 或用 VS Code
|
||
code %USERPROFILE%\.config\opencode\opencode.json
|
||
```
|
||
|
||
2. 添加 API Key(两种方式):
|
||
|
||
**方式A:写到配置里(不安全)**
|
||
```jsonc
|
||
{
|
||
"provider": {
|
||
"dashscope": {
|
||
"options": {
|
||
"apiKey": "sk-56a8e427c3f7403a90e2cf22f1b9d842"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
**方式B:用环境变量(推荐)**
|
||
- 设置系统环境变量 `DASHSCOPE_API_KEY`
|
||
|
||
3. 重启 OpenCode,运行 `/models` 刷新模型列表
|
||
|
||
## 文件结构
|
||
|
||
```
|
||
llm-hub/
|
||
├── SKILL.md # 本文件
|
||
├── config/
|
||
│ └── providers.json # 供应商配置
|
||
├── references/
|
||
│ ├── usage_records.md # 使用记录
|
||
│ ├── accounts.md # 账号管理
|
||
│ └── model_comparison.md # 模型对比表
|
||
├── scripts/
|
||
│ ├── check_quotas.py # 查询额度
|
||
│ ├── switch_provider.py # 切换供应商
|
||
│ ├── add_account.py # 添加账号
|
||
│ └── init_config.py # 初始化配置
|
||
└── .env.example # 环境变量示例
|
||
```
|
||
|
||
## 注意事项
|
||
|
||
1. **火山方舟 Coding Plan** - 主要供应商,视觉模型用 `doubao-seed-code`
|
||
2. API Key 安全 - 不要提交到Git
|
||
3. 额度告警 - 低于10%时提醒切换
|
||
4. 轮询机制 - 多个账号时轮换使用
|