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
09879004
authored
Aug 05, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: abort chat response
parent
236e7d3c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
35 deletions
+41
-35
client/data/config.json
+2
-2
client/src/components/ChatBox/index.tsx
+6
-22
client/src/pages/chat/index.tsx
+11
-9
client/src/pages/chat/share.tsx
+1
-1
client/src/pages/login/index.tsx
+21
-1
No files found.
client/data/config.json
View file @
09879004
...
...
@@ -14,6 +14,7 @@
"qaMaxProcess"
:
15
,
"pgIvfflatProbe"
:
20
},
"plugins"
:
{},
"ChatModels"
:
[
{
"model"
:
"gpt-3.5-turbo"
,
...
...
@@ -62,6 +63,5 @@
"name"
:
"Embedding-2"
,
"price"
:
0.2
}
],
"plugins"
:
{}
]
}
client/src/components/ChatBox/index.tsx
View file @
09879004
...
...
@@ -89,19 +89,12 @@ const Empty = () => {
const
{
data
:
versionIntro
}
=
useMarkdown
({
url
:
'/versionIntro.md'
});
return
(
<
Box
pt=
{
[
6
,
0
]
}
w=
{
'85%'
}
maxW=
{
'600px'
}
m=
{
'auto'
}
alignItems=
{
'center'
}
justifyContent=
{
'center'
}
>
<
Box
pt=
{
6
}
w=
{
'85%'
}
maxW=
{
'600px'
}
m=
{
'auto'
}
alignItems=
{
'center'
}
justifyContent=
{
'center'
}
>
{
/* version intro */
}
<
Card
p=
{
4
}
mb=
{
10
}
>
<
Card
p=
{
4
}
mb=
{
10
}
minH=
{
'200px'
}
>
<
Markdown
source=
{
versionIntro
}
/>
</
Card
>
<
Card
p=
{
4
}
>
<
Card
p=
{
4
}
minH=
{
'600px'
}
>
<
Markdown
source=
{
chatProblem
}
/>
</
Card
>
</
Box
>
...
...
@@ -451,7 +444,7 @@ const ChatBox = (
useEffect
(()
=>
{
return
()
=>
{
controller
.
current
?.
abort
();
controller
.
current
?.
abort
(
'leave'
);
// close voice
cancelBroadcast
();
};
...
...
@@ -470,16 +463,7 @@ const ChatBox = (
return
(
<
Flex
flexDirection=
{
'column'
}
h=
{
'100%'
}
>
<
Box
ref=
{
ChatBoxRef
}
flex=
{
'1 0 0'
}
h=
{
0
}
w=
{
'100%'
}
overflow=
{
'overlay'
}
px=
{
[
4
,
0
]
}
mt=
{
[
0
,
5
]
}
pb=
{
3
}
>
<
Box
ref=
{
ChatBoxRef
}
flex=
{
'1 0 0'
}
h=
{
0
}
w=
{
'100%'
}
overflow=
{
'overlay'
}
px=
{
[
4
,
0
]
}
pb=
{
3
}
>
<
Box
maxW=
{
[
'100%'
,
'92%'
]
}
h=
{
'100%'
}
mx=
{
'auto'
}
>
{
showEmpty
&&
<
Empty
/>
}
...
...
@@ -775,7 +759,7 @@ const ChatBox = (
cursor=
{
'pointer'
}
name=
{
'stop'
}
color=
{
'gray.500'
}
onClick=
{
()
=>
controller
.
current
?.
abort
()
}
onClick=
{
()
=>
controller
.
current
?.
abort
(
'stop'
)
}
/>
)
:
(
<
MyIcon
...
...
client/src/pages/chat/index.tsx
View file @
09879004
...
...
@@ -79,8 +79,7 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
const
newTitle
=
prompts
[
0
].
content
?.
slice
(
0
,
20
)
||
'新对话'
;
// update history
if
(
completionChatId
!==
chatId
&&
!
controller
.
signal
.
aborted
)
{
forbidRefresh
.
current
=
true
;
if
(
completionChatId
!==
chatId
)
{
const
newHistory
:
ChatHistoryItemType
=
{
chatId
:
completionChatId
,
updateTime
:
new
Date
(),
...
...
@@ -89,12 +88,15 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
top
:
false
};
updateHistory
(
newHistory
);
router
.
replace
({
query
:
{
chatId
:
completionChatId
,
appId
}
});
if
(
controller
.
signal
.
reason
!==
'leave'
)
{
forbidRefresh
.
current
=
true
;
router
.
replace
({
query
:
{
chatId
:
completionChatId
,
appId
}
});
}
}
else
{
const
currentChat
=
history
.
find
((
item
)
=>
item
.
chatId
===
chatId
);
currentChat
&&
...
...
@@ -116,7 +118,7 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
[
appId
,
chatId
,
history
,
router
,
setChatData
,
updateHistory
]
);
//
删除一句话
//
del one chat content
const
delOneHistoryItem
=
useCallback
(
async
({
contentId
,
index
}:
{
contentId
?:
string
;
index
:
number
})
=>
{
if
(
!
chatId
||
!
contentId
)
return
;
...
...
client/src/pages/chat/share.tsx
View file @
09879004
...
...
@@ -73,7 +73,7 @@ const OutLink = ({ shareId, chatId }: { shareId: string; chatId: string }) => {
shareId
});
if
(
completionChatId
!==
chatId
&&
!
controller
.
signal
.
aborted
)
{
if
(
completionChatId
!==
chatId
&&
controller
.
signal
.
reason
!==
'leave'
)
{
router
.
replace
({
query
:
{
shareId
,
...
...
client/src/pages/login/index.tsx
View file @
09879004
import
React
,
{
useState
,
useCallback
}
from
'react'
;
import
styles
from
'./index.module.scss'
;
import
{
Box
,
Flex
,
Image
}
from
'@chakra-ui/react'
;
import
{
Box
,
Flex
,
Image
,
useDisclosure
}
from
'@chakra-ui/react'
;
import
{
PageTypeEnum
}
from
'@/constants/user'
;
import
{
useGlobalStore
}
from
'@/store/global'
;
import
type
{
ResLogin
}
from
'@/api/response/user'
;
...
...
@@ -11,6 +11,8 @@ import LoginForm from './components/LoginForm';
import
dynamic
from
'next/dynamic'
;
import
{
serviceSideProps
}
from
'@/utils/i18n'
;
import
{
setToken
}
from
'@/utils/user'
;
import
{
feConfigs
}
from
'@/store/static'
;
import
WxConcat
from
'@/components/WxConcat'
;
const
RegisterForm
=
dynamic
(()
=>
import
(
'./components/RegisterForm'
));
const
ForgetPasswordForm
=
dynamic
(()
=>
import
(
'./components/ForgetPasswordForm'
));
...
...
@@ -21,6 +23,7 @@ const Login = () => {
const
[
pageType
,
setPageType
]
=
useState
<
`
${
PageTypeEnum
}
`
>
(
PageTypeEnum
.
login
);
const
{
setUserInfo
}
=
useUserStore
();
const
{
setLastChatId
,
setLastChatAppId
}
=
useChatStore
();
const
{
isOpen
,
onOpen
,
onClose
}
=
useDisclosure
();
const
loginSuccess
=
useCallback
(
(
res
:
ResLogin
)
=>
{
...
...
@@ -84,6 +87,7 @@ const Login = () => {
)
}
<
Box
position=
{
'relative'
}
order=
{
1
}
flex=
{
`0 0 ${isPc ? '400px' : '100%'}`
}
height=
{
'100%'
}
...
...
@@ -94,8 +98,24 @@ const Login = () => {
borderRadius=
{
isPc
?
'md'
:
'none'
}
>
<
DynamicComponent
type=
{
pageType
}
/>
{
feConfigs
?.
show_register
&&
(
<
Box
fontSize=
{
'sm'
}
color=
{
'myGray.600'
}
cursor=
{
'pointer'
}
position=
{
'absolute'
}
right=
{
5
}
bottom=
{
3
}
onClick=
{
onOpen
}
>
无法登录,点击联系
</
Box
>
)
}
</
Box
>
</
Flex
>
{
isOpen
&&
<
WxConcat
onClose=
{
onClose
}
/>
}
</
Flex
>
);
};
...
...
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