Browse Source

feat: better animation speed

Yidadaa 1 year ago
parent
commit
f2485931d9
3 changed files with 7 additions and 5 deletions
  1. 5 3
      app/client/platforms/openai.ts
  2. 1 1
      app/locales/index.ts
  3. 1 1
      app/locales/pt.ts

+ 5 - 3
app/client/platforms/openai.ts

@@ -127,9 +127,11 @@ export class ChatGPTApi implements LLMApi {
           }
 
           if (remainText.length > 0) {
-            responseText += remainText[0];
-            remainText = remainText.slice(1);
-            options.onUpdate?.(responseText, remainText[0]);
+            const fetchCount = Math.max(1, Math.round(remainText.length / 60));
+            const fetchText = remainText.slice(0, fetchCount);
+            responseText += fetchText;
+            remainText = remainText.slice(fetchCount);
+            options.onUpdate?.(responseText, fetchText);
           }
 
           requestAnimationFrame(animateResponseText);

+ 1 - 1
app/locales/index.ts

@@ -24,8 +24,8 @@ export type { LocaleType, PartialLocaleType } from "./cn";
 const ALL_LANGS = {
   cn,
   en,
-  pt,
   tw,
+  pt,
   jp,
   ko,
   id,

+ 1 - 1
app/locales/pt.ts

@@ -145,7 +145,7 @@ const pt: LocaleType = {
       },
     },
     Lang: {
-      Name: "Idioma",
+      Name: "Language",
       All: "Todos os Idiomas",
     },
     Avatar: "Avatar",