mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-09-26 17:45:14 +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 =
|
let errorMessage =
|
||||||
"Failed to request message, please check your network.";
|
"Failed to request message, please check your network.";
|
||||||
try {
|
try {
|
||||||
const res = await rawRes.json();
|
errorMessage = await rawRes.statusText;
|
||||||
errorMessage = res.error.message;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// do nth
|
// do nth
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,15 @@ const handler = async (req: NextRequest) => {
|
|||||||
const reqBody = await req.json();
|
const reqBody = await req.json();
|
||||||
const openAIApiConfig = reqBody.openAIApiConfig;
|
const openAIApiConfig = reqBody.openAIApiConfig;
|
||||||
const apiKey = openAIApiConfig?.key || openAIApiKey;
|
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(
|
const apiEndpoint = getApiEndpoint(
|
||||||
openAIApiConfig?.endpoint || openAIApiEndpoint
|
openAIApiConfig?.endpoint || openAIApiEndpoint
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user