perf:提示文案;错误处理

This commit is contained in:
Archer
2023-03-13 19:48:19 +08:00
parent b204c55bd1
commit 138b607ac7
6 changed files with 13 additions and 26 deletions

View File

@@ -80,20 +80,6 @@ const Layout = ({ children }: { children: JSX.Element }) => {
</Box>
</Box>
)}
<Box
textAlign={'center'}
backgroundColor={'#fff'}
p={4}
position={'absolute'}
bottom={0}
left={0}
right={0}
>
<Box>@ Make by Archer</Box>
<Link href={'https://beian.miit.gov.cn/'} target={'_blank'}>
ICP备19010228号-1
</Link>
</Box>
</Box>
) : (
<Auth>

View File

@@ -82,6 +82,9 @@ export const theme = extendTheme({
'8xl': '6rem',
'9xl': '8rem'
},
fonts: {
body: '-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"'
},
components: {
Modal: ModalTheme,
Button

View File

@@ -30,8 +30,8 @@ export default function App({ Component, pageProps }: AppProps) {
return (
<>
<Head>
<title></title>
<meta name="description" content="Generated by Doc GPT" />
<title>Fast GPT</title>
<meta name="description" content="Generated by Fast GPT" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;"

View File

@@ -18,6 +18,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
res.on('close', () => {
res.end();
});
req.on('error', () => {
res.end();
});
const { chatId, windowId } = req.query as { chatId: string; windowId: string };
@@ -114,14 +117,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}
};
try {
for await (const chunk of chatResponse.data as any) {
const parser = createParser(onParse);
parser.feed(decoder.decode(chunk));
}
} catch (error) {
console.log(error, '====');
throw new Error('错误了');
for await (const chunk of chatResponse.data as any) {
const parser = createParser(onParse);
parser.feed(decoder.decode(chunk));
}
} catch (err: any) {
console.log('error->', err?.response, '===');

View File

@@ -13,7 +13,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
const { authorization } = req.headers;
if (!authorization) {
throw new Error('缺少参数');
throw new Error('无权操作');
}
const userId = await authToken(authorization);

View File

@@ -2,5 +2,5 @@ export const openaiError: Record<string, string> = {
context_length_exceeded: '内容超长了,请重置对话',
Unauthorized: 'API-KEY 不合法',
rate_limit_reached: '同时访问用户过多,请稍后再试',
'Bad Request': '内容太多了~'
'Bad Request': '上下文太多了,请重开对话~'
};