From 9398b34b5c248c3d6e7f2c79824e133fd666895d Mon Sep 17 00:00:00 2001 From: Yifei Zhang Date: Sun, 19 Mar 2023 14:13:00 +0000 Subject: [PATCH] feat: optimize loading screen --- app/api/chat-stream/route.ts | 5 +---- app/api/chat/route.ts | 1 + app/components/home.module.scss | 6 ++++++ app/favicon.ico | Bin 8912 -> 0 bytes app/layout.tsx | 4 ++-- app/{ => styles}/globals.scss | 0 app/{ => styles}/markdown.scss | 0 7 files changed, 10 insertions(+), 6 deletions(-) delete mode 100644 app/favicon.ico rename app/{ => styles}/globals.scss (100%) rename app/{ => styles}/markdown.scss (100%) diff --git a/app/api/chat-stream/route.ts b/app/api/chat-stream/route.ts index 789a1b9..16c5950 100644 --- a/app/api/chat-stream/route.ts +++ b/app/api/chat-stream/route.ts @@ -8,8 +8,6 @@ async function createStream(payload: ReadableStream) { const encoder = new TextEncoder(); const decoder = new TextDecoder(); - console.log("[ChatStream]", payload); - const res = await fetch("https://api.openai.com/v1/chat/completions", { headers: { "Content-Type": "application/json", @@ -51,11 +49,10 @@ async function createStream(payload: ReadableStream) { export async function POST(req: NextRequest) { try { - console.log("Request", req); const stream = await createStream(req.body!); return new Response(stream); } catch (error) { - console.error(error); + console.error("[Chat Stream]", error); } } diff --git a/app/api/chat/route.ts b/app/api/chat/route.ts index 27ce118..c4e41ca 100644 --- a/app/api/chat/route.ts +++ b/app/api/chat/route.ts @@ -20,6 +20,7 @@ export async function POST(req: Request) { return new Response(JSON.stringify(completion.data)); } catch (e) { + console.error("[Chat] ", e); return new Response(JSON.stringify(e)); } } diff --git a/app/components/home.module.scss b/app/components/home.module.scss index 3a5365a..0ef3d75 100644 --- a/app/components/home.module.scss +++ b/app/components/home.module.scss @@ -338,4 +338,10 @@ .export-content { white-space: break-spaces; +} + +.loading-content { + display: flex; + justify-content: center; + align-items: center; } \ No newline at end of file diff --git a/app/favicon.ico b/app/favicon.ico deleted file mode 100644 index 68b7b77f3ee1826539169d16347b509d6edeaed2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8912 zcmeI1L13R&v)ICWg}tCKTq75W%q?O!6kTf*99~1&(_;J zZLQS^ZP7X{OSbM@!&cfmJ(#VvcO}n)V|Jx=E*;NGvm3MX z?<~#O+3{CweEd~A^669d6g%E^8Uoc>$%^F zlh4`r-@P4S%=c+^_~;XM^`GDD=bsMR{*NEDEA!*_$Lw)ygg6#1pRwtw5A6Ms`|axT ztZ=SNw`;3&_SSp%+J^@ow&@@C+ohSKHg@VoJN@-bc5>{6+<)%(FYNr}oAzh>+miqC z;*@=K@DaPV(zJ8myk-XuJ!;E~)3)~auQq!8>7G9rt>&qcKRPo=Anf zK6}^Q&zU?IYGQr)lJgJyN6owXp--()Gt>?>^yOF2+vMaMk#GJRX;jrOHH)UyaE#x3 z4)vS=25#c_qu=4p{C*|V8|2>muEqRd`M8x!j3-?b5A*aDlg1+AEfLt>Z88GUwy=S}9-U0hgLE6$cnJ zjYl@g>#LG^6dHO%MTlI@|@(A4|%CCu2{R6PaOE+ujj}nd08Voe7#vCK$r74`^#lnk?^-kk;&$pXBw}K6~Z*ZltD>cl|Ih^l?J=YC=mh<}P)-E+{tr$kNXzfQ+nLD;9e%~|BbCL#`VQm#XRf_)W4{Qewo%6v$Es1wzi`l@x+oa#lb#dy8cr8|$6I(m#Ici*e;8zE{_2{WkKeFUC5