mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-17 11:07:11 +08:00
feat(web): manage multiple custom (OpenAI-compatible) providers in console UI
Adds first-class support for configuring more than one custom OpenAI-compatible provider (e.g. SiliconFlow, DeepSeek, local vLLM) and switching the active one from the web console, addressing #2838. Backend: - config: new `custom_providers` (list) and `custom_active_provider` fields, fully backward compatible with the legacy single `open_ai_api_base`/`model` fields (used as fallback). - models/custom_provider.py: centralized resolver `resolve_custom_credentials()` returning (api_key, api_base, model), with active-provider selection and graceful fallback. - chat_gpt_bot.py wired to use the resolver. - web_channel.py: `_provider_overview` expands `custom_providers` into one card per provider (id `custom:<name>`, active flag, masked key); new POST actions `set_custom_provider`, `delete_custom_provider`, `set_active_custom_provider` with hermetic persistence + bridge reset. Frontend: - console.js: dedicated "Custom providers" section with add / edit / delete / set-active actions, masked-key keep-existing handling, and ~20 new zh/en i18n strings. - chat.html: custom provider modal. Tests: - tests/test_custom_provider.py (11) - resolver/config behavior. - tests/test_custom_provider_handlers.py (18) - write-side handlers and overview expansion, including duplicate-name rejection. All 29 unit tests pass.
This commit is contained in:
@@ -60,3 +60,37 @@ description: 自定义厂商配置,适用于第三方 API 代理和本地模
|
||||
```
|
||||
/config model qwen3.5:27b
|
||||
```
|
||||
|
||||
## 配置多个自定义厂商
|
||||
|
||||
如果需要同时配置多个第三方 OpenAI 兼容服务(例如硅基流动、七牛云等),可以使用 `custom_providers` 列表,并通过 `custom_active_provider` 指定当前生效的厂商:
|
||||
|
||||
```json
|
||||
{
|
||||
"bot_type": "custom",
|
||||
"custom_active_provider": "siliconflow",
|
||||
"custom_providers": [
|
||||
{
|
||||
"name": "siliconflow",
|
||||
"api_key": "YOUR_SILICONFLOW_KEY",
|
||||
"api_base": "https://api.siliconflow.cn/v1",
|
||||
"model": "deepseek-ai/DeepSeek-V3"
|
||||
},
|
||||
{
|
||||
"name": "qiniu",
|
||||
"api_key": "YOUR_QINIU_KEY",
|
||||
"api_base": "https://api.qnaigc.com/v1",
|
||||
"model": "deepseek-v3"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| 参数 | 说明 |
|
||||
| --- | --- |
|
||||
| `custom_providers` | 自定义厂商列表,每项包含 `name`、`api_key`、`api_base`、可选的 `model` |
|
||||
| `custom_active_provider` | 当前生效厂商的 `name`;留空时默认使用列表中的第一个厂商 |
|
||||
|
||||
<Note>
|
||||
当 `custom_providers` 为空时,将自动回退到上文的 `custom_api_key` / `custom_api_base` 单厂商配置,已有配置无需改动即可正常工作。
|
||||
</Note>
|
||||
|
||||
Reference in New Issue
Block a user