fix: 修复自部署模型渠道 fetch failed 与官方地址测试 404 兼容问题#6717
Draft
ljluestc wants to merge 1 commit intolabring:mainfrom
Draft
fix: 修复自部署模型渠道 fetch failed 与官方地址测试 404 兼容问题#6717ljluestc wants to merge 1 commit intolabring:mainfrom
ljluestc wants to merge 1 commit intolabring:mainfrom
Conversation
问题: 1. AI Proxy 未配置时访问渠道管理页面报 'fetch failed' 2. 使用官方 API 地址测试模型时返回 404 解决方案: 1. AI Proxy 未配置时返回清晰错误提示,建议使用自定义请求地址 2. 模型测试 API 支持直接使用自定义请求地址测试 3. 渠道配置提交前自动规范化 base_url,移除常见接口路径后缀 4. AI Proxy 转发异常返回统一结构并附带可操作的配置诊断信息 5. .env.template 改进 AI Proxy 配置说明,默认值改为 http:// 6. 新增文档说明不使用 AI Proxy 的配置方法 变更文件: - projects/app/src/pages/api/aiproxy/[...path].ts: 增强错误处理 - projects/app/src/pages/api/core/ai/model/test.ts: 支持自定义请求地址 - projects/app/src/pageComponents/account/model/Channel/index.tsx: 添加警告组件 - projects/app/src/web/core/ai/channel.ts: 添加 base_url 规范化函数 - projects/app/.env.template: 改进配置注释 - document/content/docs/self-host/config/model/intro.mdx: 中文文档 - document/content/docs/self-host/config/model/intro.en.mdx: 英文文档 Closes: labring#6525
|
|
1 similar comment
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: 修复自部署模型渠道 fetch failed 与官方地址测试 404 兼容问题
Closes: #6525
问题背景
用户反馈了两个自部署场景下的问题:
渠道管理页面报错: 未配置 AI Proxy 时访问渠道管理页面出现 "fetch failed" 错误,缺少明确的配置指引
官方 API 地址测试失败: 在模型配置中填写完整的 OpenAI 接口地址(如
https://api.openai.com/v1/chat/completions)测试时返回 404 错误解决方案
1. 增强 AI Proxy 错误处理
2. 支持自定义请求地址测试
requestUrl/requestAuth参数进行测试,无需依赖 AI Proxy3. base_url 自动规范化
/chat/completions/embeddings/audio/transcriptions/audio/speech/rerank/responses4. 改进配置文档
.env.template中 AI Proxy 配置标记为可选https://localhost:3010改为http://localhost:3010,避免本地 TLS 误配5. 新增使用文档
变更文件
projects/app/src/pages/api/aiproxy/[...path].tsprojects/app/src/pages/api/core/ai/model/test.tsprojects/app/src/pageComponents/account/model/Channel/index.tsxprojects/app/src/web/core/ai/channel.tsnormalizeChannelBaseUrl()规范化函数projects/app/.env.templatedocument/content/docs/self-host/config/model/intro.mdxdocument/content/docs/self-host/config/model/intro.en.mdx测试验证
使用说明
方式一:使用 AI Proxy(推荐)
适用于需要负载均衡、日志记录等高级功能的场景:
方式二:直接使用官方 API
无需配置 AI Proxy,直接在模型配置中设置:
requestUrl: API 基础地址,如https://api.openai.com/v1requestAuth: API Key技术细节
base_url 规范化逻辑
错误信息示例
{ "success": false, "message": "AI Proxy request failed (AIPROXY_API_ENDPOINT=http://localhost:3010): connect ECONNREFUSED 127.0.0.1:3010. If FastGPT runs in Docker, localhost points to the FastGPT container itself. Use a container service name or a reachable host IP.", "data": null }