suspense
parent
fe8626cf9d
commit
6415e3032c
|
@ -1,14 +1,16 @@
|
||||||
|
import React, { Suspense } from 'react';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import slugify from 'slugify';
|
import slugify from 'slugify';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { Loader } from '@mantine/core';
|
import { Loader } from '@mantine/core';
|
||||||
|
|
||||||
import Message from '../message';
|
|
||||||
import { useAppContext } from '../../context';
|
import { useAppContext } from '../../context';
|
||||||
import { backend } from '../../backend';
|
import { backend } from '../../backend';
|
||||||
import { Page } from '../page';
|
import { Page } from '../page';
|
||||||
|
|
||||||
|
const Message = React.lazy(() => import(/* webpackChunkName: "message" */ '../message'));
|
||||||
|
|
||||||
const Messages = styled.div`
|
const Messages = styled.div`
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
@ -81,6 +83,11 @@ export default function ChatPage(props: any) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}}>
|
}}>
|
||||||
|
<Suspense fallback={<Messages id="messages">
|
||||||
|
<EmptyMessage>
|
||||||
|
<Loader variant="dots" />
|
||||||
|
</EmptyMessage>
|
||||||
|
</Messages>}>
|
||||||
<Messages id="messages">
|
<Messages id="messages">
|
||||||
{shouldShowChat && (
|
{shouldShowChat && (
|
||||||
<div style={{ paddingBottom: '4.5rem' }}>
|
<div style={{ paddingBottom: '4.5rem' }}>
|
||||||
|
@ -96,5 +103,6 @@ export default function ChatPage(props: any) {
|
||||||
<Loader variant="dots" />
|
<Loader variant="dots" />
|
||||||
</EmptyMessage>}
|
</EmptyMessage>}
|
||||||
</Messages>
|
</Messages>
|
||||||
|
</Suspense>
|
||||||
</Page>;
|
</Page>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { OpenAIMessage } from "./types";
|
||||||
let enc: any;
|
let enc: any;
|
||||||
|
|
||||||
setTimeout(async () => {
|
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");
|
enc = encoding_for_model("gpt-3.5-turbo");
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue