From f2485931d9b3680234f4816f4526759c8d4b741e Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Sun, 19 Nov 2023 19:15:11 +0800 Subject: [PATCH] feat: better animation speed --- app/client/platforms/openai.ts | 8 +++++--- app/locales/index.ts | 2 +- app/locales/pt.ts | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/client/platforms/openai.ts b/app/client/platforms/openai.ts index dc79d2cec..8ea864692 100644 --- a/app/client/platforms/openai.ts +++ b/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); diff --git a/app/locales/index.ts b/app/locales/index.ts index 1d84de22c..cfbdff297 100644 --- a/app/locales/index.ts +++ b/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, diff --git a/app/locales/pt.ts b/app/locales/pt.ts index e984dc99a..55a404970 100644 --- a/app/locales/pt.ts +++ b/app/locales/pt.ts @@ -145,7 +145,7 @@ const pt: LocaleType = { }, }, Lang: { - Name: "Idioma", + Name: "Language", All: "Todos os Idiomas", }, Avatar: "Avatar",