Browse Source

Merge pull request #1586 from Yidadaa/bugfix-0518

chore: wont parse finished result
Yifei Zhang 1 năm trước cách đây
mục cha
commit
f0cb2fc21a
2 tập tin đã thay đổi với 2 bổ sung3 xóa
  1. 1 2
      app/api/auth.ts
  2. 1 1
      app/client/platforms/openai.ts

+ 1 - 2
app/api/auth.ts

@@ -3,8 +3,6 @@ import { getServerSideConfig } from "../config/server";
 import md5 from "spark-md5";
 import { ACCESS_CODE_PREFIX } from "../constant";
 
-const serverConfig = getServerSideConfig();
-
 function getIP(req: NextRequest) {
   let ip = req.ip ?? req.headers.get("x-real-ip");
   const forwardedFor = req.headers.get("x-forwarded-for");
@@ -34,6 +32,7 @@ export function auth(req: NextRequest) {
 
   const hashedCode = md5.hash(accessCode ?? "").trim();
 
+  const serverConfig = getServerSideConfig();
   console.log("[Auth] allowed hashed codes: ", [...serverConfig.codes]);
   console.log("[Auth] got access code:", accessCode);
   console.log("[Auth] hashed access code:", hashedCode);

+ 1 - 1
app/client/platforms/openai.ts

@@ -123,7 +123,7 @@ export class ChatGPTApi implements LLMApi {
             }
           },
           onmessage(msg) {
-            if (msg.data === "[DONE]") {
+            if (msg.data === "[DONE]" || finished) {
               return finish();
             }
             const text = msg.data;