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