diff --git a/client/data/SystemParams.json b/client/data/SystemParams.json index 08a807e07..e7bcacd4d 100644 --- a/client/data/SystemParams.json +++ b/client/data/SystemParams.json @@ -1,6 +1,6 @@ { - "vectorMaxProcess": 10, - "qaMaxProcess": 10, - "pgIvfflatProbe": 10, + "vectorMaxProcess": 15, + "qaMaxProcess": 15, + "pgIvfflatProbe": 20, "sensitiveCheck": false } diff --git a/client/src/components/ChatBox/index.tsx b/client/src/components/ChatBox/index.tsx index face96074..db6a6bde6 100644 --- a/client/src/components/ChatBox/index.tsx +++ b/client/src/components/ChatBox/index.tsx @@ -5,7 +5,8 @@ import React, { useMemo, forwardRef, useImperativeHandle, - ForwardedRef + ForwardedRef, + useEffect } from 'react'; import { throttle } from 'lodash'; import { ChatItemType, ChatSiteItemType, ExportChatType } from '@/types/chat'; @@ -31,6 +32,7 @@ import { MessageItemType } from '@/pages/api/openapi/v1/chat/completions'; import MyTooltip from '../MyTooltip'; import { fileDownload } from '@/utils/file'; import { htmlTemplate } from '@/constants/common'; +import { useRouter } from 'next/router'; import dynamic from 'next/dynamic'; const QuoteModal = dynamic(() => import('./QuoteModal')); @@ -133,6 +135,7 @@ const ChatBox = ( ) => { const ChatBoxRef = useRef(null); const theme = useTheme(); + const router = useRouter(); const { copyData } = useCopyData(); const { toast } = useToast(); const { userInfo } = useUserStore(); @@ -392,6 +395,12 @@ const ChatBox = ( [chatHistory.length, showEmptyIntro, variableModules, welcomeText] ); + useEffect(() => { + return () => { + controller.current?.abort(); + }; + }, [router.query]); + return ( diff --git a/client/src/components/Markdown/index.tsx b/client/src/components/Markdown/index.tsx index c0616f985..aaccb671f 100644 --- a/client/src/components/Markdown/index.tsx +++ b/client/src/components/Markdown/index.tsx @@ -1,4 +1,4 @@ -import React, { useRef } from 'react'; +import React, { useMemo, useRef } from 'react'; import ReactMarkdown from 'react-markdown'; import RemarkGfm from 'remark-gfm'; import RemarkMath from 'remark-math'; @@ -48,13 +48,16 @@ const Markdown = ({ isChatting?: boolean; onClick?: (e: any) => void; }) => { - const components = useRef({ - a: Link, - img: Image, - pre: 'div', - p: 'div', - code: (props: any) => - }); + const components = useMemo( + () => ({ + a: Link, + img: Image, + pre: 'div', + p: 'div', + code: (props: any) => + }), + [onClick] + ); return ( {source} diff --git a/client/src/pages/api/app/modules/chat/gpt.ts b/client/src/pages/api/app/modules/chat/gpt.ts index 59c7d14c3..d763c7c4d 100644 --- a/client/src/pages/api/app/modules/chat/gpt.ts +++ b/client/src/pages/api/app/modules/chat/gpt.ts @@ -89,6 +89,14 @@ export async function chatCompletion({ // FastGpt temperature range: 1~10 temperature = +(modelConstantsData.maxTemperature * (temperature / 10)).toFixed(2); + const limitText = (() => { + if (limitPrompt) return limitPrompt; + if (quotePrompt && !limitPrompt) { + return '根据知识库内容回答问题,仅回复知识库提供的内容。'; + } + return ''; + })(); + const messages: ChatItemType[] = [ ...(quotePrompt ? [ @@ -107,11 +115,11 @@ export async function chatCompletion({ ] : []), ...history, - ...(limitPrompt + ...(limitText ? [ { obj: ChatRoleEnum.System, - value: limitPrompt + value: limitText } ] : []), diff --git a/client/src/pages/api/openapi/v1/chat/completions.ts b/client/src/pages/api/openapi/v1/chat/completions.ts index 74b5ac703..18007f384 100644 --- a/client/src/pages/api/openapi/v1/chat/completions.ts +++ b/client/src/pages/api/openapi/v1/chat/completions.ts @@ -145,7 +145,7 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex }); } - console.log(`finish time: ${(Date.now() - startTime) / 100}s`); + console.log(`finish time: ${(Date.now() - startTime) / 1000}s`); if (stream) { sseResponse({ diff --git a/client/src/pages/app/list/component/CreateModal.tsx b/client/src/pages/app/list/component/CreateModal.tsx index ff22ec9fe..64571438a 100644 --- a/client/src/pages/app/list/component/CreateModal.tsx +++ b/client/src/pages/app/list/component/CreateModal.tsx @@ -23,6 +23,7 @@ import { postCreateApp } from '@/api/app'; import { useRouter } from 'next/router'; import { appTemplates } from '@/constants/flow/ModuleTemplate'; import Avatar from '@/components/Avatar'; +import MyTooltip from '@/components/MyTooltip'; type FormType = { avatar: string; @@ -102,21 +103,22 @@ const CreateModal = ({ onClose, onSuccess }: { onClose: () => void; onSuccess: ( - 开始创建你的 AI 应用 + 创建属于你的 AI 应用 取个响亮的名字 - + + + { const newTitle = prompts[0].content?.slice(0, 20) || '新对话'; // update history - if (newChatId) { + if (newChatId && !controller.signal.aborted) { forbidRefresh.current = true; const newHistory: ChatHistoryItemType = { _id: newChatId, diff --git a/client/src/pages/chat/share.tsx b/client/src/pages/chat/share.tsx index 8a3dfa52c..4c5feee04 100644 --- a/client/src/pages/chat/share.tsx +++ b/client/src/pages/chat/share.tsx @@ -69,7 +69,7 @@ const ShareChat = ({ shareId, chatId }: { shareId: string; chatId: string }) => shareId }); - if (newChatId) { + if (newChatId && !controller.signal.aborted) { router.replace({ query: { shareId,