forked from XiaoMo/ChatGPT-Next-Web
feat: optimize loading screen
This commit is contained in:
parent
caec01269a
commit
9398b34b5c
@ -8,8 +8,6 @@ async function createStream(payload: ReadableStream<Uint8Array>) {
|
|||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const decoder = new TextDecoder();
|
const decoder = new TextDecoder();
|
||||||
|
|
||||||
console.log("[ChatStream]", payload);
|
|
||||||
|
|
||||||
const res = await fetch("https://api.openai.com/v1/chat/completions", {
|
const res = await fetch("https://api.openai.com/v1/chat/completions", {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@ -51,11 +49,10 @@ async function createStream(payload: ReadableStream<Uint8Array>) {
|
|||||||
|
|
||||||
export async function POST(req: NextRequest) {
|
export async function POST(req: NextRequest) {
|
||||||
try {
|
try {
|
||||||
console.log("Request", req);
|
|
||||||
const stream = await createStream(req.body!);
|
const stream = await createStream(req.body!);
|
||||||
return new Response(stream);
|
return new Response(stream);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error("[Chat Stream]", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ export async function POST(req: Request) {
|
|||||||
|
|
||||||
return new Response(JSON.stringify(completion.data));
|
return new Response(JSON.stringify(completion.data));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.error("[Chat] ", e);
|
||||||
return new Response(JSON.stringify(e));
|
return new Response(JSON.stringify(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -338,4 +338,10 @@
|
|||||||
|
|
||||||
.export-content {
|
.export-content {
|
||||||
white-space: break-spaces;
|
white-space: break-spaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-content {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
BIN
app/favicon.ico
BIN
app/favicon.ico
Binary file not shown.
Before Width: | Height: | Size: 8.7 KiB |
@ -1,5 +1,5 @@
|
|||||||
import "./globals.scss";
|
import "./styles/globals.scss";
|
||||||
import "./markdown.scss";
|
import "./styles/markdown.scss";
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
title: "ChatGPT Next Web",
|
title: "ChatGPT Next Web",
|
||||||
|
Loading…
Reference in New Issue
Block a user