Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 46
fix(assistant): 切换免费模型 Intern-S1 → GLM-4.6V-Flash + 加关闭按钮 (#285)#293
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,22 +1,33 @@ | ||||||||||||||||||||||||||||||||||
| import { createOpenAICompatible } from "@ai-sdk/openai-compatible"; | ||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||
| * Create Intern-AI model instance | ||||||||||||||||||||||||||||||||||
| * Uses environment variable INTERN_KEY for API key | ||||||||||||||||||||||||||||||||||
| * 在开发环境下,临时映射到 Deepseek 进行测试 | ||||||||||||||||||||||||||||||||||
| * @returns Configured Intern-AI model instance | ||||||||||||||||||||||||||||||||||
| * 免费聊天模型:智谱 GLM-4.6V-Flash | ||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||
| * 历史原因:此前默认走上海 AI Lab 的书生 Intern-S1,现因 key 过期改接智谱 | ||||||||||||||||||||||||||||||||||
| * GLM-4.6V-Flash(同样免费、128K 上下文、支持多模态)。为避免破坏用户 | ||||||||||||||||||||||||||||||||||
| * localStorage 里已有的 provider="intern" 设置,函数/Provider 名保留 `intern` | ||||||||||||||||||||||||||||||||||
| * 作为语义上的"免费兜底模型"标识。 | ||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||
| * 开发环境仍可通过 DEEPSEEK_API_KEY 快速切换到 Deepseek 接口做调试。 | ||||||||||||||||||||||||||||||||||
| * 生产环境需要在服务端配置 ZHIPU_API_KEY(智谱 AI 开放平台)。 | ||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||
| export function createInternModel() { | ||||||||||||||||||||||||||||||||||
| const isDev = process.env.NODE_ENV === "development"; | ||||||||||||||||||||||||||||||||||
| const intern = createOpenAICompatible({ | ||||||||||||||||||||||||||||||||||
| name: "intern", | ||||||||||||||||||||||||||||||||||
| baseURL: isDev | ||||||||||||||||||||||||||||||||||
| ? "https://api.deepseek.com" // 开发环境临时使用 Deepseek 接口测试 | ||||||||||||||||||||||||||||||||||
| : "https://chat.intern-ai.org.cn/api/v1/", | ||||||||||||||||||||||||||||||||||
| apiKey: isDev ? process.env.DEEPSEEK_API_KEY : process.env.INTERN_KEY, | ||||||||||||||||||||||||||||||||||
| if (isDev && process.env.DEEPSEEK_API_KEY) { | ||||||||||||||||||||||||||||||||||
| const deepseek = createOpenAICompatible({ | ||||||||||||||||||||||||||||||||||
| name: "deepseek", | ||||||||||||||||||||||||||||||||||
| baseURL: "https://api.deepseek.com", | ||||||||||||||||||||||||||||||||||
| apiKey: process.env.DEEPSEEK_API_KEY, | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
| return deepseek("deepseek-chat"); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| const glm = createOpenAICompatible({ | ||||||||||||||||||||||||||||||||||
| name: "zhipu", | ||||||||||||||||||||||||||||||||||
| baseURL: "https://open.bigmodel.cn/api/paas/v4/", | ||||||||||||||||||||||||||||||||||
| apiKey: process.env.ZHIPU_API_KEY, | ||||||||||||||||||||||||||||||||||
Comment on lines
+26
to
+29
CopilotAI | ||||||||||||||||||||||||||||||||||
| constglm=createOpenAICompatible({ | |
| name: "zhipu", | |
| baseURL: "https://open.bigmodel.cn/api/paas/v4/", | |
| apiKey: process.env.ZHIPU_API_KEY, | |
| constzhipuApiKey=process.env.ZHIPU_API_KEY; | |
| if(!zhipuApiKey||zhipuApiKey.trim()===""){ | |
| thrownewError( | |
| "Missing required environment variable ZHIPU_API_KEY. Configure it on the server (for example in Vercel Project Settings -> Environment Variables) before using the intern provider.", | |
| ); | |
| } | |
| constglm=createOpenAICompatible({ | |
| name: "zhipu", | |
| baseURL: "https://open.bigmodel.cn/api/paas/v4/", | |
| apiKey: zhipuApiKey, |
Uh oh!
There was an error while loading. Please reload this page.
CopilotAIApr 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里用 throw 触发 fallback 会导致所有匿名请求都进入 catch 分支并打印带 stack 的 warn 日志(且文案是“Java Backend unavailable...”),实际会在生产环境造成大量噪音。建议改为显式的 if 分支直接跳过代理(不抛错、不进入 catch),或在 catch 中对匿名场景单独处理为低噪日志/不记录 error 对象。