zhu327 / gemini-openai-proxy

A proxy for converting the OpenAI API protocol to the Google Gemini Pro protocol.
MIT License
504 stars 92 forks source link

[疑似BUG] 请求gpt-4-vision-preview时报错 #28

Closed Nothingness-Void closed 2 months ago

Nothingness-Void commented 2 months ago
{
  "error": {
    "headers": {
      "alt-svc": "h3=\":443\"; ma=86400",
      "cf-cache-status": "DYNAMIC",
      "cf-ray": "8759f2923a5d369e-YYZ",
      "connection": "keep-alive",
      "content-length": "131",
      "content-type": "application/json; charset=utf-8",
      "date": "Wed, 17 Apr 2024 05:17:14 GMT",
      "nel": "{\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}",
      "report-to": "{\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v4?s=fV7mNNt1AvY1ZIWrL3ayQ0vCV7tjzAs0nA4pJMJCpR0wDIFcL%2BmQ7N2M4CLsOzXZy%2BRa3duFEtAgXdQYsH0uRE04%2BOM883x86W6Q2A325UVwvHc6mH150tmI7fFyl%2BNvDw8W2U0%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}",
      "server": "cloudflare"
    },
    "stack": "Error: 400 status code (no body)\n    at eP.generate (/app/.next/server/edge-chunks/316.js:4:1718)\n    at s_.makeStatusError (/app/.next/server/edge-chunks/316.js:4:14205)\n    at s_.makeRequest (/app/.next/server/edge-chunks/316.js:4:15128)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async Object.chat (/app/.next/server/edge-chunks/708.js:1:2328)\n    at async /app/.next/server/app/api/chat/[provider]/route.js:1:1500\n    at async /app/.next/server/edge-chunks/369.js:6:64203\n    at async O.execute (/app/.next/server/edge-chunks/369.js:6:61096)\n    at async O.handle (/app/.next/server/edge-chunks/369.js:6:65470)\n    at async ey.handler (/app/.next/server/edge-chunks/369.js:7:31644)",
    "status": 400
  },
  "endpoint": "https://gemini.nvoid.***.ua/v1",
  "provider": "openai"
}

请求应用为LobeChat image 服务搭建完测试没问题 已增加环境变量使vision指向gemini1.5-pro image 正常请求1.5-pro没问题

zhu327 commented 2 months ago

Error 400 means that the input data is incorrect. You need to provide the specific input data of the API call to confirm the problem.

Nothingness-Void commented 2 months ago

Error 400 means that the input data is incorrect. You need to provide the specific input data of the API call to confirm the problem.

因为我也是用的别人的项目,我也不知道他们的请求格式是怎样的 我尝试了另一个项目 One-API 仅请求vision时 也会返回如下报错

{
  "error": {
    "message": "message.multiContent: json.Unmarshal: json: cannot unmarshal string into Go value of type []openai.ChatMessagePart (request id: 2024041713413320632400558692646)",
    "type": "upstream_error",
    "param": "400",
    "code": "bad_response_status_code"
  }
}

请求别的模型是正常的

zhu327 commented 2 months ago
curl http://localhost:8080/v1/chat/completions \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer $YOUR_GOOGLE_AI_STUDIO_API_KEY" \
 -d '{
     "model": "gpt-4-vision-preview",
     "messages": [{"role": "user", "content": [
        {"type": "text", "text": "What’s in this image?"},
        {
          "type": "image_url",
          "image_url": {
            "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
          }
        }
     ]}],
     "temperature": 0.7
 }'

The data format of GPT-4-vision-preview is different from that of GPT-3.5-turbo. Incorrect data formats will cause errors