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/app/store/chat.ts b/app/store/chat.ts index 9c58c852..8fa32724 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -407,13 +407,16 @@ 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 ) { - const topicMessages = session.messages.concat( + const topicMessages = cleanMessages.concat( createMessage({ role: "user", content: Locale.Store.Prompt.Topic, @@ -435,7 +438,7 @@ export const useChatStore = create()( } const modelConfig = session.mask.modelConfig; - let toBeSummarizedMsgs = session.messages.slice( + let toBeSummarizedMsgs = cleanMessages.slice( session.lastSummarizeIndex, ); 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;