模型问题排查
排查 FastGPT 自部署环境中模型调用超时、流式响应中断、向量维度不匹配与渠道鉴权失败等常见报错。
(1) 如何检查模型可用性问题
- 私有部署模型,先确认部署的模型是否正常。
- 通过 CURL 请求,直接测试上游模型是否正常运行(云端模型或私有模型均进行测试)
- 在 管理员 → 系统资源 → 系统模型 页面的“模型渠道”标签测试 AI Proxy 渠道;若渠道后方连接了 OneAPI 等中转,再分别检查该中转。
- 在 FastGPT 中使用该模型进行测试。
下面示例直接测试上游服务。将地址、模型与凭证替换为当前渠道支持的值;记录错误时移除凭证。FastGPT 渠道配置见模型配置。
curl https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-4o",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
]
}'curl https://api.openai.com/v1/embeddings \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "The food was delicious and the waiter...",
"model": "text-embedding-ada-002",
"encoding_format": "float"
}'curl --location --request POST 'https://xxxx.com/api/v1/rerank' \
--header 'Authorization: Bearer {{ACCESS_TOKEN}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "bge-rerank-m3",
"query": "Who is the director?",
"documents": [
"Who are you?\nI am an assistant for the film Suzume."
]
}'curl https://api.openai.com/v1/audio/speech \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "tts-1",
"input": "The quick brown fox jumped over the lazy dog.",
"voice": "alloy"
}' \
--output speech.mp3curl https://api.openai.com/v1/audio/transcriptions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F file="@/path/to/file/audio.mp3" \
-F model="whisper-1"(2) 报错 - 模型响应为空/模型报错
空响应可能来自上游拒绝请求、参数不兼容或事件流提前结束。检查 FastGPT 模型调用日志,核对实际请求与上游返回。分别验证 JSON 与流式模式;stream: false 有时能返回更完整的错误信息。
可能的报错问题:
- 国内模型命中风控
- 不支持的模型参数:只保留 messages 和必要参数来测试,删除其他参数测试。
- 参数不符合模型要求:例如有的模型 temperature 不支持 0,有些不支持两位小数。max_tokens 超出,上下文超长等。
- 模型部署有问题,stream 模式不兼容。
测试示例如下,可复制报错日志中的请求体进行测试:
curl --location --request POST 'https://api.openai.com/v1/chat/completions' \
--header 'Authorization: Bearer sk-xxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "xxx",
"temperature": 0.01,
"max_tokens": 1000,
"stream": true,
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}'(3) 如何测试模型是否支持工具调用
模型和所选渠道均需支持工具调用。先验证普通对话,再验证以下两轮协议。示例中的地址代表支持 OpenAI Chat Completions 的模型服务或中转地址。
1. 通过 curl 向模型渠道发起第一轮 stream 模式的 tool 测试
curl --location --request POST 'https://model.example.com/v1/chat/completions' \
--header 'Authorization: Bearer sk-xxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "gpt-5",
"temperature": 0.01,
"max_tokens": 8000,
"stream": true,
"messages": [
{
"role": "user",
"content": "What time is it?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_time",
"description": "Get the current time in the user timezone.",
"parameters": {
"type": "object",
"properties": {},
"required": []
}
}
}
],
"tool_choice": "auto"
}'2. 检查响应参数
模型决定调用工具时,流式响应中的 choices[0].delta.tool_calls 提供调用信息。按索引合并分片中的函数名和参数 JSON,保存实际 id。下面是完整片段形状示例:
{
"id": "example-chat-id",
"object": "chat.completion.chunk",
"choices": [{
"index": 0,
"delta": {
"tool_calls": [{
"index": 0,
"id": "example-call-id",
"type": "function",
"function": { "name": "get_time", "arguments": "{}" }
}]
},
"finish_reason": null
}]
}3. 通过 curl 向模型渠道发起第二轮 stream 模式的 tool 测试
第二轮把工具结果发送给模型。使用第一轮实际返回的调用 ID、函数名与参数;example-call-id 是占位符。预期响应会结合工具结果继续回答;模型也可能继续请求工具。
curl --location --request POST 'https://model.example.com/v1/chat/completions' \
--header 'Authorization: Bearer sk-xxx' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "gpt-5",
"temperature": 0.01,
"max_tokens": 8000,
"stream": true,
"messages": [
{
"role": "user",
"content": "What time is it?"
},
{
"role": "assistant",
"tool_calls": [
{
"id": "example-call-id",
"type": "function",
"function": {
"name": "get_time",
"arguments": "{}"
}
}
]
},
{
"tool_call_id": "example-call-id",
"role": "tool",
"name": "get_time",
"content": "{\n \"time\": \"2024-09-14 22:59:21 Sunday\"\n}"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_time",
"description": "Get the current time in the user timezone.",
"parameters": {
"type": "object",
"properties": {},
"required": []
}
}
}
],
"tool_choice": "auto"
}'(4) 向量检索得分大于 1
核对向量模型的归一化设置、向量后端使用的相似度度量及是否启用重排。分数含义随后端和模型变化;用固定样本确认排序与阈值,参见检索参数。
(5) 当前分组上游负载已饱和,请稍后再试
该报错来自 AI Proxy 渠道所连的上游服务(如 OneAPI 等中转或模型服务商)。检查渠道并发、限流、额度与服务健康;记录请求标识后联系相应服务管理员。切换模型前验证其能力和应用行为。
(6) 使用 API 时在日志中报错 Connection Error
从实际发起请求的服务检查 DNS、端口、TLS、代理地址及网络策略,再核对凭证。分别测试上游和 AI Proxy 渠道,确定失败发生在哪一跳。
(7) 开启图片索引报 400
检查返回的具体错误以及图片处理所需的视觉/OCR 能力、格式、模型配置和额度。按当前部署的系统配置与导入模式确认相应服务可用。
文件更新时间