mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-09-24 08:36:18 +08:00
fix: update response body type
This commit is contained in:
@ -28,14 +28,19 @@ const handler = async (req: NextRequest) => {
|
|||||||
const apiKey = openAIApiConfig?.key || openAIApiKey;
|
const apiKey = openAIApiConfig?.key || openAIApiKey;
|
||||||
|
|
||||||
if (!apiKey) {
|
if (!apiKey) {
|
||||||
const stream = new ReadableStream({
|
return new Response(
|
||||||
async start(controller) {
|
JSON.stringify({
|
||||||
controller.error(new Error("OpenAI API Key is missing. You can supply your own key via Settings."));
|
error: {
|
||||||
},
|
message: "OpenAI API Key is missing. You can supply your own key via Settings.",
|
||||||
});
|
},
|
||||||
return new Response(stream, {
|
}),
|
||||||
status: 401,
|
{
|
||||||
});
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
status: 401,
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiEndpoint = getApiEndpoint(openAIApiConfig?.endpoint || openAIApiEndpoint);
|
const apiEndpoint = getApiEndpoint(openAIApiConfig?.endpoint || openAIApiEndpoint);
|
||||||
|
Reference in New Issue
Block a user