Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
70525653
Unverified
Commit
70525653
authored
Mar 07, 2024
by
Lance Mao
Committed by
GitHub
Mar 07, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix typo: responsing -> responding (#2718)
Co-authored-by:
OSS-MAOLONGDONG\kaihong
<
maolongdong@kaihong.com
>
parent
31070ffb
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
127 additions
and
127 deletions
+127
-127
index.tsx
web/app/components/app/chat/answer/index.tsx
+6
-6
index.tsx
web/app/components/app/chat/index.tsx
+11
-11
index.tsx
web/app/components/app/chat/question/index.tsx
+3
-3
chat-item.tsx
...nfiguration/debug/debug-with-multiple-model/chat-item.tsx
+2
-2
text-generation-item.tsx
.../debug/debug-with-multiple-model/text-generation-item.tsx
+3
-3
index.tsx
...app/configuration/debug/debug-with-single-model/index.tsx
+2
-2
index.tsx
web/app/components/app/configuration/debug/index.tsx
+8
-8
index.tsx
web/app/components/app/text-generate/item/index.tsx
+3
-3
chat-wrapper.tsx
...p/components/base/chat/chat-with-history/chat-wrapper.tsx
+2
-2
agent-content.tsx
web/app/components/base/chat/chat/answer/agent-content.tsx
+3
-3
index.tsx
web/app/components/base/chat/chat/answer/index.tsx
+7
-7
context.tsx
web/app/components/base/chat/chat/context.tsx
+3
-3
hooks.ts
web/app/components/base/chat/chat/hooks.ts
+14
-14
index.tsx
web/app/components/base/chat/chat/index.tsx
+6
-6
question.tsx
web/app/components/base/chat/chat/question.tsx
+3
-3
hooks.ts
web/app/components/base/text-generation/hooks.ts
+7
-7
index.tsx
web/app/components/share/chat/index.tsx
+19
-19
index.tsx
web/app/components/share/chatbot/index.tsx
+16
-16
index.tsx
web/app/components/share/text-generation/result/index.tsx
+9
-9
No files found.
web/app/components/app/chat/answer/index.tsx
View file @
70525653
...
...
@@ -49,7 +49,7 @@ export type IAnswerProps = {
onQueryChange
:
(
query
:
string
)
=>
void
onFeedback
?:
FeedbackFunc
displayScene
:
DisplayScene
isRespon
s
ing
?:
boolean
isRespon
d
ing
?:
boolean
answerIcon
?:
ReactNode
citation
?:
CitationItem
[]
dataSets
?:
DataSet
[]
...
...
@@ -74,7 +74,7 @@ const Answer: FC<IAnswerProps> = ({
isHideFeedbackEdit
=
false
,
onFeedback
,
displayScene
=
'web'
,
isRespon
s
ing
,
isRespon
d
ing
,
answerIcon
,
citation
,
isShowCitation
,
...
...
@@ -229,7 +229,7 @@ const Answer: FC<IAnswerProps> = ({
<
Thought
thought=
{
item
}
allToolIcons=
{
allToolIcons
||
{}
}
isFinished=
{
!!
item
.
observation
||
!
isRespon
s
ing
}
isFinished=
{
!!
item
.
observation
||
!
isRespon
d
ing
}
/>
)
}
...
...
@@ -248,7 +248,7 @@ const Answer: FC<IAnswerProps> = ({
{
answerIcon
||
(
<
div
className=
{
`${s.answerIcon} w-10 h-10 shrink-0`
}
>
{
isRespon
s
ing
{
isRespon
d
ing
&&
<
div
className=
{
s
.
typeingIcon
}
>
<
LoadingAnim
type=
'avatar'
/>
</
div
>
...
...
@@ -260,7 +260,7 @@ const Answer: FC<IAnswerProps> = ({
<
div
className=
{
`${s.answerWrap} ${showEdit ? 'w-full' : ''}`
}
>
<
div
className=
{
`${s.answer} relative text-sm text-gray-900`
}
>
<
div
className=
{
'ml-2 py-3 px-4 bg-gray-100 rounded-tr-2xl rounded-b-2xl'
}
>
{
(
isRespon
s
ing
&&
(
isAgentMode
?
(
!
content
&&
(
agent_thoughts
||
[]).
filter
(
item
=>
!!
item
.
thought
||
!!
item
.
tool
).
length
===
0
)
:
!
content
))
{
(
isRespon
d
ing
&&
(
isAgentMode
?
(
!
content
&&
(
agent_thoughts
||
[]).
filter
(
item
=>
!!
item
.
thought
||
!!
item
.
tool
).
length
===
0
)
:
!
content
))
?
(
<
div
className=
'flex items-center justify-center w-6 h-5'
>
<
LoadingAnim
type=
'text'
/>
...
...
@@ -314,7 +314,7 @@ const Answer: FC<IAnswerProps> = ({
</
div
>
)
}
{
!!
citation
?.
length
&&
isShowCitation
&&
!
isRespon
s
ing
&&
(
!!
citation
?.
length
&&
isShowCitation
&&
!
isRespon
d
ing
&&
(
<
Citation
data=
{
citation
}
showHitInfo=
{
isShowCitationHitInfo
}
/>
)
}
...
...
web/app/components/app/chat/index.tsx
View file @
70525653
...
...
@@ -49,9 +49,9 @@ export type IChatProps = {
onSend
?:
(
message
:
string
,
files
:
VisionFile
[])
=>
void
displayScene
?:
DisplayScene
useCurrentUserAvatar
?:
boolean
isRespon
s
ing
?:
boolean
canStopRespon
s
ing
?:
boolean
abortRespon
s
ing
?:
()
=>
void
isRespon
d
ing
?:
boolean
canStopRespon
d
ing
?:
boolean
abortRespon
d
ing
?:
()
=>
void
controlClearQuery
?:
number
controlFocus
?:
number
isShowSuggestion
?:
boolean
...
...
@@ -82,9 +82,9 @@ const Chat: FC<IChatProps> = ({
onSend
=
()
=>
{
},
displayScene
,
useCurrentUserAvatar
,
isRespon
s
ing
,
canStopRespon
s
ing
,
abortRespon
s
ing
,
isRespon
d
ing
,
canStopRespon
d
ing
,
abortRespon
d
ing
,
controlClearQuery
,
controlFocus
,
isShowSuggestion
,
...
...
@@ -153,7 +153,7 @@ const Chat: FC<IChatProps> = ({
if
(
!
files
.
find
(
item
=>
item
.
type
===
TransferMethod
.
local_file
&&
!
item
.
fileId
))
{
if
(
files
.
length
)
onClear
()
if
(
!
isRespon
s
ing
)
if
(
!
isRespon
d
ing
)
onQueryChange
(
''
)
}
}
...
...
@@ -286,7 +286,7 @@ const Chat: FC<IChatProps> = ({
isHideFeedbackEdit=
{
isHideFeedbackEdit
}
onFeedback=
{
onFeedback
}
displayScene=
{
displayScene
??
'web'
}
isRespon
sing=
{
isRespons
ing
&&
isLast
}
isRespon
ding=
{
isRespond
ing
&&
isLast
}
answerIcon=
{
answerIcon
}
citation=
{
citation
}
dataSets=
{
dataSets
}
...
...
@@ -311,7 +311,7 @@ const Chat: FC<IChatProps> = ({
useCurrentUserAvatar=
{
useCurrentUserAvatar
}
item=
{
item
}
isShowPromptLog=
{
isShowPromptLog
}
isRespon
sing=
{
isRespons
ing
}
isRespon
ding=
{
isRespond
ing
}
/>
)
})
}
...
...
@@ -320,9 +320,9 @@ const Chat: FC<IChatProps> = ({
!
isHideSendInput
&&
(
<
div
className=
{
cn
(
!
feedbackDisabled
&&
'!left-3.5 !right-3.5'
,
'absolute z-10 bottom-0 left-0 right-0'
)
}
>
{
/* Thinking is sync and can not be stopped */
}
{
(
isRespon
sing
&&
canStopRespons
ing
&&
((
!!
chatList
[
chatList
.
length
-
1
]?.
content
)
||
(
chatList
[
chatList
.
length
-
1
]?.
agent_thoughts
&&
chatList
[
chatList
.
length
-
1
].
agent_thoughts
!
.
length
>
0
)))
&&
(
{
(
isRespon
ding
&&
canStopRespond
ing
&&
((
!!
chatList
[
chatList
.
length
-
1
]?.
content
)
||
(
chatList
[
chatList
.
length
-
1
]?.
agent_thoughts
&&
chatList
[
chatList
.
length
-
1
].
agent_thoughts
!
.
length
>
0
)))
&&
(
<
div
className=
'flex justify-center mb-4'
>
<
Button
className=
'flex items-center space-x-1 bg-white'
onClick=
{
()
=>
abortRespon
s
ing
?.()
}
>
<
Button
className=
'flex items-center space-x-1 bg-white'
onClick=
{
()
=>
abortRespon
d
ing
?.()
}
>
{
stopIcon
}
<
span
className=
'text-xs text-gray-500 font-normal'
>
{
t
(
'appDebug.operation.stopResponding'
)
}
</
span
>
</
Button
>
...
...
web/app/components/app/chat/question/index.tsx
View file @
70525653
...
...
@@ -13,10 +13,10 @@ import ImageGallery from '@/app/components/base/image-gallery'
type
IQuestionProps
=
Pick
<
IChatItem
,
'id'
|
'content'
|
'more'
|
'useCurrentUserAvatar'
>
&
{
isShowPromptLog
?:
boolean
item
:
IChatItem
isRespon
s
ing
?:
boolean
isRespon
d
ing
?:
boolean
}
const
Question
:
FC
<
IQuestionProps
>
=
({
id
,
content
,
more
,
useCurrentUserAvatar
,
isShowPromptLog
,
item
,
isRespon
s
ing
})
=>
{
const
Question
:
FC
<
IQuestionProps
>
=
({
id
,
content
,
more
,
useCurrentUserAvatar
,
isShowPromptLog
,
item
,
isRespon
d
ing
})
=>
{
const
{
userProfile
}
=
useContext
(
AppContext
)
const
userName
=
userProfile
?.
name
const
ref
=
useRef
(
null
)
...
...
@@ -28,7 +28,7 @@ const Question: FC<IQuestionProps> = ({ id, content, more, useCurrentUserAvatar,
<
div
className=
{
`${s.question} group relative text-sm text-gray-900`
}
>
{
isShowPromptLog
&&
!
isRespon
s
ing
&&
(
isShowPromptLog
&&
!
isRespon
d
ing
&&
(
<
Log
log=
{
item
.
log
!
}
containerRef=
{
ref
}
/>
)
}
...
...
web/app/components/app/configuration/debug/debug-with-multiple-model/chat-item.tsx
View file @
70525653
...
...
@@ -46,7 +46,7 @@ const ChatItem: FC<ChatItemProps> = ({
const
config
=
useConfigFromDebugContext
()
const
{
chatList
,
isRespon
s
ing
,
isRespon
d
ing
,
handleSend
,
suggestedQuestions
,
handleRestart
,
...
...
@@ -118,7 +118,7 @@ const ChatItem: FC<ChatItemProps> = ({
<
Chat
config=
{
config
}
chatList=
{
chatList
}
isRespon
sing=
{
isRespons
ing
}
isRespon
ding=
{
isRespond
ing
}
noChatInput
noStopResponding
chatContainerclassName=
'p-4'
...
...
web/app/components/app/configuration/debug/debug-with-multiple-model/text-generation-item.tsx
View file @
70525653
...
...
@@ -83,7 +83,7 @@ const TextGenerationItem: FC<TextGenerationItemProps> = ({
const
{
completion
,
handleSend
,
isRespon
s
ing
,
isRespon
d
ing
,
messageId
,
}
=
useTextGeneration
()
...
...
@@ -143,8 +143,8 @@ const TextGenerationItem: FC<TextGenerationItemProps> = ({
innerClassName=
'grow flex flex-col'
contentClassName=
'grow'
content=
{
completion
}
isLoading=
{
!
completion
&&
isRespon
s
ing
}
isRespon
sing=
{
isRespons
ing
}
isLoading=
{
!
completion
&&
isRespon
d
ing
}
isRespon
ding=
{
isRespond
ing
}
isInstalledApp=
{
false
}
messageId=
{
messageId
}
isError=
{
false
}
...
...
web/app/components/app/configuration/debug/debug-with-single-model/index.tsx
View file @
70525653
...
...
@@ -45,7 +45,7 @@ const DebugWithSingleModel = forwardRef<DebugWithSingleModelRefType, DebugWithSi
const
config
=
useConfigFromDebugContext
()
const
{
chatList
,
isRespon
s
ing
,
isRespon
d
ing
,
handleSend
,
suggestedQuestions
,
handleStop
,
...
...
@@ -118,7 +118,7 @@ const DebugWithSingleModel = forwardRef<DebugWithSingleModelRefType, DebugWithSi
<
Chat
config=
{
config
}
chatList=
{
chatList
}
isRespon
sing=
{
isRespons
ing
}
isRespon
ding=
{
isRespond
ing
}
chatContainerclassName=
'p-6'
chatFooterClassName=
'px-6 pt-10 pb-4'
suggestedQuestions=
{
suggestedQuestions
}
...
...
web/app/components/app/configuration/debug/index.tsx
View file @
70525653
...
...
@@ -93,7 +93,7 @@ const Debug: FC<IDebug> = ({
}
},
[])
const
[
isRespon
sing
,
{
setTrue
:
setResponsingTrue
,
setFalse
:
setRespons
ingFalse
}]
=
useBoolean
(
false
)
const
[
isRespon
ding
,
{
setTrue
:
setRespondingTrue
,
setFalse
:
setRespond
ingFalse
}]
=
useBoolean
(
false
)
const
[
isShowFormattingChangeConfirm
,
setIsShowFormattingChangeConfirm
]
=
useState
(
false
)
const
[
isShowCannotQueryDataset
,
setShowCannotQueryDataset
]
=
useState
(
false
)
...
...
@@ -191,7 +191,7 @@ const Debug: FC<IDebug> = ({
const
[
messageId
,
setMessageId
]
=
useState
<
string
|
null
>
(
null
)
const
sendTextCompletion
=
async
()
=>
{
if
(
isRespon
s
ing
)
{
if
(
isRespon
d
ing
)
{
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
return
false
}
...
...
@@ -277,7 +277,7 @@ const Debug: FC<IDebug> = ({
setMessageId
(
''
)
let
res
:
string
[]
=
[]
setRespon
s
ingTrue
()
setRespon
d
ingTrue
()
sendCompletionMessage
(
appId
,
data
,
{
onData
:
(
data
:
string
,
_isFirstMessage
:
boolean
,
{
messageId
})
=>
{
res
.
push
(
data
)
...
...
@@ -289,10 +289,10 @@ const Debug: FC<IDebug> = ({
setCompletionRes
(
res
.
join
(
''
))
},
onCompleted
()
{
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
},
onError
()
{
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
},
})
}
...
...
@@ -440,13 +440,13 @@ const Debug: FC<IDebug> = ({
{
mode
===
AppType
.
completion
&&
(
<
div
className=
"mt-6 px-6 pb-4"
>
<
GroupName
name=
{
t
(
'appDebug.result'
)
}
/>
{
(
completionRes
||
isRespon
s
ing
)
&&
(
{
(
completionRes
||
isRespon
d
ing
)
&&
(
<
TextGeneration
className=
"mt-2"
content=
{
completionRes
}
isLoading=
{
!
completionRes
&&
isRespon
s
ing
}
isLoading=
{
!
completionRes
&&
isRespon
d
ing
}
isShowTextToSpeech=
{
textToSpeechConfig
.
enabled
&&
!!
text2speechDefaultModel
}
isRespon
sing=
{
isRespons
ing
}
isRespon
ding=
{
isRespond
ing
}
isInstalledApp=
{
false
}
messageId=
{
messageId
}
isError=
{
false
}
...
...
web/app/components/app/text-generate/item/index.tsx
View file @
70525653
...
...
@@ -32,7 +32,7 @@ export type IGenerationItemProps = {
messageId
?:
string
|
null
conversationId
?:
string
isLoading
?:
boolean
isRespon
s
ing
?:
boolean
isRespon
d
ing
?:
boolean
isInWebApp
?:
boolean
moreLikeThis
?:
boolean
depth
?:
number
...
...
@@ -81,7 +81,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
content
,
messageId
,
isLoading
,
isRespon
s
ing
,
isRespon
d
ing
,
moreLikeThis
,
isInWebApp
=
false
,
feedback
,
...
...
@@ -277,7 +277,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
<
div
className=
'flex items-center justify-between mt-3'
>
<
div
className=
'flex items-center'
>
{
!
isInWebApp
&&
!
isInstalledApp
&&
!
isRespon
s
ing
&&
(
!
isInWebApp
&&
!
isInstalledApp
&&
!
isRespon
d
ing
&&
(
<
PromptLog
log=
{
promptLog
}
containerRef=
{
ref
}
...
...
web/app/components/base/chat/chat-with-history/chat-wrapper.tsx
View file @
70525653
...
...
@@ -43,7 +43,7 @@ const ChatWrapper = () => {
chatList
,
handleSend
,
handleStop
,
isRespon
s
ing
,
isRespon
d
ing
,
suggestedQuestions
,
}
=
useChat
(
appConfig
,
...
...
@@ -130,7 +130,7 @@ const ChatWrapper = () => {
<
Chat
config=
{
appConfig
}
chatList=
{
chatList
}
isRespon
sing=
{
isRespons
ing
}
isRespon
ding=
{
isRespond
ing
}
chatContainerInnerClassName=
{
`mx-auto pt-6 w-full max-w-[720px] ${isMobile && 'px-4'}`
}
chatFooterClassName=
'pb-4'
chatFooterInnerClassName=
{
`mx-auto w-full max-w-[720px] ${isMobile && 'px-4'}`
}
...
...
web/app/components/base/chat/chat/answer/agent-content.tsx
View file @
70525653
...
...
@@ -11,12 +11,12 @@ import type { Emoji } from '@/app/components/tools/types'
type
AgentContentProps
=
{
item
:
ChatItem
respon
s
ing
?:
boolean
respon
d
ing
?:
boolean
allToolIcons
?:
Record
<
string
,
string
|
Emoji
>
}
const
AgentContent
:
FC
<
AgentContentProps
>
=
({
item
,
respon
s
ing
,
respon
d
ing
,
allToolIcons
,
})
=>
{
const
{
...
...
@@ -46,7 +46,7 @@ const AgentContent: FC<AgentContentProps> = ({
<
Thought
thought=
{
thought
}
allToolIcons=
{
allToolIcons
||
{}
}
isFinished=
{
!!
thought
.
observation
||
!
respon
s
ing
}
isFinished=
{
!!
thought
.
observation
||
!
respon
d
ing
}
/>
)
}
...
...
web/app/components/base/chat/chat/answer/index.tsx
View file @
70525653
...
...
@@ -25,7 +25,7 @@ type AnswerProps = {
index
:
number
config
?:
ChatConfig
answerIcon
?:
ReactNode
respon
s
ing
?:
boolean
respon
d
ing
?:
boolean
allToolIcons
?:
Record
<
string
,
string
|
Emoji
>
}
const
Answer
:
FC
<
AnswerProps
>
=
({
...
...
@@ -34,7 +34,7 @@ const Answer: FC<AnswerProps> = ({
index
,
config
,
answerIcon
,
respon
s
ing
,
respon
d
ing
,
allToolIcons
,
})
=>
{
const
{
t
}
=
useTranslation
()
...
...
@@ -58,7 +58,7 @@ const Answer: FC<AnswerProps> = ({
)
}
{
respon
s
ing
&&
(
respon
d
ing
&&
(
<
div
className=
'absolute -top-[3px] -left-[3px] pl-[6px] flex items-center w-4 h-4 bg-white rounded-full shadow-xs border-[0.5px] border-gray-50'
>
<
LoadingAnim
type=
'avatar'
/>
</
div
>
...
...
@@ -70,7 +70,7 @@ const Answer: FC<AnswerProps> = ({
<
AnswerTriangle
className=
'absolute -left-2 top-0 w-2 h-3 text-gray-100'
/>
<
div
className=
'group relative inline-block px-4 py-3 max-w-full bg-gray-100 rounded-b-2xl rounded-tr-2xl text-sm text-gray-900'
>
{
!
respon
s
ing
&&
(
!
respon
d
ing
&&
(
<
Operation
item=
{
item
}
question=
{
question
}
...
...
@@ -79,7 +79,7 @@ const Answer: FC<AnswerProps> = ({
)
}
{
respon
s
ing
&&
!
content
&&
!
hasAgentThoughts
&&
(
respon
d
ing
&&
!
content
&&
!
hasAgentThoughts
&&
(
<
div
className=
'flex items-center justify-center w-6 h-5'
>
<
LoadingAnim
type=
'text'
/>
</
div
>
...
...
@@ -94,7 +94,7 @@ const Answer: FC<AnswerProps> = ({
hasAgentThoughts
&&
(
<
AgentContent
item=
{
item
}
respon
sing=
{
respons
ing
}
respon
ding=
{
respond
ing
}
allToolIcons=
{
allToolIcons
}
/>
)
...
...
@@ -109,7 +109,7 @@ const Answer: FC<AnswerProps> = ({
}
<
SuggestedQuestions
item=
{
item
}
/>
{
!!
citation
?.
length
&&
config
?.
retriever_resource
?.
enabled
&&
!
respon
s
ing
&&
(
!!
citation
?.
length
&&
config
?.
retriever_resource
?.
enabled
&&
!
respon
d
ing
&&
(
<
Citation
data=
{
citation
}
showHitInfo=
{
config
.
supportCitationHitInfo
}
/>
)
}
...
...
web/app/components/base/chat/chat/context.tsx
View file @
70525653
...
...
@@ -5,7 +5,7 @@ import { createContext, useContext } from 'use-context-selector'
import
type
{
ChatProps
}
from
'./index'
export
type
ChatContextValue
=
Pick
<
ChatProps
,
'config'
|
'isRespon
s
ing'
|
'isRespon
d
ing'
|
'chatList'
|
'showPromptLog'
|
'questionIcon'
...
...
@@ -29,7 +29,7 @@ type ChatContextProviderProps = {
export
const
ChatContextProvider
=
({
children
,
config
,
isRespon
s
ing
,
isRespon
d
ing
,
chatList
,
showPromptLog
,
questionIcon
,
...
...
@@ -44,7 +44,7 @@ export const ChatContextProvider = ({
return
(
<
ChatContext
.
Provider
value=
{
{
config
,
isRespon
s
ing
,
isRespon
d
ing
,
chatList
:
chatList
||
[],
showPromptLog
,
questionIcon
,
...
...
web/app/components/base/chat/chat/hooks.ts
View file @
70525653
...
...
@@ -80,8 +80,8 @@ export const useChat = (
const
{
notify
}
=
useToastContext
()
const
connversationId
=
useRef
(
''
)
const
hasStopResponded
=
useRef
(
false
)
const
[
isRespon
sing
,
setIsRespons
ing
]
=
useState
(
false
)
const
isRespon
s
ingRef
=
useRef
(
false
)
const
[
isRespon
ding
,
setIsRespond
ing
]
=
useState
(
false
)
const
isRespon
d
ingRef
=
useRef
(
false
)
const
[
chatList
,
setChatList
]
=
useState
<
ChatItem
[]
>
(
prevChatList
||
[])
const
chatListRef
=
useRef
<
ChatItem
[]
>
(
prevChatList
||
[])
const
taskIdRef
=
useRef
(
''
)
...
...
@@ -101,9 +101,9 @@ export const useChat = (
setChatList
(
newChatList
)
chatListRef
.
current
=
newChatList
},
[])
const
handleRespon
sing
=
useCallback
((
isRespons
ing
:
boolean
)
=>
{
setIsRespon
sing
(
isRespons
ing
)
isRespon
singRef
.
current
=
isRespons
ing
const
handleRespon
ding
=
useCallback
((
isRespond
ing
:
boolean
)
=>
{
setIsRespon
ding
(
isRespond
ing
)
isRespon
dingRef
.
current
=
isRespond
ing
},
[])
const
getIntroduction
=
useCallback
((
str
:
string
)
=>
{
...
...
@@ -136,14 +136,14 @@ export const useChat = (
const
handleStop
=
useCallback
(()
=>
{
hasStopResponded
.
current
=
true
handleRespon
s
ing
(
false
)
handleRespon
d
ing
(
false
)
if
(
stopChat
&&
taskIdRef
.
current
)
stopChat
(
taskIdRef
.
current
)
if
(
conversationMessagesAbortControllerRef
.
current
)
conversationMessagesAbortControllerRef
.
current
.
abort
()
if
(
suggestedQuestionsAbortControllerRef
.
current
)
suggestedQuestionsAbortControllerRef
.
current
.
abort
()
},
[
stopChat
,
handleRespon
s
ing
])
},
[
stopChat
,
handleRespon
d
ing
])
const
handleRestart
=
useCallback
(()
=>
{
connversationId
.
current
=
''
...
...
@@ -200,7 +200,7 @@ export const useChat = (
)
=>
{
setSuggestQuestions
([])
if
(
isRespon
s
ingRef
.
current
)
{
if
(
isRespon
d
ingRef
.
current
)
{
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
return
false
}
...
...
@@ -235,7 +235,7 @@ export const useChat = (
isAnswer
:
true
,
}
handleRespon
s
ing
(
true
)
handleRespon
d
ing
(
true
)
hasStopResponded
.
current
=
false
const
bodyParams
=
{
...
...
@@ -295,7 +295,7 @@ export const useChat = (
})
},
async
onCompleted
(
hasError
?:
boolean
)
{
handleRespon
s
ing
(
false
)
handleRespon
d
ing
(
false
)
if
(
hasError
)
return
...
...
@@ -416,7 +416,7 @@ export const useChat = (
responseItem
.
content
=
messageReplace
.
answer
},
onError
()
{
handleRespon
s
ing
(
false
)
handleRespon
d
ing
(
false
)
const
newChatList
=
produce
(
chatListRef
.
current
,
(
draft
)
=>
{
draft
.
splice
(
draft
.
findIndex
(
item
=>
item
.
id
===
placeholderAnswerId
),
1
)
})
...
...
@@ -432,7 +432,7 @@ export const useChat = (
notify
,
promptVariablesConfig
,
handleUpdateChatList
,
handleRespon
s
ing
,
handleRespon
d
ing
,
])
const
handleAnnotationEdited
=
useCallback
((
query
:
string
,
answer
:
string
,
index
:
number
)
=>
{
...
...
@@ -506,8 +506,8 @@ export const useChat = (
chatList
,
setChatList
,
conversationId
:
connversationId
.
current
,
isRespon
s
ing
,
setIsRespon
s
ing
,
isRespon
d
ing
,
setIsRespon
d
ing
,
handleSend
,
suggestedQuestions
,
handleRestart
,
...
...
web/app/components/base/chat/chat/index.tsx
View file @
70525653
...
...
@@ -28,7 +28,7 @@ import { StopCircle } from '@/app/components/base/icons/src/vender/solid/mediaAn
export
type
ChatProps
=
{
chatList
:
ChatItem
[]
config
?:
ChatConfig
isRespon
s
ing
?:
boolean
isRespon
d
ing
?:
boolean
noStopResponding
?:
boolean
onStopResponding
?:
()
=>
void
noChatInput
?:
boolean
...
...
@@ -52,7 +52,7 @@ const Chat: FC<ChatProps> = ({
config
,
onSend
,
chatList
,
isRespon
s
ing
,
isRespon
d
ing
,
noStopResponding
,
onStopResponding
,
noChatInput
,
...
...
@@ -125,7 +125,7 @@ const Chat: FC<ChatProps> = ({
<
ChatContextProvider
config=
{
config
}
chatList=
{
chatList
}
isRespon
sing=
{
isRespons
ing
}
isRespon
ding=
{
isRespond
ing
}
showPromptLog=
{
showPromptLog
}
questionIcon=
{
questionIcon
}
answerIcon=
{
answerIcon
}
...
...
@@ -158,7 +158,7 @@ const Chat: FC<ChatProps> = ({
index=
{
index
}
config=
{
config
}
answerIcon=
{
answerIcon
}
respon
sing=
{
isLast
&&
isRespons
ing
}
respon
ding=
{
isLast
&&
isRespond
ing
}
allToolIcons=
{
allToolIcons
}
/>
)
...
...
@@ -169,7 +169,7 @@ const Chat: FC<ChatProps> = ({
item=
{
item
}
showPromptLog=
{
showPromptLog
}
questionIcon=
{
questionIcon
}
isRespon
sing=
{
isRespons
ing
}
isRespon
ding=
{
isRespond
ing
}
/>
)
})
...
...
@@ -188,7 +188,7 @@ const Chat: FC<ChatProps> = ({
className=
{
`${chatFooterInnerClassName}`
}
>
{
!
noStopResponding
&&
isRespon
s
ing
&&
(
!
noStopResponding
&&
isRespon
d
ing
&&
(
<
div
className=
'flex justify-center mb-2'
>
<
Button
className=
'py-0 px-3 h-7 bg-white shadow-xs'
onClick=
{
onStopResponding
}
>
<
StopCircle
className=
'mr-[5px] w-3.5 h-3.5 text-gray-500'
/>
...
...
web/app/components/base/chat/chat/question.tsx
View file @
70525653
...
...
@@ -17,12 +17,12 @@ type QuestionProps = {
item
:
ChatItem
showPromptLog
?:
boolean
questionIcon
?:
ReactNode
isRespon
s
ing
?:
boolean
isRespon
d
ing
?:
boolean
}
const
Question
:
FC
<
QuestionProps
>
=
({
item
,
showPromptLog
,
isRespon
s
ing
,
isRespon
d
ing
,
questionIcon
,
})
=>
{
const
ref
=
useRef
(
null
)
...
...
@@ -38,7 +38,7 @@ const Question: FC<QuestionProps> = ({
<
div
className=
'group relative mr-4'
>
<
QuestionTriangle
className=
'absolute -right-2 top-0 w-2 h-3 text-[#D1E9FF]/50'
/>
{
showPromptLog
&&
!
isRespon
s
ing
&&
(
showPromptLog
&&
!
isRespon
d
ing
&&
(
<
Log
log=
{
item
.
log
!
}
containerRef=
{
ref
}
/>
)
}
...
...
web/app/components/base/text-generation/hooks.ts
View file @
70525653
...
...
@@ -6,7 +6,7 @@ import { ssePost } from '@/service/base'
export
const
useTextGeneration
=
()
=>
{
const
{
t
}
=
useTranslation
()
const
{
notify
}
=
useToastContext
()
const
[
isRespon
sing
,
setIsRespons
ing
]
=
useState
(
false
)
const
[
isRespon
ding
,
setIsRespond
ing
]
=
useState
(
false
)
const
[
completion
,
setCompletion
]
=
useState
(
''
)
const
[
messageId
,
setMessageId
]
=
useState
<
string
|
null
>
(
null
)
...
...
@@ -14,12 +14,12 @@ export const useTextGeneration = () => {
url
:
string
,
data
:
any
,
)
=>
{
if
(
isRespon
s
ing
)
{
if
(
isRespon
d
ing
)
{
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
return
false
}
setIsRespon
s
ing
(
true
)
setIsRespon
d
ing
(
true
)
setCompletion
(
''
)
setMessageId
(
''
)
let
res
:
string
[]
=
[]
...
...
@@ -42,10 +42,10 @@ export const useTextGeneration = () => {
setCompletion
(
res
.
join
(
''
))
},
onCompleted
()
{
setIsRespon
s
ing
(
false
)
setIsRespon
d
ing
(
false
)
},
onError
()
{
setIsRespon
s
ing
(
false
)
setIsRespon
d
ing
(
false
)
},
})
return
true
...
...
@@ -53,8 +53,8 @@ export const useTextGeneration = () => {
return
{
completion
,
isRespon
s
ing
,
setIsRespon
s
ing
,
isRespon
d
ing
,
setIsRespon
d
ing
,
handleSend
,
messageId
,
}
...
...
web/app/components/share/chat/index.tsx
View file @
70525653
...
...
@@ -190,7 +190,7 @@ const Main: FC<IMainProps> = ({
const
[
citationConfig
,
setCitationConfig
]
=
useState
<
CitationConfig
|
null
>
(
null
)
const
[
chatList
,
setChatList
,
getChatList
]
=
useGetState
<
IChatItem
[]
>
([])
const
chatListDomRef
=
useRef
<
HTMLDivElement
>
(
null
)
const
[
isRespon
sing
,
{
setTrue
:
setResponsingTrue
,
setFalse
:
setRespons
ingFalse
}]
=
useBoolean
(
false
)
const
[
isRespon
ding
,
{
setTrue
:
setRespondingTrue
,
setFalse
:
setRespond
ingFalse
}]
=
useBoolean
(
false
)
const
[
abortController
,
setAbortController
]
=
useState
<
AbortController
|
null
>
(
null
)
const
[
conversationIdChangeBecauseOfNew
,
setConversationIdChangeBecauseOfNew
,
getConversationIdChangeBecauseOfNew
]
=
useGetState
(
false
)
const
[
isChatStarted
,
{
setTrue
:
setChatStarted
,
setFalse
:
setChatNotStarted
}]
=
useBoolean
(
false
)
...
...
@@ -198,7 +198,7 @@ const Main: FC<IMainProps> = ({
const
createNewChat
=
useCallback
(
async
()
=>
{
// if new chat is already exist, do not create new chat
abortController
?.
abort
()
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
if
(
conversationList
.
some
(
item
=>
item
.
id
===
'-1'
))
return
...
...
@@ -212,7 +212,7 @@ const Main: FC<IMainProps> = ({
}))
},
[
abortController
,
setRespon
s
ingFalse
,
setRespon
d
ingFalse
,
setConversationList
,
conversationList
,
newConversationInputs
,
...
...
@@ -504,11 +504,11 @@ const Main: FC<IMainProps> = ({
},
[
currConversationId
,
currInputs
,
promptConfig
,
t
,
logError
])
const
[
controlFocus
,
setControlFocus
]
=
useState
(
0
)
const
doShowSuggestion
=
isShowSuggestion
&&
!
isRespon
s
ing
const
doShowSuggestion
=
isShowSuggestion
&&
!
isRespon
d
ing
const
[
openingSuggestedQuestions
,
setOpeningSuggestedQuestions
]
=
useState
<
string
[]
>
([])
const
[
messageTaskId
,
setMessageTaskId
]
=
useState
(
''
)
const
[
hasStopResponded
,
setHasStopResponded
,
getHasStopResponded
]
=
useGetState
(
false
)
const
[
isRespon
singConIsCurrCon
,
setIsResponsingConCurrCon
,
getIsRespons
ingConIsCurrCon
]
=
useGetState
(
true
)
const
[
isRespon
dingConIsCurrCon
,
setIsRespondingConCurrCon
,
getIsRespond
ingConIsCurrCon
]
=
useGetState
(
true
)
const
[
userQuery
,
setUserQuery
]
=
useState
(
''
)
const
[
visionConfig
,
setVisionConfig
]
=
useState
<
VisionSettings
>
({
enabled
:
false
,
...
...
@@ -541,7 +541,7 @@ const Main: FC<IMainProps> = ({
}
const
handleSend
=
async
(
message
:
string
,
files
?:
VisionFile
[])
=>
{
if
(
isRespon
s
ing
)
{
if
(
isRespon
d
ing
)
{
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
return
}
...
...
@@ -605,9 +605,9 @@ const Main: FC<IMainProps> = ({
let
tempNewConversationId
=
prevTempNewConversationId
setHasStopResponded
(
false
)
setRespon
s
ingTrue
()
setRespon
d
ingTrue
()
setIsShowSuggestion
(
false
)
setIsRespon
s
ingConCurrCon
(
true
)
setIsRespon
d
ingConCurrCon
(
true
)
sendChatMessage
(
data
,
{
getAbortController
:
(
abortController
)
=>
{
setAbortController
(
abortController
)
...
...
@@ -632,7 +632,7 @@ const Main: FC<IMainProps> = ({
setMessageTaskId
(
taskId
)
// has switched to other conversation
if
(
prevTempNewConversationId
!==
getCurrConversationId
())
{
setIsRespon
s
ingConCurrCon
(
false
)
setIsRespon
d
ingConCurrCon
(
false
)
return
}
updateCurrentQA
({
...
...
@@ -660,12 +660,12 @@ const Main: FC<IMainProps> = ({
resetNewConversationInputs
()
setChatNotStarted
()
setCurrConversationId
(
tempNewConversationId
,
appId
,
true
)
if
(
getIsRespon
s
ingConIsCurrCon
()
&&
suggestedQuestionsAfterAnswerConfig
?.
enabled
&&
!
getHasStopResponded
())
{
if
(
getIsRespon
d
ingConIsCurrCon
()
&&
suggestedQuestionsAfterAnswerConfig
?.
enabled
&&
!
getHasStopResponded
())
{
const
{
data
}:
any
=
await
fetchSuggestedQuestions
(
responseItem
.
id
,
isInstalledApp
,
installedAppInfo
?.
id
)
setSuggestQuestions
(
data
)
setIsShowSuggestion
(
true
)
}
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
},
onFile
(
file
)
{
const
lastThought
=
responseItem
.
agent_thoughts
?.[
responseItem
.
agent_thoughts
?.
length
-
1
]
...
...
@@ -704,7 +704,7 @@ const Main: FC<IMainProps> = ({
}
// has switched to other conversation
if
(
prevTempNewConversationId
!==
getCurrConversationId
())
{
setIsRespon
s
ingConCurrCon
(
false
)
setIsRespon
d
ingConCurrCon
(
false
)
return
false
}
...
...
@@ -766,7 +766,7 @@ const Main: FC<IMainProps> = ({
}
},
onError
()
{
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
// role back placeholder answer
setChatList
(
produce
(
getChatList
(),
(
draft
)
=>
{
draft
.
splice
(
draft
.
findIndex
(
item
=>
item
.
id
===
placeholderAnswerId
),
1
)
...
...
@@ -832,10 +832,10 @@ const Main: FC<IMainProps> = ({
)
}
const
handleAbortRespon
s
ing
=
useCallback
(
async
()
=>
{
const
handleAbortRespon
d
ing
=
useCallback
(
async
()
=>
{
await
stopChatMessageResponding
(
appId
,
messageTaskId
,
isInstalledApp
,
installedAppInfo
?.
id
)
setHasStopResponded
(
true
)
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
},
[
appId
,
messageTaskId
,
isInstalledApp
,
installedAppInfo
?.
id
])
if
(
appUnavailable
)
...
...
@@ -905,7 +905,7 @@ const Main: FC<IMainProps> = ({
{
hasSetInputs
&&
(
<
div
className=
{
cn
(
doShowSuggestion
?
'pb-[140px]'
:
(
isRespon
s
ing
?
'pb-[113px]'
:
'pb-[76px]'
),
'relative grow h-[200px] pc:w-[794px] max-w-full mobile:w-full mx-auto mb-3.5 overflow-hidden'
)
}
>
<
div
className=
{
cn
(
doShowSuggestion
?
'pb-[140px]'
:
(
isRespon
d
ing
?
'pb-[113px]'
:
'pb-[76px]'
),
'relative grow h-[200px] pc:w-[794px] max-w-full mobile:w-full mx-auto mb-3.5 overflow-hidden'
)
}
>
<
div
className=
'h-full overflow-y-auto'
ref=
{
chatListDomRef
}
>
<
Chat
chatList=
{
chatList
}
...
...
@@ -914,9 +914,9 @@ const Main: FC<IMainProps> = ({
onSend=
{
handleSend
}
isHideFeedbackEdit
onFeedback=
{
handleFeedback
}
isRespon
sing=
{
isRespons
ing
}
canStopRespon
sing=
{
!!
messageTaskId
&&
isRespons
ingConIsCurrCon
}
abortRespon
sing=
{
handleAbortRespons
ing
}
isRespon
ding=
{
isRespond
ing
}
canStopRespon
ding=
{
!!
messageTaskId
&&
isRespond
ingConIsCurrCon
}
abortRespon
ding=
{
handleAbortRespond
ing
}
checkCanSend=
{
checkCanSend
}
controlFocus=
{
controlFocus
}
isShowSuggestion=
{
doShowSuggestion
}
...
...
web/app/components/share/chatbot/index.tsx
View file @
70525653
...
...
@@ -203,7 +203,7 @@ const Main: FC<IMainProps> = ({
}
// update chat list of current conversation
if
(
!
isNewConversation
&&
!
conversationIdChangeBecauseOfNew
&&
!
isRespon
s
ing
)
{
if
(
!
isNewConversation
&&
!
conversationIdChangeBecauseOfNew
&&
!
isRespon
d
ing
)
{
fetchChatList
(
currConversationId
,
isInstalledApp
,
installedAppInfo
?.
id
).
then
((
res
:
any
)
=>
{
const
{
data
}
=
res
const
newChatList
:
IChatItem
[]
=
generateNewChatListWithOpenstatement
(
notSyncToStateIntroduction
,
notSyncToStateInputs
)
...
...
@@ -252,7 +252,7 @@ const Main: FC<IMainProps> = ({
const
createNewChat
=
async
()
=>
{
// if new chat is already exist, do not create new chat
abortController
?.
abort
()
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
if
(
conversationList
.
some
(
item
=>
item
.
id
===
'-1'
))
return
...
...
@@ -369,7 +369,7 @@ const Main: FC<IMainProps> = ({
})()
},
[])
const
[
isRespon
sing
,
{
setTrue
:
setResponsingTrue
,
setFalse
:
setRespons
ingFalse
}]
=
useBoolean
(
false
)
const
[
isRespon
ding
,
{
setTrue
:
setRespondingTrue
,
setFalse
:
setRespond
ingFalse
}]
=
useBoolean
(
false
)
const
[
abortController
,
setAbortController
]
=
useState
<
AbortController
|
null
>
(
null
)
const
{
notify
}
=
useContext
(
ToastContext
)
const
logError
=
(
message
:
string
)
=>
{
...
...
@@ -407,11 +407,11 @@ const Main: FC<IMainProps> = ({
const
[
controlFocus
,
setControlFocus
]
=
useState
(
0
)
const
[
isShowSuggestion
,
setIsShowSuggestion
]
=
useState
(
false
)
const
doShowSuggestion
=
isShowSuggestion
&&
!
isRespon
s
ing
const
doShowSuggestion
=
isShowSuggestion
&&
!
isRespon
d
ing
const
[
suggestQuestions
,
setSuggestQuestions
]
=
useState
<
string
[]
>
([])
const
[
messageTaskId
,
setMessageTaskId
]
=
useState
(
''
)
const
[
hasStopResponded
,
setHasStopResponded
,
getHasStopResponded
]
=
useGetState
(
false
)
const
[
isRespon
singConIsCurrCon
,
setIsResponsingConCurrCon
,
getIsRespons
ingConIsCurrCon
]
=
useGetState
(
true
)
const
[
isRespon
dingConIsCurrCon
,
setIsRespondingConCurrCon
,
getIsRespond
ingConIsCurrCon
]
=
useGetState
(
true
)
const
[
shouldReload
,
setShouldReload
]
=
useState
(
false
)
const
[
userQuery
,
setUserQuery
]
=
useState
(
''
)
const
[
visionConfig
,
setVisionConfig
]
=
useState
<
VisionSettings
>
({
...
...
@@ -445,7 +445,7 @@ const Main: FC<IMainProps> = ({
}
const
handleSend
=
async
(
message
:
string
,
files
?:
VisionFile
[])
=>
{
if
(
isRespon
s
ing
)
{
if
(
isRespon
d
ing
)
{
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
return
}
...
...
@@ -507,7 +507,7 @@ const Main: FC<IMainProps> = ({
let
tempNewConversationId
=
prevTempNewConversationId
setHasStopResponded
(
false
)
setRespon
s
ingTrue
()
setRespon
d
ingTrue
()
setIsShowSuggestion
(
false
)
sendChatMessage
(
data
,
{
getAbortController
:
(
abortController
)
=>
{
...
...
@@ -533,7 +533,7 @@ const Main: FC<IMainProps> = ({
setMessageTaskId
(
taskId
)
// has switched to other conversation
if
(
prevTempNewConversationId
!==
getCurrConversationId
())
{
setIsRespon
s
ingConCurrCon
(
false
)
setIsRespon
d
ingConCurrCon
(
false
)
return
}
updateCurrentQA
({
...
...
@@ -565,7 +565,7 @@ const Main: FC<IMainProps> = ({
setSuggestQuestions
(
data
)
setIsShowSuggestion
(
true
)
}
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
},
onFile
(
file
)
{
const
lastThought
=
responseItem
.
agent_thoughts
?.[
responseItem
.
agent_thoughts
?.
length
-
1
]
...
...
@@ -604,7 +604,7 @@ const Main: FC<IMainProps> = ({
}
// has switched to other conversation
if
(
prevTempNewConversationId
!==
getCurrConversationId
())
{
setIsRespon
s
ingConCurrCon
(
false
)
setIsRespon
d
ingConCurrCon
(
false
)
return
false
}
...
...
@@ -666,7 +666,7 @@ const Main: FC<IMainProps> = ({
}
},
onError
()
{
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
// role back placeholder answer
setChatList
(
produce
(
getChatList
(),
(
draft
)
=>
{
draft
.
splice
(
draft
.
findIndex
(
item
=>
item
.
id
===
placeholderAnswerId
),
1
)
...
...
@@ -773,7 +773,7 @@ const Main: FC<IMainProps> = ({
}
{
hasSetInputs
&&
(
<
div
className=
{
cn
(
doShowSuggestion
?
'pb-[140px]'
:
(
isRespon
s
ing
?
'pb-[113px]'
:
'pb-[76px]'
),
'relative grow h-[200px] pc:w-[794px] max-w-full mobile:w-full mx-auto mb-3.5 overflow-hidden'
)
}
>
<
div
className=
{
cn
(
doShowSuggestion
?
'pb-[140px]'
:
(
isRespon
d
ing
?
'pb-[113px]'
:
'pb-[76px]'
),
'relative grow h-[200px] pc:w-[794px] max-w-full mobile:w-full mx-auto mb-3.5 overflow-hidden'
)
}
>
<
div
className=
'h-full overflow-y-auto'
ref=
{
chatListDomRef
}
>
<
Chat
chatList=
{
chatList
}
...
...
@@ -782,12 +782,12 @@ const Main: FC<IMainProps> = ({
onSend=
{
handleSend
}
isHideFeedbackEdit
onFeedback=
{
handleFeedback
}
isRespon
sing=
{
isRespons
ing
}
canStopRespon
sing=
{
!!
messageTaskId
&&
isRespons
ingConIsCurrCon
}
abortRespon
s
ing=
{
async
()
=>
{
isRespon
ding=
{
isRespond
ing
}
canStopRespon
ding=
{
!!
messageTaskId
&&
isRespond
ingConIsCurrCon
}
abortRespon
d
ing=
{
async
()
=>
{
await
stopChatMessageResponding
(
appId
,
messageTaskId
,
isInstalledApp
,
installedAppInfo
?.
id
)
setHasStopResponded
(
true
)
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
}
}
checkCanSend=
{
checkCanSend
}
controlFocus=
{
controlFocus
}
...
...
web/app/components/share/text-generation/result/index.tsx
View file @
70525653
...
...
@@ -60,10 +60,10 @@ const Result: FC<IResultProps> = ({
visionConfig
,
completionFiles
,
})
=>
{
const
[
isRespon
sing
,
{
setTrue
:
setResponsingTrue
,
setFalse
:
setRespons
ingFalse
}]
=
useBoolean
(
false
)
const
[
isRespon
ding
,
{
setTrue
:
setRespondingTrue
,
setFalse
:
setRespond
ingFalse
}]
=
useBoolean
(
false
)
useEffect
(()
=>
{
if
(
controlStopResponding
)
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
},
[
controlStopResponding
])
const
[
completionRes
,
doSetCompletionRes
]
=
useState
(
''
)
...
...
@@ -130,7 +130,7 @@ const Result: FC<IResultProps> = ({
}
const
handleSend
=
async
()
=>
{
if
(
isRespon
s
ing
)
{
if
(
isRespon
d
ing
)
{
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
return
false
}
...
...
@@ -165,13 +165,13 @@ const Result: FC<IResultProps> = ({
if
(
!
isPC
)
onShowRes
()
setRespon
s
ingTrue
()
setRespon
d
ingTrue
()
const
startTime
=
Date
.
now
()
let
isTimeout
=
false
const
runId
=
setInterval
(()
=>
{
if
(
Date
.
now
()
-
startTime
>
1000
*
60
)
{
// 1min timeout
clearInterval
(
runId
)
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
onCompleted
(
getCompletionRes
(),
taskId
,
false
)
isTimeout
=
true
}
...
...
@@ -186,7 +186,7 @@ const Result: FC<IResultProps> = ({
if
(
isTimeout
)
return
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
setMessageId
(
tempMessageId
)
onCompleted
(
getCompletionRes
(),
taskId
,
true
)
clearInterval
(
runId
)
...
...
@@ -199,7 +199,7 @@ const Result: FC<IResultProps> = ({
if
(
isTimeout
)
return
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
onCompleted
(
getCompletionRes
(),
taskId
,
false
)
clearInterval
(
runId
)
},
...
...
@@ -234,7 +234,7 @@ const Result: FC<IResultProps> = ({
isMobile=
{
isMobile
}
isInstalledApp=
{
isInstalledApp
}
installedAppId=
{
installedAppInfo
?.
id
}
isLoading=
{
isCallBatchAPI
?
(
!
completionRes
&&
isRespon
s
ing
)
:
false
}
isLoading=
{
isCallBatchAPI
?
(
!
completionRes
&&
isRespon
d
ing
)
:
false
}
taskId=
{
isCallBatchAPI
?
((
taskId
as
number
)
<
10
?
`0${taskId}`
:
`${taskId}`
)
:
undefined
}
controlClearMoreLikeThis=
{
controlClearMoreLikeThis
}
isShowTextToSpeech=
{
isShowTextToSpeech
}
...
...
@@ -244,7 +244,7 @@ const Result: FC<IResultProps> = ({
return
(
<
div
className=
{
cn
(
isNoData
&&
!
isCallBatchAPI
&&
'h-full'
)
}
>
{
!
isCallBatchAPI
&&
(
(
isRespon
s
ing
&&
!
completionRes
)
(
isRespon
d
ing
&&
!
completionRes
)
?
(
<
div
className=
'flex h-full w-full justify-center items-center'
>
<
Loading
type=
'area'
/>
...
...
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