Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
2330186a
authored
Jul 18, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: abort
parent
8a25aeab
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
37 additions
and
15 deletions
+37
-15
client/data/SystemParams.json
+3
-3
client/src/components/ChatBox/index.tsx
+10
-1
client/src/components/Markdown/index.tsx
+7
-4
client/src/pages/api/app/modules/chat/gpt.ts
+10
-2
client/src/pages/api/openapi/v1/chat/completions.ts
+1
-1
client/src/pages/app/list/component/CreateModal.tsx
+4
-2
client/src/pages/chat/index.tsx
+1
-1
client/src/pages/chat/share.tsx
+1
-1
No files found.
client/data/SystemParams.json
View file @
2330186a
{
{
"vectorMaxProcess"
:
1
0
,
"vectorMaxProcess"
:
1
5
,
"qaMaxProcess"
:
1
0
,
"qaMaxProcess"
:
1
5
,
"pgIvfflatProbe"
:
1
0
,
"pgIvfflatProbe"
:
2
0
,
"sensitiveCheck"
:
false
"sensitiveCheck"
:
false
}
}
client/src/components/ChatBox/index.tsx
View file @
2330186a
...
@@ -5,7 +5,8 @@ import React, {
...
@@ -5,7 +5,8 @@ import React, {
useMemo
,
useMemo
,
forwardRef
,
forwardRef
,
useImperativeHandle
,
useImperativeHandle
,
ForwardedRef
ForwardedRef
,
useEffect
}
from
'react'
;
}
from
'react'
;
import
{
throttle
}
from
'lodash'
;
import
{
throttle
}
from
'lodash'
;
import
{
ChatItemType
,
ChatSiteItemType
,
ExportChatType
}
from
'@/types/chat'
;
import
{
ChatItemType
,
ChatSiteItemType
,
ExportChatType
}
from
'@/types/chat'
;
...
@@ -31,6 +32,7 @@ import { MessageItemType } from '@/pages/api/openapi/v1/chat/completions';
...
@@ -31,6 +32,7 @@ import { MessageItemType } from '@/pages/api/openapi/v1/chat/completions';
import
MyTooltip
from
'../MyTooltip'
;
import
MyTooltip
from
'../MyTooltip'
;
import
{
fileDownload
}
from
'@/utils/file'
;
import
{
fileDownload
}
from
'@/utils/file'
;
import
{
htmlTemplate
}
from
'@/constants/common'
;
import
{
htmlTemplate
}
from
'@/constants/common'
;
import
{
useRouter
}
from
'next/router'
;
import
dynamic
from
'next/dynamic'
;
import
dynamic
from
'next/dynamic'
;
const
QuoteModal
=
dynamic
(()
=>
import
(
'./QuoteModal'
));
const
QuoteModal
=
dynamic
(()
=>
import
(
'./QuoteModal'
));
...
@@ -133,6 +135,7 @@ const ChatBox = (
...
@@ -133,6 +135,7 @@ const ChatBox = (
)
=>
{
)
=>
{
const
ChatBoxRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
ChatBoxRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
theme
=
useTheme
();
const
theme
=
useTheme
();
const
router
=
useRouter
();
const
{
copyData
}
=
useCopyData
();
const
{
copyData
}
=
useCopyData
();
const
{
toast
}
=
useToast
();
const
{
toast
}
=
useToast
();
const
{
userInfo
}
=
useUserStore
();
const
{
userInfo
}
=
useUserStore
();
...
@@ -392,6 +395,12 @@ const ChatBox = (
...
@@ -392,6 +395,12 @@ const ChatBox = (
[
chatHistory
.
length
,
showEmptyIntro
,
variableModules
,
welcomeText
]
[
chatHistory
.
length
,
showEmptyIntro
,
variableModules
,
welcomeText
]
);
);
useEffect
(()
=>
{
return
()
=>
{
controller
.
current
?.
abort
();
};
},
[
router
.
query
]);
return
(
return
(
<
Flex
flexDirection=
{
'column'
}
h=
{
'100%'
}
>
<
Flex
flexDirection=
{
'column'
}
h=
{
'100%'
}
>
<
Box
ref=
{
ChatBoxRef
}
flex=
{
'1 0 0'
}
h=
{
0
}
overflow=
{
'overlay'
}
px=
{
[
2
,
5
,
7
]
}
pt=
{
[
0
,
5
]
}
>
<
Box
ref=
{
ChatBoxRef
}
flex=
{
'1 0 0'
}
h=
{
0
}
overflow=
{
'overlay'
}
px=
{
[
2
,
5
,
7
]
}
pt=
{
[
0
,
5
]
}
>
...
...
client/src/components/Markdown/index.tsx
View file @
2330186a
import
React
,
{
useRef
}
from
'react'
;
import
React
,
{
use
Memo
,
use
Ref
}
from
'react'
;
import
ReactMarkdown
from
'react-markdown'
;
import
ReactMarkdown
from
'react-markdown'
;
import
RemarkGfm
from
'remark-gfm'
;
import
RemarkGfm
from
'remark-gfm'
;
import
RemarkMath
from
'remark-math'
;
import
RemarkMath
from
'remark-math'
;
...
@@ -48,13 +48,16 @@ const Markdown = ({
...
@@ -48,13 +48,16 @@ const Markdown = ({
isChatting
?:
boolean
;
isChatting
?:
boolean
;
onClick
?:
(
e
:
any
)
=>
void
;
onClick
?:
(
e
:
any
)
=>
void
;
})
=>
{
})
=>
{
const
components
=
useRef
({
const
components
=
useMemo
(
()
=>
({
a
:
Link
,
a
:
Link
,
img
:
Image
,
img
:
Image
,
pre
:
'div'
,
pre
:
'div'
,
p
:
'div'
,
p
:
'div'
,
code
:
(
props
:
any
)
=>
<
Code
{
...
props
}
onClick=
{
onClick
}
/>
code
:
(
props
:
any
)
=>
<
Code
{
...
props
}
onClick=
{
onClick
}
/>
});
}),
[
onClick
]
);
return
(
return
(
<
ReactMarkdown
<
ReactMarkdown
...
@@ -64,7 +67,7 @@ const Markdown = ({
...
@@ -64,7 +67,7 @@ const Markdown = ({
remarkPlugins=
{
[
RemarkGfm
,
RemarkMath
,
RemarkBreaks
]
}
remarkPlugins=
{
[
RemarkGfm
,
RemarkMath
,
RemarkBreaks
]
}
rehypePlugins=
{
[
RehypeKatex
]
}
rehypePlugins=
{
[
RehypeKatex
]
}
// @ts-ignore
// @ts-ignore
components=
{
components
.
current
}
components=
{
components
}
>
>
{
source
}
{
source
}
</
ReactMarkdown
>
</
ReactMarkdown
>
...
...
client/src/pages/api/app/modules/chat/gpt.ts
View file @
2330186a
...
@@ -89,6 +89,14 @@ export async function chatCompletion({
...
@@ -89,6 +89,14 @@ export async function chatCompletion({
// FastGpt temperature range: 1~10
// FastGpt temperature range: 1~10
temperature
=
+
(
modelConstantsData
.
maxTemperature
*
(
temperature
/
10
)).
toFixed
(
2
);
temperature
=
+
(
modelConstantsData
.
maxTemperature
*
(
temperature
/
10
)).
toFixed
(
2
);
const
limitText
=
(()
=>
{
if
(
limitPrompt
)
return
limitPrompt
;
if
(
quotePrompt
&&
!
limitPrompt
)
{
return
'根据知识库内容回答问题,仅回复知识库提供的内容。'
;
}
return
''
;
})();
const
messages
:
ChatItemType
[]
=
[
const
messages
:
ChatItemType
[]
=
[
...(
quotePrompt
...(
quotePrompt
?
[
?
[
...
@@ -107,11 +115,11 @@ export async function chatCompletion({
...
@@ -107,11 +115,11 @@ export async function chatCompletion({
]
]
:
[]),
:
[]),
...
history
,
...
history
,
...(
limit
Promp
t
...(
limit
Tex
t
?
[
?
[
{
{
obj
:
ChatRoleEnum
.
System
,
obj
:
ChatRoleEnum
.
System
,
value
:
limit
Promp
t
value
:
limit
Tex
t
}
}
]
]
:
[]),
:
[]),
...
...
client/src/pages/api/openapi/v1/chat/completions.ts
View file @
2330186a
...
@@ -145,7 +145,7 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
...
@@ -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
)
/
100
0
}
s`
);
if
(
stream
)
{
if
(
stream
)
{
sseResponse
({
sseResponse
({
...
...
client/src/pages/app/list/component/CreateModal.tsx
View file @
2330186a
...
@@ -23,6 +23,7 @@ import { postCreateApp } from '@/api/app';
...
@@ -23,6 +23,7 @@ import { postCreateApp } from '@/api/app';
import
{
useRouter
}
from
'next/router'
;
import
{
useRouter
}
from
'next/router'
;
import
{
appTemplates
}
from
'@/constants/flow/ModuleTemplate'
;
import
{
appTemplates
}
from
'@/constants/flow/ModuleTemplate'
;
import
Avatar
from
'@/components/Avatar'
;
import
Avatar
from
'@/components/Avatar'
;
import
MyTooltip
from
'@/components/MyTooltip'
;
type
FormType
=
{
type
FormType
=
{
avatar
:
string
;
avatar
:
string
;
...
@@ -102,21 +103,22 @@ const CreateModal = ({ onClose, onSuccess }: { onClose: () => void; onSuccess: (
...
@@ -102,21 +103,22 @@ const CreateModal = ({ onClose, onSuccess }: { onClose: () => void; onSuccess: (
<
Modal
isOpen
onClose=
{
onClose
}
>
<
Modal
isOpen
onClose=
{
onClose
}
>
<
ModalOverlay
/>
<
ModalOverlay
/>
<
ModalContent
w=
{
'700px'
}
maxW=
{
'90vw'
}
>
<
ModalContent
w=
{
'700px'
}
maxW=
{
'90vw'
}
>
<
ModalHeader
fontSize=
{
'2xl'
}
>
开始创建
你的 AI 应用
</
ModalHeader
>
<
ModalHeader
fontSize=
{
'2xl'
}
>
创建属于
你的 AI 应用
</
ModalHeader
>
<
ModalBody
>
<
ModalBody
>
<
Box
color=
{
'myGray.800'
}
fontWeight=
{
'bold'
}
>
<
Box
color=
{
'myGray.800'
}
fontWeight=
{
'bold'
}
>
取个响亮的名字
取个响亮的名字
</
Box
>
</
Box
>
<
Flex
mt=
{
3
}
alignItems=
{
'center'
}
>
<
Flex
mt=
{
3
}
alignItems=
{
'center'
}
>
<
MyTooltip
label=
{
'点击设置头像'
}
>
<
Avatar
<
Avatar
src=
{
getValues
(
'avatar'
)
}
src=
{
getValues
(
'avatar'
)
}
w=
{
[
'32px'
,
'36px'
]
}
w=
{
[
'32px'
,
'36px'
]
}
h=
{
[
'32px'
,
'36px'
]
}
h=
{
[
'32px'
,
'36px'
]
}
cursor=
{
'pointer'
}
cursor=
{
'pointer'
}
title=
{
'点击选择头像'
}
borderRadius=
{
'md'
}
borderRadius=
{
'md'
}
onClick=
{
onOpenSelectFile
}
onClick=
{
onOpenSelectFile
}
/>
/>
</
MyTooltip
>
<
Input
<
Input
ml=
{
4
}
ml=
{
4
}
bg=
{
'myWhite.600'
}
bg=
{
'myWhite.600'
}
...
...
client/src/pages/chat/index.tsx
View file @
2330186a
...
@@ -66,7 +66,7 @@ const Chat = () => {
...
@@ -66,7 +66,7 @@ const Chat = () => {
const
newTitle
=
prompts
[
0
].
content
?.
slice
(
0
,
20
)
||
'新对话'
;
const
newTitle
=
prompts
[
0
].
content
?.
slice
(
0
,
20
)
||
'新对话'
;
// update history
// update history
if
(
newChatId
)
{
if
(
newChatId
&&
!
controller
.
signal
.
aborted
)
{
forbidRefresh
.
current
=
true
;
forbidRefresh
.
current
=
true
;
const
newHistory
:
ChatHistoryItemType
=
{
const
newHistory
:
ChatHistoryItemType
=
{
_id
:
newChatId
,
_id
:
newChatId
,
...
...
client/src/pages/chat/share.tsx
View file @
2330186a
...
@@ -69,7 +69,7 @@ const ShareChat = ({ shareId, chatId }: { shareId: string; chatId: string }) =>
...
@@ -69,7 +69,7 @@ const ShareChat = ({ shareId, chatId }: { shareId: string; chatId: string }) =>
shareId
shareId
});
});
if
(
newChatId
)
{
if
(
newChatId
&&
!
controller
.
signal
.
aborted
)
{
router
.
replace
({
router
.
replace
({
query
:
{
query
:
{
shareId
,
shareId
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment