From a9f000e7ef7f0713d474f4e8a8801ce4ee7bc19f Mon Sep 17 00:00:00 2001 From: PaRaD1SE98 Date: Sun, 14 May 2023 01:24:20 +0900 Subject: [PATCH 1/3] remove error messages in toBeSummarizedMsgs --- app/store/chat.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/store/chat.ts b/app/store/chat.ts index cb11087d..b8cdecb6 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -423,7 +423,10 @@ export const useChatStore = create()( let toBeSummarizedMsgs = session.messages.slice( session.lastSummarizeIndex, ); - + + // remove error messages if any + toBeSummarizedMsgs = toBeSummarizedMsgs.filter((msg) => !msg.isError); + const historyMsgLength = countMessages(toBeSummarizedMsgs); if (historyMsgLength > modelConfig?.max_tokens ?? 4000) { From ff2589c97f00abe30d389cc5e71a6b63c561a6c1 Mon Sep 17 00:00:00 2001 From: PaRaD1SE98 Date: Sun, 14 May 2023 02:34:32 +0900 Subject: [PATCH 2/3] remove error messages for chat title summary --- app/store/chat.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/store/chat.ts b/app/store/chat.ts index b8cdecb6..d9a4af78 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -402,14 +402,17 @@ export const useChatStore = create()( summarizeSession() { const session = get().currentSession(); + + // remove error messages if any + const cleanMessages = session.messages.filter((msg) => !msg.isError); // should summarize topic after chating more than 50 words const SUMMARIZE_MIN_LEN = 50; if ( session.topic === DEFAULT_TOPIC && - countMessages(session.messages) >= SUMMARIZE_MIN_LEN + countMessages(cleanMessages) >= SUMMARIZE_MIN_LEN ) { - requestWithPrompt(session.messages, Locale.Store.Prompt.Topic, { + requestWithPrompt(cleanMessages, Locale.Store.Prompt.Topic, { model: "gpt-3.5-turbo", }).then((res) => { get().updateCurrentSession( @@ -420,12 +423,9 @@ export const useChatStore = create()( } const modelConfig = session.mask.modelConfig; - let toBeSummarizedMsgs = session.messages.slice( + let toBeSummarizedMsgs = cleanMessages.slice( session.lastSummarizeIndex, ); - - // remove error messages if any - toBeSummarizedMsgs = toBeSummarizedMsgs.filter((msg) => !msg.isError); const historyMsgLength = countMessages(toBeSummarizedMsgs); From 03163d6a61856dbe52f156d89da80a2ce9f7cb79 Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Sun, 14 May 2023 23:25:22 +0800 Subject: [PATCH 3/3] fix: #1444 async load google fonts --- app/components/home.tsx | 13 ++++++++++++- app/layout.tsx | 5 ----- next.config.mjs | 4 ++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/components/home.tsx b/app/components/home.tsx index 6b34a5a1..810c9fa1 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -23,7 +23,6 @@ import { } from "react-router-dom"; import { SideBar } from "./sidebar"; import { useAppConfig } from "../store/config"; -import { useMaskStore } from "../store/mask"; export function Loading(props: { noLogo?: boolean }) { return ( @@ -91,12 +90,24 @@ const useHasHydrated = () => { return hasHydrated; }; +const loadAsyncGoogleFont = () => { + const linkEl = document.createElement("link"); + linkEl.rel = "stylesheet"; + linkEl.href = + "/google-fonts/css2?family=Noto+Sans+SC:wght@300;400;700;900&display=swap"; + document.head.appendChild(linkEl); +}; + function Screen() { const config = useAppConfig(); const location = useLocation(); const isHome = location.pathname === Path.Home; const isMobileScreen = useMobileScreen(); + useEffect(() => { + loadAsyncGoogleFont(); + }, []); + return (
- - {children} diff --git a/next.config.mjs b/next.config.mjs index c62f8840..da23fd21 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -10,6 +10,10 @@ const nextConfig = { source: "/api/proxy/:path*", destination: "https://api.openai.com/:path*", }, + { + source: "/google-fonts/:path*", + destination: "https://fonts.googleapis.com/:path*", + }, ]; const apiUrl = process.env.API_URL;