perf: abort
This commit is contained in:
@@ -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
|
||||
}
|
||||
]
|
||||
: []),
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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: (
|
||||
<Modal isOpen onClose={onClose}>
|
||||
<ModalOverlay />
|
||||
<ModalContent w={'700px'} maxW={'90vw'}>
|
||||
<ModalHeader fontSize={'2xl'}>开始创建你的 AI 应用</ModalHeader>
|
||||
<ModalHeader fontSize={'2xl'}>创建属于你的 AI 应用</ModalHeader>
|
||||
<ModalBody>
|
||||
<Box color={'myGray.800'} fontWeight={'bold'}>
|
||||
取个响亮的名字
|
||||
</Box>
|
||||
<Flex mt={3} alignItems={'center'}>
|
||||
<Avatar
|
||||
src={getValues('avatar')}
|
||||
w={['32px', '36px']}
|
||||
h={['32px', '36px']}
|
||||
cursor={'pointer'}
|
||||
title={'点击选择头像'}
|
||||
borderRadius={'md'}
|
||||
onClick={onOpenSelectFile}
|
||||
/>
|
||||
<MyTooltip label={'点击设置头像'}>
|
||||
<Avatar
|
||||
src={getValues('avatar')}
|
||||
w={['32px', '36px']}
|
||||
h={['32px', '36px']}
|
||||
cursor={'pointer'}
|
||||
borderRadius={'md'}
|
||||
onClick={onOpenSelectFile}
|
||||
/>
|
||||
</MyTooltip>
|
||||
<Input
|
||||
ml={4}
|
||||
bg={'myWhite.600'}
|
||||
|
||||
@@ -66,7 +66,7 @@ const Chat = () => {
|
||||
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,
|
||||
|
||||
@@ -69,7 +69,7 @@ const ShareChat = ({ shareId, chatId }: { shareId: string; chatId: string }) =>
|
||||
shareId
|
||||
});
|
||||
|
||||
if (newChatId) {
|
||||
if (newChatId && !controller.signal.aborted) {
|
||||
router.replace({
|
||||
query: {
|
||||
shareId,
|
||||
|
||||
Reference in New Issue
Block a user