diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx index 016b5c445..f3d2bd193 100644 --- a/src/components/Layout/index.tsx +++ b/src/components/Layout/index.tsx @@ -35,7 +35,7 @@ const Layout = ({ children, isPcDevice }: { children: JSX.Element; isPcDevice: b return ( <> - + {isPc ? ( pcUnShowLayoutRoute[router.pathname] ? ( {children} diff --git a/src/pages/api/chat/chat.ts b/src/pages/api/chat/chat.ts index 8374521b1..c6da26596 100644 --- a/src/pages/api/chat/chat.ts +++ b/src/pages/api/chat/chat.ts @@ -103,8 +103,12 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) stream, chatResponse: streamResponse, prompts, - systemPrompt: - showModelDetail && prompts[0].obj === ChatRoleEnum.System ? prompts[0].value : '' + systemPrompt: showModelDetail + ? prompts + .filter((item) => item.obj === ChatRoleEnum.System) + .map((item) => item.value) + .join('\n') + : '' }); // 只有使用平台的 key 才计费 diff --git a/src/pages/model/components/detail/components/ModelDataCard.tsx b/src/pages/model/components/detail/components/ModelDataCard.tsx index 8e6d20d1a..0733caacb 100644 --- a/src/pages/model/components/detail/components/ModelDataCard.tsx +++ b/src/pages/model/components/detail/components/ModelDataCard.tsx @@ -279,9 +279,9 @@ const ModelDataCard = ({ modelId, isOwner }: { modelId: string; isOwner: boolean - + - + diff --git a/src/pages/model/share/index.tsx b/src/pages/model/share/index.tsx index f1a6d44e2..534389b1b 100644 --- a/src/pages/model/share/index.tsx +++ b/src/pages/model/share/index.tsx @@ -101,9 +101,9 @@ const modelList = () => { - + - + diff --git a/src/pages/number/components/BillTable.tsx b/src/pages/number/components/BillTable.tsx index aa1ba74ba..cd0a2e499 100644 --- a/src/pages/number/components/BillTable.tsx +++ b/src/pages/number/components/BillTable.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Card, Box, Table, Thead, Tbody, Tr, Th, Td, TableContainer } from '@chakra-ui/react'; +import { Card, Box, Table, Thead, Tbody, Tr, Th, Td, TableContainer, Flex } from '@chakra-ui/react'; import { BillTypeMap } from '@/constants/user'; import { getUserBills } from '@/api/user'; import type { UserBillType } from '@/types/user'; @@ -48,9 +48,9 @@ const BillTable = () => { - + - + ); }; diff --git a/src/pages/promotion/index.tsx b/src/pages/promotion/index.tsx index be2c1a4ec..bba23053b 100644 --- a/src/pages/promotion/index.tsx +++ b/src/pages/promotion/index.tsx @@ -139,9 +139,9 @@ const OpenApi = () => { - + - + diff --git a/src/service/plugins/searchKb.ts b/src/service/plugins/searchKb.ts index 090674d6c..b6275c5b1 100644 --- a/src/service/plugins/searchKb.ts +++ b/src/service/plugins/searchKb.ts @@ -85,7 +85,8 @@ export const searchKb = async ({ }; const filterRate = filterRateMap[systemPrompts.length] || filterRateMap[0]; - const filterPrompts = [ + // 计算固定提示词的 token 数量 + const fixedPrompts = [ ...(model.chat.systemPrompt ? [ { @@ -94,22 +95,26 @@ export const searchKb = async ({ } ] : []), - ...(model.chat.searchMode !== ModelVectorSearchModeEnum.noContext + ...(model.chat.searchMode === ModelVectorSearchModeEnum.noContext ? [ { obj: ChatRoleEnum.System, - value: `我们来玩问答游戏,规则为: -1.你完全忘记你已有的知识 -2.你只能回答关于"${model.name}"的问题 -3.你只能从知识库中选择内容进行回答 -4.如果问题不在知识库中,你会回答"我不知道。" -务必遵守规则` + value: `知识库是关于"${model.name}"的内容,根据知识库内容回答问题.` } ] - : []) + : [ + { + obj: ChatRoleEnum.System, + value: `我们来玩问答游戏,规则为: +1.你只能回答关于"${model.name}"的问题 +2.你只能从知识库中选择内容进行回答 +3.如果问题不在知识库中,你会回答"我不知道。" +务必遵守规则` + } + ]) ]; const fixedSystemTokens = modelToolMap[model.chat.chatModel].countTokens({ - messages: filterPrompts + messages: fixedPrompts }); const maxTokens = modelConstantsData.systemMaxToken - fixedSystemTokens; @@ -157,7 +162,7 @@ export const searchKb = async ({ obj: ChatRoleEnum.System, value: `知识库:'${filterSystemPrompt}'` }, - ...filterPrompts + ...fixedPrompts ] }; };