feat: 国产大模型官方渠道增加千问 Qwen

默认使用阿里云百炼 Token Plan 地址和 qwen3.8-max 模型,按量付费的 Key 可改填 DashScope 兼容地址。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
margrop
2026-10-30 03:30:06 +08:00
parent e3470ea846
commit 1ca9783ad3
13 changed files with 40 additions and 17 deletions

View File

@@ -25,7 +25,7 @@ AUTH_TRUST_HOST=true
# AI_DAILY_LIMIT=0
# AI 服务提供商配置
# 可选值: "minimax" (默认)、"minimax-code"、"glm"、"deepseek"、"kimi"、"anthropic"、"azure"、"openai"、"gemini"
# 可选值: "minimax" (默认)、"minimax-code"、"glm"、"deepseek"、"kimi"、"qwen"、"anthropic"、"azure"、"openai"、"gemini"
AI_PROVIDER="minimax"
# 国产大模型官方渠道(OpenAI 兼容接口,BASE_URL 和 MODEL 可选,留空使用官方默认值)
@@ -45,6 +45,10 @@ DEEPSEEK_MODEL="" # 默认为 deepseek-flash
KIMI_API_KEY=""
KIMI_BASE_URL="" # 默认为 https://api.moonshot.cn/v1,国际站为 https://api.moonshot.ai/v1
KIMI_MODEL="" # 默认为 kimi-k3
# 千问 Qwen (当 AI_PROVIDER="qwen" 时需要;推荐阿里云百炼 Token Plan,Key 以 sk-sp- 开头)
QWEN_API_KEY=""
QWEN_BASE_URL="" # 默认为 Token Plan 地址 https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1,按量付费的 Key 填 https://dashscope.aliyuncs.com/compatible-mode/v1
QWEN_MODEL="" # 默认为 qwen3.8-max
# MiniMax Code OAuth (当 AI_PROVIDER="minimax-code" 时使用):在网页“设置 → AI 设置”中登录账号,无需 API Key
MINIMAX_CODE_MODEL="" # 默认为 MiniMax-M3.1-Flash

View File

@@ -60,7 +60,7 @@ bash scripts/ci.sh # 完整 CI(要求 Node.js 22 及以上,含生
- 界面文本放在 `@/lib/translations.ts`,组件中用 `t.section.key`,缺省回退英文。中英文 key 必须一致(`translations.test.ts` 会检查)。
- 页面须同时适配 PC 和移动端(移动优先)。
- 修改 AI 调用时同步更新所有提供商(`gemini-provider.ts`、`openai-provider.ts`、`azure-provider.ts`、`anthropic-provider.ts`),提示词集中在 `prompts.ts`。
- MiniMax、智谱 GLM、DeepSeek、Kimi 等国产大模型官方渠道复用 `OpenAIProvider`,默认地址和模型集中在 `src/lib/ai/vendor-presets.ts`;新增渠道只需加预设并同步文档与测试。
- MiniMax、智谱 GLM、DeepSeek、Kimi、千问 Qwen 等国产大模型官方渠道复用 `OpenAIProvider`,默认地址和模型集中在 `src/lib/ai/vendor-presets.ts`;新增渠道只需加预设并同步文档与测试。
## 安全

View File

@@ -194,7 +194,7 @@ When served over HTTPS (or `localhost`), a service worker caches scripts, styles
- **Database**: [SQLite](https://www.sqlite.org/) (via [Prisma 5](https://www.prisma.io/))
- **Styling**: [Tailwind CSS v4](https://tailwindcss.com/) + [Radix UI](https://www.radix-ui.com/) (shadcn/ui-style components)
- **Formulas**: [KaTeX](https://katex.org/) (react-markdown + remark-math)
- **AI**: MiniMax / MiniMax Code (browser sign-in) / Zhipu GLM / DeepSeek / Kimi / Anthropic (and compatible APIs) / Azure OpenAI / OpenAI (and compatible APIs) / Google Gemini
- **AI**: MiniMax / MiniMax Code (browser sign-in) / Zhipu GLM / DeepSeek / Kimi / Qwen / Anthropic (and compatible APIs) / Azure OpenAI / OpenAI (and compatible APIs) / Google Gemini
- **Auth**: [NextAuth.js v4](https://next-auth.js.org/)
- **Testing**: Vitest (unit, integration), Playwright (E2E)
@@ -351,13 +351,14 @@ Data directories, default accounts and local builds are described in [INSTALL_PA
| Variable | Description | Default | Notes |
| :--- | :--- | :--- | :--- |
| `AI_PROVIDER` | AI provider | `minimax` | `minimax`, `minimax-code`, `glm`, `deepseek`, `kimi`, `anthropic`, `azure`, `openai` or `gemini` |
| `AI_PROVIDER` | AI provider | `minimax` | `minimax`, `minimax-code`, `glm`, `deepseek`, `kimi`, `qwen`, `anthropic`, `azure`, `openai` or `gemini` |
| `MINIMAX_API_KEY` / `MINIMAX_BASE_URL` / `MINIMAX_MODEL` | MiniMax | URL `https://api.minimax.cn/v1`, model `MiniMax-M3.1-Flash` | URL and model are optional |
| `MINIMAX_CODE_MODEL` | MiniMax Code model | `MiniMax-M3.1-Flash` | The account signs in from the web settings; no API key needed |
| `MINIMAX_CODE_AUTO_CHECKIN` | MiniMax Code daily auto check-in | `true` | Set to `false` to turn it off |
| `GLM_API_KEY` / `GLM_BASE_URL` / `GLM_MODEL` | Zhipu GLM | URL `https://open.bigmodel.cn/api/paas/v4`, model `glm-5.3-flash` | URL and model are optional |
| `DEEPSEEK_API_KEY` / `DEEPSEEK_BASE_URL` / `DEEPSEEK_MODEL` | DeepSeek | URL `https://api.deepseek.com`, model `deepseek-flash` | URL and model are optional |
| `KIMI_API_KEY` / `KIMI_BASE_URL` / `KIMI_MODEL` | Kimi | URL `https://api.moonshot.cn/v1`, model `kimi-k3` | URL and model are optional |
| `QWEN_API_KEY` / `QWEN_BASE_URL` / `QWEN_MODEL` | Qwen | URL `https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1` (Model Studio Token Plan), model `qwen3.8-max` | Pay-as-you-go keys use `https://dashscope.aliyuncs.com/compatible-mode/v1` |
| `ANTHROPIC_API_KEY` | Anthropic API key | None | From the [Claude Console](https://platform.claude.com/) |
| `ANTHROPIC_BASE_URL` | API URL | `https://api.anthropic.com` | For compatible services, use the URL without `/v1` |
| `ANTHROPIC_MODEL` | Model | `claude-sonnet-5-5` | e.g. `claude-opus-5-5`, `claude-haiku-5-5` |
@@ -390,7 +391,7 @@ When adding environment variables, update `.env.example` as well.
AI settings can be changed in the web UI without restarting the server.
1. **Open settings**: as an administrator, click the settings icon at the top right of the home page and open **AI Provider**.
2. **Choose a provider**: MiniMax is the default. Choose from the official MiniMax channel, MiniMax Code OAuth (sign in with a MiniMax Code account in the browser), the official Zhipu GLM, DeepSeek and Kimi channels, Anthropic, Azure OpenAI, OpenAI (including compatible APIs) or Google Gemini; OpenAI supports several configurations you can switch between.
2. **Choose a provider**: MiniMax is the default. Choose from the official MiniMax channel, MiniMax Code OAuth (sign in with a MiniMax Code account in the browser), the official Zhipu GLM, DeepSeek, Kimi and Qwen channels, Anthropic, Azure OpenAI, OpenAI (including compatible APIs) or Google Gemini; OpenAI supports several configurations you can switch between.
3. **Fill in the parameters**: API key, base URL (or endpoint) and model (or deployment name). Test the connection and fetch the model list from the API.
4. **Save**: settings are stored in `config/app-config.json` and take precedence over `.env`.
@@ -409,7 +410,7 @@ The selected model must meet these requirements, or some features will fail or w
| **Valid LaTeX** | Questions, answers, analyses | Formulas must render in KaTeX; use **Fix LaTeX** on the details page if there are syntax errors |
| **Strong math reasoning** | Solutions, mistake analysis, difficulty stars, mastery estimates | Reasoning (thinking) models work; their thinking output is ignored. If thinking takes long, administrators can raise **AI Analysis Timeout** in **Settings → General** |
Use each provider's current multimodal flagship or fast model, such as `MiniMax-M3.1-Flash`, `glm-5.3-flash`, `deepseek-flash`, `kimi-k3`, `claude-sonnet-5-5`, `gpt-6.1-sol` or `gemini-3.8-flash`. For third-party models behind compatible APIs, make sure they support image input first.
Use each provider's current multimodal flagship or fast model, such as `MiniMax-M3.1-Flash`, `glm-5.3-flash`, `deepseek-flash`, `kimi-k3`, `qwen3.8-max`, `claude-sonnet-5-5`, `gpt-6.1-sol` or `gemini-3.8-flash`. For third-party models behind compatible APIs, make sure they support image input first.
### Configuration examples
@@ -423,6 +424,7 @@ These channels call each vendor's official OpenAI-compatible API, so only an API
| Zhipu GLM | [Z.ai platform](https://z.ai) | `https://open.bigmodel.cn/api/paas/v4` (international `https://api.z.ai/api/paas/v4`) | `glm-5.3-flash` |
| DeepSeek | [DeepSeek platform](https://platform.deepseek.com) | `https://api.deepseek.com` | `deepseek-flash` |
| Kimi | [Kimi platform](https://platform.kimi.com) | `https://api.moonshot.cn/v1` (international `https://api.moonshot.ai/v1`) | `kimi-k3` |
| Qwen | [Alibaba Cloud Model Studio](https://bailian.console.aliyun.com) (Token Plan recommended) | `https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1` (pay-as-you-go `https://dashscope.aliyuncs.com/compatible-mode/v1`) | `qwen3.8-max` |
#### MiniMax Code OAuth

View File

@@ -192,7 +192,7 @@
- **数据库**: [SQLite](https://www.sqlite.org/) (via [Prisma 5](https://www.prisma.io/))
- **样式**: [Tailwind CSS v4](https://tailwindcss.com/) + [Radix UI](https://www.radix-ui.com/)(shadcn/ui 风格组件)
- **公式**: [KaTeX](https://katex.org/)(react-markdown + remark-math)
- **AI**: MiniMax / MiniMax Code(网页登录)/ 智谱 GLM / DeepSeek / Kimi / Anthropic(及兼容接口)/ Azure OpenAI / OpenAI(及兼容接口)/ Google Gemini
- **AI**: MiniMax / MiniMax Code(网页登录)/ 智谱 GLM / DeepSeek / Kimi / 千问 Qwen / Anthropic(及兼容接口)/ Azure OpenAI / OpenAI(及兼容接口)/ Google Gemini
- **认证**: [NextAuth.js v4](https://next-auth.js.org/)
- **测试**: Vitest(单元、集成)、Playwright(E2E)
@@ -349,13 +349,14 @@ wrong-notebook --port 3000
| 环境变量 | 描述 | 默认值 | 说明 |
| :--- | :--- | :--- | :--- |
| `AI_PROVIDER` | AI 提供商 | `minimax` | 可选 `minimax`、`minimax-code`、`glm`、`deepseek`、`kimi`、`anthropic`、`azure`、`openai`、`gemini` |
| `AI_PROVIDER` | AI 提供商 | `minimax` | 可选 `minimax`、`minimax-code`、`glm`、`deepseek`、`kimi`、`qwen`、`anthropic`、`azure`、`openai`、`gemini` |
| `MINIMAX_API_KEY` / `MINIMAX_BASE_URL` / `MINIMAX_MODEL` | MiniMax | 地址 `https://api.minimax.cn/v1`,模型 `MiniMax-M3.1-Flash` | 地址和模型可留空 |
| `MINIMAX_CODE_MODEL` | MiniMax Code 模型 | `MiniMax-M3.1-Flash` | 账号在网页设置中登录,无需 API Key |
| `MINIMAX_CODE_AUTO_CHECKIN` | MiniMax Code 每日自动签到 | `true` | 设为 `false` 关闭 |
| `GLM_API_KEY` / `GLM_BASE_URL` / `GLM_MODEL` | 智谱 GLM | 地址 `https://open.bigmodel.cn/api/paas/v4`,模型 `glm-5.3-flash` | 地址和模型可留空 |
| `DEEPSEEK_API_KEY` / `DEEPSEEK_BASE_URL` / `DEEPSEEK_MODEL` | DeepSeek | 地址 `https://api.deepseek.com`,模型 `deepseek-flash` | 地址和模型可留空 |
| `KIMI_API_KEY` / `KIMI_BASE_URL` / `KIMI_MODEL` | Kimi | 地址 `https://api.moonshot.cn/v1`,模型 `kimi-k3` | 地址和模型可留空 |
| `QWEN_API_KEY` / `QWEN_BASE_URL` / `QWEN_MODEL` | 千问 Qwen | 地址 `https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1`(百炼 Token Plan),模型 `qwen3.8-max` | 按量付费的 Key 改填 `https://dashscope.aliyuncs.com/compatible-mode/v1` |
| `ANTHROPIC_API_KEY` | Anthropic API Key | 无 | 从 [Claude Console](https://platform.claude.com/) 获取 |
| `ANTHROPIC_BASE_URL` | API 地址 | `https://api.anthropic.com` | 兼容服务填写不含 `/v1` 的地址 |
| `ANTHROPIC_MODEL` | 模型 | `claude-sonnet-5-5` | 如 `claude-opus-5-5`、`claude-haiku-5-5` |
@@ -388,7 +389,7 @@ wrong-notebook --port 3000
AI 配置可在网页中动态修改,无需重启服务器。
1. **进入设置**:管理员点击首页右上角的设置图标,打开「AI 设置」。
2. **选择提供商**:默认使用 MiniMax;可选 MiniMax、用 MiniMax Code 账号网页登录的 MiniMax Code OAuth、智谱 GLM、DeepSeek、Kimi,以及 Anthropic、Azure OpenAI、OpenAI(含兼容接口)、Google Gemini,OpenAI 可添加多个配置并切换。
2. **选择提供商**:默认使用 MiniMax;可选 MiniMax、用 MiniMax Code 账号网页登录的 MiniMax Code OAuth、智谱 GLM、DeepSeek、Kimi、千问 Qwen,以及 Anthropic、Azure OpenAI、OpenAI(含兼容接口)、Google Gemini,OpenAI 可添加多个配置并切换。
3. **填写参数**:API Key、Base URL(或 Endpoint)、模型(或部署名称);可测试连接并从接口获取模型列表。
4. **保存生效**:配置保存到 `config/app-config.json`,优先级高于 `.env`。
@@ -407,7 +408,7 @@ AI 配置可在网页中动态修改,无需重启服务器。
| **规范的 LaTeX** | 题目、答案、解析 | 公式须能被 KaTeX 显示;出现语法错误时可用详情页的「修复 LaTeX」修正 |
| **较强的数学推理** | 解答、错因分析、难度星级、掌握概率评估 | 推理(思考)模型可以使用,思考内容会被自动忽略;思考耗时较长时,管理员可在「设置 → 通用」中调大「AI 分析超时时间」 |
推荐使用各提供商当前的多模态旗舰或快速模型,例如 `MiniMax-M3.1-Flash`、`glm-5.3-flash`、`deepseek-flash`、`kimi-k3`、`claude-sonnet-5-5`、`gpt-6.1-sol`、`gemini-3.8-flash`。使用兼容接口的第三方模型时,请先确认它支持图片输入。
推荐使用各提供商当前的多模态旗舰或快速模型,例如 `MiniMax-M3.1-Flash`、`glm-5.3-flash`、`deepseek-flash`、`kimi-k3`、`qwen3.8-max`、`claude-sonnet-5-5`、`gpt-6.1-sol`、`gemini-3.8-flash`。使用兼容接口的第三方模型时,请先确认它支持图片输入。
### 配置样例
@@ -421,6 +422,7 @@ AI 配置可在网页中动态修改,无需重启服务器。
| 智谱 GLM | [智谱开放平台](https://open.bigmodel.cn) | `https://open.bigmodel.cn/api/paas/v4`(国际站 `https://api.z.ai/api/paas/v4`) | `glm-5.3-flash` |
| DeepSeek | [DeepSeek 开放平台](https://platform.deepseek.com) | `https://api.deepseek.com` | `deepseek-flash` |
| Kimi | [Kimi 开放平台](https://platform.kimi.com) | `https://api.moonshot.cn/v1`(国际站 `https://api.moonshot.ai/v1`) | `kimi-k3` |
| 千问 Qwen | [阿里云百炼](https://bailian.console.aliyun.com)(推荐 Token Plan) | `https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1`(按量付费 `https://dashscope.aliyuncs.com/compatible-mode/v1`) | `qwen3.8-max` |
#### MiniMax Code OAuth

View File

@@ -14,7 +14,7 @@
| 数据库 | SQLite (Prisma ORM 5.22) |
| 样式 | Tailwind CSS v4 + Shadcn UI (Radix primitives) |
| 认证 | NextAuth.js v4 (credentials provider, bcryptjs) |
| AI | MiniMax(默认)/ 智谱 GLM / DeepSeek / Kimi / Anthropic / Azure OpenAI / OpenAI / Google Gemini (动态切换) |
| AI | MiniMax(默认)/ 智谱 GLM / DeepSeek / Kimi / 千问 Qwen / Anthropic / Azure OpenAI / OpenAI / Google Gemini (动态切换) |
| 测试 | Vitest (单元/集成) + Playwright (E2E) |
| 部署 | Docker (standalone output) + Docker Compose |
| 包管理 | npm |

View File

@@ -20,6 +20,7 @@ AI 设置、连接测试、模型列表与提示词设置只向管理员开放
| 智谱 GLM | API Key | 默认 `https://open.bigmodel.cn/api/paas/v4`;代码默认 `glm-5.3-flash` |
| DeepSeek | API Key | 默认 `https://api.deepseek.com`;代码默认 `deepseek-flash` |
| Kimi | API Key | 默认 `https://api.moonshot.cn/v1`;代码默认 `kimi-k3` |
| 千问 Qwen | API Key(推荐百炼 Token Plan,以 `sk-sp-` 开头) | 默认 Token Plan 地址 `https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1`,按量付费的 Key 改填 `https://dashscope.aliyuncs.com/compatible-mode/v1`;代码默认 `qwen3.8-max` |
| Anthropic 或兼容接口 | API Key、模型 | 默认 `https://api.anthropic.com`;代码默认 `claude-sonnet-5-5` |
| Azure OpenAI | API Key、Endpoint、部署名称 | API 版本默认 `2024-02-15-preview`;模型字段用于显示 |
| OpenAI 或兼容接口 | API Key、模型 | 默认 `https://api.openai.com/v1`;代码默认 `gpt-6.1-sol` |
@@ -45,7 +46,7 @@ MiniMax Code OAuth 用 MiniMax Code 账号登录后调用模型,不需要 API
## 环境变量
基础选择使用 `AI_PROVIDER`,默认 `minimax`,可选 `minimax`、`minimax-code`、`glm`、`deepseek`、`kimi`、`anthropic`、`azure`、`openai`、`gemini`。
基础选择使用 `AI_PROVIDER`,默认 `minimax`,可选 `minimax`、`minimax-code`、`glm`、`deepseek`、`kimi`、`qwen`、`anthropic`、`azure`、`openai`、`gemini`。
| 提供商 | 配置项 |
| --- | --- |
@@ -54,6 +55,7 @@ MiniMax Code OAuth 用 MiniMax Code 账号登录后调用模型,不需要 API
| 智谱 GLM | `GLM_API_KEY`、`GLM_BASE_URL`、`GLM_MODEL` |
| DeepSeek | `DEEPSEEK_API_KEY`、`DEEPSEEK_BASE_URL`、`DEEPSEEK_MODEL` |
| Kimi | `KIMI_API_KEY`、`KIMI_BASE_URL`、`KIMI_MODEL` |
| 千问 Qwen | `QWEN_API_KEY`、`QWEN_BASE_URL`、`QWEN_MODEL` |
| Anthropic | `ANTHROPIC_API_KEY`、`ANTHROPIC_BASE_URL`、`ANTHROPIC_MODEL` |
| Azure | `AZURE_OPENAI_API_KEY`、`AZURE_OPENAI_ENDPOINT`、`AZURE_OPENAI_DEPLOYMENT`、`AZURE_OPENAI_API_VERSION`、`AZURE_OPENAI_MODEL` |
| OpenAI | `OPENAI_API_KEY`、`OPENAI_BASE_URL`、`OPENAI_MODEL` |

View File

@@ -20,6 +20,7 @@ AI settings, connection tests, model lists and prompt settings are admin-only. T
| Zhipu GLM | API key | Defaults to `https://open.bigmodel.cn/api/paas/v4`; code default `glm-5.3-flash` |
| DeepSeek | API key | Defaults to `https://api.deepseek.com`; code default `deepseek-flash` |
| Kimi | API key | Defaults to `https://api.moonshot.cn/v1`; code default `kimi-k3` |
| Qwen | API key (Model Studio Token Plan recommended, starts with `sk-sp-`) | Defaults to the Token Plan URL `https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1`; pay-as-you-go keys use `https://dashscope.aliyuncs.com/compatible-mode/v1`; code default `qwen3.8-max` |
| Anthropic or compatible | API key, model | Defaults to `https://api.anthropic.com`; code default `claude-sonnet-5-5` |
| Azure OpenAI | API key, endpoint, deployment name | API version defaults to `2024-02-15-preview`; the model field is for display |
| OpenAI or compatible | API key, model | Defaults to `https://api.openai.com/v1`; code default `gpt-6.1-sol` |
@@ -27,7 +28,7 @@ AI settings, connection tests, model lists and prompt settings are admin-only. T
The default names come from the current code and do not mean these models are enabled for your account. Model availability, billing and capabilities are determined by the provider.
For OpenAI-compatible services, the base URL should include the API path they require. For Anthropic-compatible services, the base URL excludes `/v1`; the app appends `/v1/messages`. The official MiniMax, GLM, DeepSeek and Kimi channels are called through the OpenAI-compatible API; leaving the endpoint and model empty uses the official defaults. Fill in the international endpoint if you use an international site.
For OpenAI-compatible services, the base URL should include the API path they require. For Anthropic-compatible services, the base URL excludes `/v1`; the app appends `/v1/messages`. The official MiniMax, GLM, DeepSeek, Kimi and Qwen channels are called through the OpenAI-compatible API; leaving the endpoint and model empty uses the official defaults. Fill in the international endpoint if you use an international site.
## MiniMax Code OAuth
@@ -45,7 +46,7 @@ This channel uses the sign-in of the MiniMax Code desktop client rather than an
## Environment variables
`AI_PROVIDER` selects the provider. It defaults to `minimax` and accepts `minimax`, `minimax-code`, `glm`, `deepseek`, `kimi`, `anthropic`, `azure`, `openai` and `gemini`.
`AI_PROVIDER` selects the provider. It defaults to `minimax` and accepts `minimax`, `minimax-code`, `glm`, `deepseek`, `kimi`, `qwen`, `anthropic`, `azure`, `openai` and `gemini`.
| Provider | Variables |
| --- | --- |
@@ -54,6 +55,7 @@ This channel uses the sign-in of the MiniMax Code desktop client rather than an
| Zhipu GLM | `GLM_API_KEY`, `GLM_BASE_URL`, `GLM_MODEL` |
| DeepSeek | `DEEPSEEK_API_KEY`, `DEEPSEEK_BASE_URL`, `DEEPSEEK_MODEL` |
| Kimi | `KIMI_API_KEY`, `KIMI_BASE_URL`, `KIMI_MODEL` |
| Qwen | `QWEN_API_KEY`, `QWEN_BASE_URL`, `QWEN_MODEL` |
| Anthropic | `ANTHROPIC_API_KEY`, `ANTHROPIC_BASE_URL`, `ANTHROPIC_MODEL` |
| Azure | `AZURE_OPENAI_API_KEY`, `AZURE_OPENAI_ENDPOINT`, `AZURE_OPENAI_DEPLOYMENT`, `AZURE_OPENAI_API_VERSION`, `AZURE_OPENAI_MODEL` |
| OpenAI | `OPENAI_API_KEY`, `OPENAI_BASE_URL`, `OPENAI_MODEL` |

View File

@@ -65,7 +65,7 @@ After changing logic, run at least the unit and integration tests. Changes to do
## Changing AI features
AI logic changes must consider all providers: Gemini, OpenAI (including the MiniMax, GLM, DeepSeek and Kimi channels), Azure and Anthropic. Prompts live in `prompts.ts`; the type and format contract of generated questions is also validated by modules such as `generated-question.ts`.
AI logic changes must consider all providers: Gemini, OpenAI (including the MiniMax, GLM, DeepSeek, Kimi and Qwen channels), Azure and Anthropic. Prompts live in `prompts.ts`; the type and format contract of generated questions is also validated by modules such as `generated-question.ts`.
Cover normal results, malformed output, timeouts and truncated output when verifying. After changing an output structure, also check callers such as practice, exam papers, figures and re-solving.

View File

@@ -12,7 +12,7 @@ This Wiki covers [margrop/wrong-notebook](https://github.com/margrop/wrong-noteb
| --- | --- |
| Run it locally and sign in for the first time | [Quick Start](Quick-Start-en) |
| Deploy with Docker, enable HTTPS or upgrade | [Deployment and Upgrades](Deployment-en) |
| Configure MiniMax, GLM, DeepSeek, Kimi, Anthropic, Azure, OpenAI or Gemini | [AI Configuration](AI-Configuration-en) |
| Configure MiniMax, GLM, DeepSeek, Kimi, Qwen, Anthropic, Azure, OpenAI or Gemini | [AI Configuration](AI-Configuration-en) |
| Add, organize, review and search questions | [User Guide](User-Guide-en) |
| Similar-question practice, exam papers, printing and recording results | [Practice and Exams](Practice-and-Exams-en) |
| Preferences, the app time zone and user permissions | [Settings and Users](Settings-and-Users-en) |

View File

@@ -40,6 +40,7 @@ const EXPECTED: Record<VendorProviderId, { baseUrl: string; model: string }> = {
glm: { baseUrl: 'https://open.bigmodel.cn/api/paas/v4', model: 'glm-5.3-flash' },
deepseek: { baseUrl: 'https://api.deepseek.com', model: 'deepseek-flash' },
kimi: { baseUrl: 'https://api.moonshot.cn/v1', model: 'kimi-k3' },
qwen: { baseUrl: 'https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1', model: 'qwen3.8-max' },
};
const adminSession = { user: { id: 'admin-1', role: 'admin' }, expires: '2099-01-01' };

View File

@@ -41,7 +41,7 @@ export function VendorSettings({ provider, value, onChange }: VendorSettingsProp
onChange={(e) => update("baseUrl", e.target.value)}
placeholder={preset.baseUrl}
/>
<p className="text-xs text-muted-foreground">{t.settings?.ai?.vendorBaseUrlHint}</p>
<p className="text-xs text-muted-foreground">{provider === "qwen" ? t.settings?.ai?.qwenBaseUrlHint : t.settings?.ai?.vendorBaseUrlHint}</p>
</div>
<ModelSelector
provider={provider}

View File

@@ -40,6 +40,14 @@ export const VENDOR_PRESETS = {
envPrefix: 'KIMI',
consoleUrl: 'https://platform.kimi.com',
},
// 默认为百炼 Token Plan 专属地址(Key 以 sk-sp- 开头);按量付费的 Key 改用 https://dashscope.aliyuncs.com/compatible-mode/v1
qwen: {
name: '千问 Qwen',
baseUrl: 'https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1',
model: 'qwen3.8-max',
envPrefix: 'QWEN',
consoleUrl: 'https://bailian.console.aliyun.com',
},
} as const satisfies Record<string, VendorPreset>;
export type VendorProviderId = keyof typeof VENDOR_PRESETS;

View File

@@ -503,6 +503,7 @@ export const translations = {
anthropicBaseUrlHint: "Leave empty for the official API. For compatible services enter the base URL without /v1 (e.g. https://api.example.com/anthropic).",
vendorApiKeyHint: "Get an API key from the official console:",
vendorBaseUrlHint: "Leave empty for the official mainland China endpoint shown above. For the international site, enter its OpenAI-compatible URL instead.",
qwenBaseUrlHint: "The default is the Alibaba Cloud Model Studio Token Plan endpoint (recommended; keys start with sk-sp-). For a pay-as-you-go key, enter https://dashscope.aliyuncs.com/compatible-mode/v1.",
minimaxCode: {
title: "MiniMax Code account",
intro: "Sign in to your MiniMax Code account in the browser. The app uses this login to call MiniMax Code models, so no API key is needed.",
@@ -1684,6 +1685,7 @@ export const translations = {
anthropicBaseUrlHint: "留空使用官方接口;兼容服务请填写不含 /v1 的地址(如 https://api.example.com/anthropic)。",
vendorApiKeyHint: "在官方控制台获取 API Key:",
vendorBaseUrlHint: "留空使用上方的中国大陆官方地址;使用国际站时填写其 OpenAI 兼容地址。",
qwenBaseUrlHint: "默认为阿里云百炼 Token Plan 专属地址(推荐,Key 以 sk-sp- 开头);使用按量付费的 Key 时填写 https://dashscope.aliyuncs.com/compatible-mode/v1。",
minimaxCode: {
title: "MiniMax Code 账号",
intro: "用 MiniMax Code 账号在网页登录授权,应用会用这个登录调用 MiniMax Code 的模型,不需要 API Key。",