lobehub / lobe-chat

🤯 Lobe Chat - an open-source, modern-design AI chat framework. Supports Multi AI Providers( OpenAI / Claude 3 / Gemini / Ollama / Azure / DeepSeek), Knowledge Base (file upload / knowledge management / RAG ), Multi-Modals (Vision/TTS) and plugin system. One-click FREE deployment of your private ChatGPT/ Claude application.
https://chat-preview.lobehub.com
Other
42.57k stars 9.61k forks source link

[Bug] 助手SHareGPT分享失败 #4321

Open SAnBlog opened 2 days ago

SAnBlog commented 2 days ago

📦 Environment

Docker

📌 Version

v1.21.8

💻 Operating System

macOS

🌐 Browser

Chrome

🐛 Bug Description

image

📷 Recurrence Steps

No response

🚦 Expected Behavior

No response

📝 Additional Information

No response

lobehubbot commented 2 days ago

👀 @SAnBlog

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible. Please make sure you have given us as much context as possible.\ 非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

dosubot[bot] commented 2 days ago

To resolve the 405 error and the "Unexpected end of JSON input" SyntaxError in the createShareGPTUrl function, try the following:

  1. 405 Error (Method Not Allowed):

    • Verify that the endpoint https://sharegpt.com/api/conversations supports the POST method. If not, use the correct HTTP method.
    • Double-check the URL for any typos or incorrect paths.
  2. "Unexpected end of JSON input" SyntaxError:

    • This error usually occurs when the response body is empty or not valid JSON. Ensure the API returns a valid JSON response.
    • Check if the API requires additional headers or authentication that might be missing.

Here's a code snippet to handle the response and avoid the SyntaxError:

const res = await fetch(SHARE_GPT_URL, {
  body: JSON.stringify({ ...conversation, items }),
  headers: {
    'Content-Type': 'application/json',
  },
  method: 'POST',
});

if (!res.ok) {
  throw new Error(`HTTP error! status: ${res.status}`);
}

const data = await res.json();

if (!data.id) throw new Error('Failed to create ShareGPT URL');

return `https://shareg.pt/${data.id}`;

This checks if the response is OK before parsing the JSON, helping diagnose request issues [1][2][3].

To continue talking to Dosu, mention @dosu.

arvinxx commented 2 days ago
image

ShareGPT 挂了,正在想替代方案