mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-09-25 17:15:19 +08:00
chore: fix error message and readable message for openai key missing
This commit is contained in:
@ -218,8 +218,7 @@ const ConversationView = () => {
|
||||
let errorMessage =
|
||||
"Failed to request message, please check your network.";
|
||||
try {
|
||||
const res = await rawRes.json();
|
||||
errorMessage = res.error.message;
|
||||
errorMessage = await rawRes.statusText;
|
||||
} catch (error) {
|
||||
// do nth
|
||||
}
|
||||
|
@ -30,6 +30,15 @@ const handler = async (req: NextRequest) => {
|
||||
const reqBody = await req.json();
|
||||
const openAIApiConfig = reqBody.openAIApiConfig;
|
||||
const apiKey = openAIApiConfig?.key || openAIApiKey;
|
||||
|
||||
if (!apiKey) {
|
||||
return new Response("Unauthorized", {
|
||||
status: 401,
|
||||
statusText:
|
||||
"OpenAI API Key is missing. You can supply your own key via Settings.",
|
||||
});
|
||||
}
|
||||
|
||||
const apiEndpoint = getApiEndpoint(
|
||||
openAIApiConfig?.endpoint || openAIApiEndpoint
|
||||
);
|
||||
|
Reference in New Issue
Block a user