From ca4cd8af9dcd9c17a735262ffba58b22cf224e9a Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Mon, 12 Jun 2023 20:52:51 +0800 Subject: [PATCH] fix: sse --- client/src/pages/api/chat/chat.ts | 2 +- client/src/pages/api/chat/shareChat/chat.ts | 2 +- client/src/pages/api/openapi/chat/chat.ts | 2 +- client/src/pages/chat/index.tsx | 2 +- .../model/components/detail/components/ModelEditForm.tsx | 6 +++--- client/src/pages/number/components/BillTable.tsx | 4 ++-- client/src/pages/number/components/InformTable.tsx | 2 +- client/src/pages/number/components/PayRecordTable.tsx | 2 +- client/src/pages/number/components/PromotionTable.tsx | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/client/src/pages/api/chat/chat.ts b/client/src/pages/api/chat/chat.ts index 25acb0c3ed..e7119fe65d 100644 --- a/client/src/pages/api/chat/chat.ts +++ b/client/src/pages/api/chat/chat.ts @@ -58,7 +58,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) guidePrompt = '' } = await (async () => { // 使用了知识库搜索 - if (model.chat.relatedKbs.length > 0) { + if (model.chat.relatedKbs?.length > 0) { const { code, searchPrompts, rawSearch, guidePrompt } = await appKbSearch({ model, userId, diff --git a/client/src/pages/api/chat/shareChat/chat.ts b/client/src/pages/api/chat/shareChat/chat.ts index be2408c245..9b2ca6dc52 100644 --- a/client/src/pages/api/chat/shareChat/chat.ts +++ b/client/src/pages/api/chat/shareChat/chat.ts @@ -43,7 +43,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) const { code = 200, systemPrompts = [] } = await (async () => { // 使用了知识库搜索 - if (model.chat.relatedKbs.length > 0) { + if (model.chat.relatedKbs?.length > 0) { const { code, searchPrompts } = await appKbSearch({ model, userId, diff --git a/client/src/pages/api/openapi/chat/chat.ts b/client/src/pages/api/openapi/chat/chat.ts index 740aa84aba..2c32445a06 100644 --- a/client/src/pages/api/openapi/chat/chat.ts +++ b/client/src/pages/api/openapi/chat/chat.ts @@ -73,7 +73,7 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex }[] = []; // 使用了知识库搜索 - if (model.chat.relatedKbs.length > 0) { + if (model.chat.relatedKbs?.length > 0) { const { code, searchPrompts } = await appKbSearch({ model, userId, diff --git a/client/src/pages/chat/index.tsx b/client/src/pages/chat/index.tsx index acbf4f4e15..40253c43b2 100644 --- a/client/src/pages/chat/index.tsx +++ b/client/src/pages/chat/index.tsx @@ -645,7 +645,7 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => { fontSize={['sm', 'md']} onClick={() => router.push(`/model?modelId=${chatData.modelId}`)} > - {chatData.model.name} {ChatModelMap[chatData.chatModel].name} + {chatData.model.name} {ChatModelMap[chatData.chatModel]?.name} {chatData.history.length > 0 ? ` (${chatData.history.length})` : ''} {chatId ? ( diff --git a/client/src/pages/model/components/detail/components/ModelEditForm.tsx b/client/src/pages/model/components/detail/components/ModelEditForm.tsx index 0d3e3368c3..7f3476d5cd 100644 --- a/client/src/pages/model/components/detail/components/ModelEditForm.tsx +++ b/client/src/pages/model/components/detail/components/ModelEditForm.tsx @@ -175,7 +175,7 @@ ${e.password ? `密码为: ${e.password}` : ''}`; // init kb select list const { data: kbList = [] } = useQuery(['loadKbList'], () => loadKbList()); const RenderSelectedKbList = useCallback(() => { - const kbs = getValues('chat.relatedKbs').map((id) => kbList.find((kb) => kb._id === id)); + const kbs = getValues('chat.relatedKbs')?.map((id) => kbList.find((kb) => kb._id === id)) || []; return ( <> @@ -334,7 +334,7 @@ ${e.password ? `密码为: ${e.password}` : ''}`; - {getValues('chat.relatedKbs').length > 0 && ( + {getValues('chat.relatedKbs')?.length > 0 && ( 搜索模式  @@ -583,7 +583,7 @@ ${e.password ? `密码为: ${e.password}` : ''}`; {kbList.map((item) => ( { const ids = getValues('chat.relatedKbs'); // toggle to true diff --git a/client/src/pages/number/components/BillTable.tsx b/client/src/pages/number/components/BillTable.tsx index d21352d8fe..3869ebd3b9 100644 --- a/client/src/pages/number/components/BillTable.tsx +++ b/client/src/pages/number/components/BillTable.tsx @@ -23,7 +23,7 @@ const BillTable = () => { return ( <> - + @@ -53,7 +53,7 @@ const BillTable = () => { {!isLoading && bills.length === 0 && ( - + 无使用记录~ diff --git a/client/src/pages/number/components/InformTable.tsx b/client/src/pages/number/components/InformTable.tsx index bf3acc6d80..6ed8aac510 100644 --- a/client/src/pages/number/components/InformTable.tsx +++ b/client/src/pages/number/components/InformTable.tsx @@ -71,7 +71,7 @@ const BillTable = () => { ))} {!isLoading && informs.length === 0 && ( - + 暂无通知~ diff --git a/client/src/pages/number/components/PayRecordTable.tsx b/client/src/pages/number/components/PayRecordTable.tsx index 11c1d49663..fd1bb021d9 100644 --- a/client/src/pages/number/components/PayRecordTable.tsx +++ b/client/src/pages/number/components/PayRecordTable.tsx @@ -92,7 +92,7 @@ const PayRecordTable = () => {
{!isInitialLoading && payOrders.length === 0 && ( - + 无支付记录~ diff --git a/client/src/pages/number/components/PromotionTable.tsx b/client/src/pages/number/components/PromotionTable.tsx index 65686d64bc..449f18130f 100644 --- a/client/src/pages/number/components/PromotionTable.tsx +++ b/client/src/pages/number/components/PromotionTable.tsx @@ -23,7 +23,7 @@ const OpenApi = () => { return ( <> - +