diff --git a/app/src/components/pages/chat.tsx b/app/src/components/pages/chat.tsx index 4a14b32..4f93fcc 100644 --- a/app/src/components/pages/chat.tsx +++ b/app/src/components/pages/chat.tsx @@ -1,14 +1,16 @@ +import React, { Suspense } from 'react'; import styled from '@emotion/styled'; import slugify from 'slugify'; import { useEffect } from 'react'; import { useParams } from 'react-router-dom'; import { Loader } from '@mantine/core'; -import Message from '../message'; import { useAppContext } from '../../context'; import { backend } from '../../backend'; import { Page } from '../page'; +const Message = React.lazy(() => import(/* webpackChunkName: "message" */ '../message')); + const Messages = styled.div` max-height: 100%; flex-grow: 1; @@ -81,20 +83,26 @@ export default function ChatPage(props: any) { } }, }}> - - {shouldShowChat && ( -
- {messagesToDisplay.map((message) => ( - n.id === message.id)} /> - ))} -
- )} - {!shouldShowChat && + + - } -
+ + }> + + {shouldShowChat && ( +
+ {messagesToDisplay.map((message) => ( + n.id === message.id)} /> + ))} +
+ )} + {!shouldShowChat && + + } +
+ ; } diff --git a/app/src/tokenizer.ts b/app/src/tokenizer.ts index 42ddc68..231bae5 100644 --- a/app/src/tokenizer.ts +++ b/app/src/tokenizer.ts @@ -3,7 +3,7 @@ import { OpenAIMessage } from "./types"; let enc: any; setTimeout(async () => { - const { encoding_for_model } = await import("./tiktoken/dist/tiktoken"); + const { encoding_for_model } = await import(/* webpackChunkName: "tiktoken" */ "./tiktoken/dist/tiktoken"); enc = encoding_for_model("gpt-3.5-turbo"); }, 2000);