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
Show 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 = {
...
@@ -49,7 +49,7 @@ export type IAnswerProps = {
onQueryChange
:
(
query
:
string
)
=>
void
onQueryChange
:
(
query
:
string
)
=>
void
onFeedback
?:
FeedbackFunc
onFeedback
?:
FeedbackFunc
displayScene
:
DisplayScene
displayScene
:
DisplayScene
isRespon
s
ing
?:
boolean
isRespon
d
ing
?:
boolean
answerIcon
?:
ReactNode
answerIcon
?:
ReactNode
citation
?:
CitationItem
[]
citation
?:
CitationItem
[]
dataSets
?:
DataSet
[]
dataSets
?:
DataSet
[]
...
@@ -74,7 +74,7 @@ const Answer: FC<IAnswerProps> = ({
...
@@ -74,7 +74,7 @@ const Answer: FC<IAnswerProps> = ({
isHideFeedbackEdit
=
false
,
isHideFeedbackEdit
=
false
,
onFeedback
,
onFeedback
,
displayScene
=
'web'
,
displayScene
=
'web'
,
isRespon
s
ing
,
isRespon
d
ing
,
answerIcon
,
answerIcon
,
citation
,
citation
,
isShowCitation
,
isShowCitation
,
...
@@ -229,7 +229,7 @@ const Answer: FC<IAnswerProps> = ({
...
@@ -229,7 +229,7 @@ const Answer: FC<IAnswerProps> = ({
<
Thought
<
Thought
thought=
{
item
}
thought=
{
item
}
allToolIcons=
{
allToolIcons
||
{}
}
allToolIcons=
{
allToolIcons
||
{}
}
isFinished=
{
!!
item
.
observation
||
!
isRespon
s
ing
}
isFinished=
{
!!
item
.
observation
||
!
isRespon
d
ing
}
/>
/>
)
}
)
}
...
@@ -248,7 +248,7 @@ const Answer: FC<IAnswerProps> = ({
...
@@ -248,7 +248,7 @@ const Answer: FC<IAnswerProps> = ({
{
{
answerIcon
||
(
answerIcon
||
(
<
div
className=
{
`${s.answerIcon} w-10 h-10 shrink-0`
}
>
<
div
className=
{
`${s.answerIcon} w-10 h-10 shrink-0`
}
>
{
isRespon
s
ing
{
isRespon
d
ing
&&
<
div
className=
{
s
.
typeingIcon
}
>
&&
<
div
className=
{
s
.
typeingIcon
}
>
<
LoadingAnim
type=
'avatar'
/>
<
LoadingAnim
type=
'avatar'
/>
</
div
>
</
div
>
...
@@ -260,7 +260,7 @@ const Answer: FC<IAnswerProps> = ({
...
@@ -260,7 +260,7 @@ const Answer: FC<IAnswerProps> = ({
<
div
className=
{
`${s.answerWrap} ${showEdit ? 'w-full' : ''}`
}
>
<
div
className=
{
`${s.answerWrap} ${showEdit ? 'w-full' : ''}`
}
>
<
div
className=
{
`${s.answer} relative text-sm text-gray-900`
}
>
<
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'
}
>
<
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'
>
<
div
className=
'flex items-center justify-center w-6 h-5'
>
<
LoadingAnim
type=
'text'
/>
<
LoadingAnim
type=
'text'
/>
...
@@ -314,7 +314,7 @@ const Answer: FC<IAnswerProps> = ({
...
@@ -314,7 +314,7 @@ const Answer: FC<IAnswerProps> = ({
</
div
>
</
div
>
)
}
)
}
{
{
!!
citation
?.
length
&&
isShowCitation
&&
!
isRespon
s
ing
&&
(
!!
citation
?.
length
&&
isShowCitation
&&
!
isRespon
d
ing
&&
(
<
Citation
data=
{
citation
}
showHitInfo=
{
isShowCitationHitInfo
}
/>
<
Citation
data=
{
citation
}
showHitInfo=
{
isShowCitationHitInfo
}
/>
)
)
}
}
...
...
web/app/components/app/chat/index.tsx
View file @
70525653
...
@@ -49,9 +49,9 @@ export type IChatProps = {
...
@@ -49,9 +49,9 @@ export type IChatProps = {
onSend
?:
(
message
:
string
,
files
:
VisionFile
[])
=>
void
onSend
?:
(
message
:
string
,
files
:
VisionFile
[])
=>
void
displayScene
?:
DisplayScene
displayScene
?:
DisplayScene
useCurrentUserAvatar
?:
boolean
useCurrentUserAvatar
?:
boolean
isRespon
s
ing
?:
boolean
isRespon
d
ing
?:
boolean
canStopRespon
s
ing
?:
boolean
canStopRespon
d
ing
?:
boolean
abortRespon
s
ing
?:
()
=>
void
abortRespon
d
ing
?:
()
=>
void
controlClearQuery
?:
number
controlClearQuery
?:
number
controlFocus
?:
number
controlFocus
?:
number
isShowSuggestion
?:
boolean
isShowSuggestion
?:
boolean
...
@@ -82,9 +82,9 @@ const Chat: FC<IChatProps> = ({
...
@@ -82,9 +82,9 @@ const Chat: FC<IChatProps> = ({
onSend
=
()
=>
{
},
onSend
=
()
=>
{
},
displayScene
,
displayScene
,
useCurrentUserAvatar
,
useCurrentUserAvatar
,
isRespon
s
ing
,
isRespon
d
ing
,
canStopRespon
s
ing
,
canStopRespon
d
ing
,
abortRespon
s
ing
,
abortRespon
d
ing
,
controlClearQuery
,
controlClearQuery
,
controlFocus
,
controlFocus
,
isShowSuggestion
,
isShowSuggestion
,
...
@@ -153,7 +153,7 @@ const Chat: FC<IChatProps> = ({
...
@@ -153,7 +153,7 @@ const Chat: FC<IChatProps> = ({
if
(
!
files
.
find
(
item
=>
item
.
type
===
TransferMethod
.
local_file
&&
!
item
.
fileId
))
{
if
(
!
files
.
find
(
item
=>
item
.
type
===
TransferMethod
.
local_file
&&
!
item
.
fileId
))
{
if
(
files
.
length
)
if
(
files
.
length
)
onClear
()
onClear
()
if
(
!
isRespon
s
ing
)
if
(
!
isRespon
d
ing
)
onQueryChange
(
''
)
onQueryChange
(
''
)
}
}
}
}
...
@@ -286,7 +286,7 @@ const Chat: FC<IChatProps> = ({
...
@@ -286,7 +286,7 @@ const Chat: FC<IChatProps> = ({
isHideFeedbackEdit=
{
isHideFeedbackEdit
}
isHideFeedbackEdit=
{
isHideFeedbackEdit
}
onFeedback=
{
onFeedback
}
onFeedback=
{
onFeedback
}
displayScene=
{
displayScene
??
'web'
}
displayScene=
{
displayScene
??
'web'
}
isRespon
sing=
{
isRespons
ing
&&
isLast
}
isRespon
ding=
{
isRespond
ing
&&
isLast
}
answerIcon=
{
answerIcon
}
answerIcon=
{
answerIcon
}
citation=
{
citation
}
citation=
{
citation
}
dataSets=
{
dataSets
}
dataSets=
{
dataSets
}
...
@@ -311,7 +311,7 @@ const Chat: FC<IChatProps> = ({
...
@@ -311,7 +311,7 @@ const Chat: FC<IChatProps> = ({
useCurrentUserAvatar=
{
useCurrentUserAvatar
}
useCurrentUserAvatar=
{
useCurrentUserAvatar
}
item=
{
item
}
item=
{
item
}
isShowPromptLog=
{
isShowPromptLog
}
isShowPromptLog=
{
isShowPromptLog
}
isRespon
sing=
{
isRespons
ing
}
isRespon
ding=
{
isRespond
ing
}
/>
/>
)
)
})
}
})
}
...
@@ -320,9 +320,9 @@ const Chat: FC<IChatProps> = ({
...
@@ -320,9 +320,9 @@ const Chat: FC<IChatProps> = ({
!
isHideSendInput
&&
(
!
isHideSendInput
&&
(
<
div
className=
{
cn
(
!
feedbackDisabled
&&
'!left-3.5 !right-3.5'
,
'absolute z-10 bottom-0 left-0 right-0'
)
}
>
<
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 */
}
{
/* 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'
>
<
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
}
{
stopIcon
}
<
span
className=
'text-xs text-gray-500 font-normal'
>
{
t
(
'appDebug.operation.stopResponding'
)
}
</
span
>
<
span
className=
'text-xs text-gray-500 font-normal'
>
{
t
(
'appDebug.operation.stopResponding'
)
}
</
span
>
</
Button
>
</
Button
>
...
...
web/app/components/app/chat/question/index.tsx
View file @
70525653
...
@@ -13,10 +13,10 @@ import ImageGallery from '@/app/components/base/image-gallery'
...
@@ -13,10 +13,10 @@ import ImageGallery from '@/app/components/base/image-gallery'
type
IQuestionProps
=
Pick
<
IChatItem
,
'id'
|
'content'
|
'more'
|
'useCurrentUserAvatar'
>
&
{
type
IQuestionProps
=
Pick
<
IChatItem
,
'id'
|
'content'
|
'more'
|
'useCurrentUserAvatar'
>
&
{
isShowPromptLog
?:
boolean
isShowPromptLog
?:
boolean
item
:
IChatItem
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
{
userProfile
}
=
useContext
(
AppContext
)
const
userName
=
userProfile
?.
name
const
userName
=
userProfile
?.
name
const
ref
=
useRef
(
null
)
const
ref
=
useRef
(
null
)
...
@@ -28,7 +28,7 @@ const Question: FC<IQuestionProps> = ({ id, content, more, useCurrentUserAvatar,
...
@@ -28,7 +28,7 @@ const Question: FC<IQuestionProps> = ({ id, content, more, useCurrentUserAvatar,
<
div
className=
{
`${s.question} group relative text-sm text-gray-900`
}
>
<
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
}
/>
<
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> = ({
...
@@ -46,7 +46,7 @@ const ChatItem: FC<ChatItemProps> = ({
const
config
=
useConfigFromDebugContext
()
const
config
=
useConfigFromDebugContext
()
const
{
const
{
chatList
,
chatList
,
isRespon
s
ing
,
isRespon
d
ing
,
handleSend
,
handleSend
,
suggestedQuestions
,
suggestedQuestions
,
handleRestart
,
handleRestart
,
...
@@ -118,7 +118,7 @@ const ChatItem: FC<ChatItemProps> = ({
...
@@ -118,7 +118,7 @@ const ChatItem: FC<ChatItemProps> = ({
<
Chat
<
Chat
config=
{
config
}
config=
{
config
}
chatList=
{
chatList
}
chatList=
{
chatList
}
isRespon
sing=
{
isRespons
ing
}
isRespon
ding=
{
isRespond
ing
}
noChatInput
noChatInput
noStopResponding
noStopResponding
chatContainerclassName=
'p-4'
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> = ({
...
@@ -83,7 +83,7 @@ const TextGenerationItem: FC<TextGenerationItemProps> = ({
const
{
const
{
completion
,
completion
,
handleSend
,
handleSend
,
isRespon
s
ing
,
isRespon
d
ing
,
messageId
,
messageId
,
}
=
useTextGeneration
()
}
=
useTextGeneration
()
...
@@ -143,8 +143,8 @@ const TextGenerationItem: FC<TextGenerationItemProps> = ({
...
@@ -143,8 +143,8 @@ const TextGenerationItem: FC<TextGenerationItemProps> = ({
innerClassName=
'grow flex flex-col'
innerClassName=
'grow flex flex-col'
contentClassName=
'grow'
contentClassName=
'grow'
content=
{
completion
}
content=
{
completion
}
isLoading=
{
!
completion
&&
isRespon
s
ing
}
isLoading=
{
!
completion
&&
isRespon
d
ing
}
isRespon
sing=
{
isRespons
ing
}
isRespon
ding=
{
isRespond
ing
}
isInstalledApp=
{
false
}
isInstalledApp=
{
false
}
messageId=
{
messageId
}
messageId=
{
messageId
}
isError=
{
false
}
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
...
@@ -45,7 +45,7 @@ const DebugWithSingleModel = forwardRef<DebugWithSingleModelRefType, DebugWithSi
const
config
=
useConfigFromDebugContext
()
const
config
=
useConfigFromDebugContext
()
const
{
const
{
chatList
,
chatList
,
isRespon
s
ing
,
isRespon
d
ing
,
handleSend
,
handleSend
,
suggestedQuestions
,
suggestedQuestions
,
handleStop
,
handleStop
,
...
@@ -118,7 +118,7 @@ const DebugWithSingleModel = forwardRef<DebugWithSingleModelRefType, DebugWithSi
...
@@ -118,7 +118,7 @@ const DebugWithSingleModel = forwardRef<DebugWithSingleModelRefType, DebugWithSi
<
Chat
<
Chat
config=
{
config
}
config=
{
config
}
chatList=
{
chatList
}
chatList=
{
chatList
}
isRespon
sing=
{
isRespons
ing
}
isRespon
ding=
{
isRespond
ing
}
chatContainerclassName=
'p-6'
chatContainerclassName=
'p-6'
chatFooterClassName=
'px-6 pt-10 pb-4'
chatFooterClassName=
'px-6 pt-10 pb-4'
suggestedQuestions=
{
suggestedQuestions
}
suggestedQuestions=
{
suggestedQuestions
}
...
...
web/app/components/app/configuration/debug/index.tsx
View file @
70525653
...
@@ -93,7 +93,7 @@ const Debug: FC<IDebug> = ({
...
@@ -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
[
isShowFormattingChangeConfirm
,
setIsShowFormattingChangeConfirm
]
=
useState
(
false
)
const
[
isShowCannotQueryDataset
,
setShowCannotQueryDataset
]
=
useState
(
false
)
const
[
isShowCannotQueryDataset
,
setShowCannotQueryDataset
]
=
useState
(
false
)
...
@@ -191,7 +191,7 @@ const Debug: FC<IDebug> = ({
...
@@ -191,7 +191,7 @@ const Debug: FC<IDebug> = ({
const
[
messageId
,
setMessageId
]
=
useState
<
string
|
null
>
(
null
)
const
[
messageId
,
setMessageId
]
=
useState
<
string
|
null
>
(
null
)
const
sendTextCompletion
=
async
()
=>
{
const
sendTextCompletion
=
async
()
=>
{
if
(
isRespon
s
ing
)
{
if
(
isRespon
d
ing
)
{
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
return
false
return
false
}
}
...
@@ -277,7 +277,7 @@ const Debug: FC<IDebug> = ({
...
@@ -277,7 +277,7 @@ const Debug: FC<IDebug> = ({
setMessageId
(
''
)
setMessageId
(
''
)
let
res
:
string
[]
=
[]
let
res
:
string
[]
=
[]
setRespon
s
ingTrue
()
setRespon
d
ingTrue
()
sendCompletionMessage
(
appId
,
data
,
{
sendCompletionMessage
(
appId
,
data
,
{
onData
:
(
data
:
string
,
_isFirstMessage
:
boolean
,
{
messageId
})
=>
{
onData
:
(
data
:
string
,
_isFirstMessage
:
boolean
,
{
messageId
})
=>
{
res
.
push
(
data
)
res
.
push
(
data
)
...
@@ -289,10 +289,10 @@ const Debug: FC<IDebug> = ({
...
@@ -289,10 +289,10 @@ const Debug: FC<IDebug> = ({
setCompletionRes
(
res
.
join
(
''
))
setCompletionRes
(
res
.
join
(
''
))
},
},
onCompleted
()
{
onCompleted
()
{
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
},
},
onError
()
{
onError
()
{
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
},
},
})
})
}
}
...
@@ -440,13 +440,13 @@ const Debug: FC<IDebug> = ({
...
@@ -440,13 +440,13 @@ const Debug: FC<IDebug> = ({
{
mode
===
AppType
.
completion
&&
(
{
mode
===
AppType
.
completion
&&
(
<
div
className=
"mt-6 px-6 pb-4"
>
<
div
className=
"mt-6 px-6 pb-4"
>
<
GroupName
name=
{
t
(
'appDebug.result'
)
}
/>
<
GroupName
name=
{
t
(
'appDebug.result'
)
}
/>
{
(
completionRes
||
isRespon
s
ing
)
&&
(
{
(
completionRes
||
isRespon
d
ing
)
&&
(
<
TextGeneration
<
TextGeneration
className=
"mt-2"
className=
"mt-2"
content=
{
completionRes
}
content=
{
completionRes
}
isLoading=
{
!
completionRes
&&
isRespon
s
ing
}
isLoading=
{
!
completionRes
&&
isRespon
d
ing
}
isShowTextToSpeech=
{
textToSpeechConfig
.
enabled
&&
!!
text2speechDefaultModel
}
isShowTextToSpeech=
{
textToSpeechConfig
.
enabled
&&
!!
text2speechDefaultModel
}
isRespon
sing=
{
isRespons
ing
}
isRespon
ding=
{
isRespond
ing
}
isInstalledApp=
{
false
}
isInstalledApp=
{
false
}
messageId=
{
messageId
}
messageId=
{
messageId
}
isError=
{
false
}
isError=
{
false
}
...
...
web/app/components/app/text-generate/item/index.tsx
View file @
70525653
...
@@ -32,7 +32,7 @@ export type IGenerationItemProps = {
...
@@ -32,7 +32,7 @@ export type IGenerationItemProps = {
messageId
?:
string
|
null
messageId
?:
string
|
null
conversationId
?:
string
conversationId
?:
string
isLoading
?:
boolean
isLoading
?:
boolean
isRespon
s
ing
?:
boolean
isRespon
d
ing
?:
boolean
isInWebApp
?:
boolean
isInWebApp
?:
boolean
moreLikeThis
?:
boolean
moreLikeThis
?:
boolean
depth
?:
number
depth
?:
number
...
@@ -81,7 +81,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
...
@@ -81,7 +81,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
content
,
content
,
messageId
,
messageId
,
isLoading
,
isLoading
,
isRespon
s
ing
,
isRespon
d
ing
,
moreLikeThis
,
moreLikeThis
,
isInWebApp
=
false
,
isInWebApp
=
false
,
feedback
,
feedback
,
...
@@ -277,7 +277,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
...
@@ -277,7 +277,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
<
div
className=
'flex items-center justify-between mt-3'
>
<
div
className=
'flex items-center justify-between mt-3'
>
<
div
className=
'flex items-center'
>
<
div
className=
'flex items-center'
>
{
{
!
isInWebApp
&&
!
isInstalledApp
&&
!
isRespon
s
ing
&&
(
!
isInWebApp
&&
!
isInstalledApp
&&
!
isRespon
d
ing
&&
(
<
PromptLog
<
PromptLog
log=
{
promptLog
}
log=
{
promptLog
}
containerRef=
{
ref
}
containerRef=
{
ref
}
...
...
web/app/components/base/chat/chat-with-history/chat-wrapper.tsx
View file @
70525653
...
@@ -43,7 +43,7 @@ const ChatWrapper = () => {
...
@@ -43,7 +43,7 @@ const ChatWrapper = () => {
chatList
,
chatList
,
handleSend
,
handleSend
,
handleStop
,
handleStop
,
isRespon
s
ing
,
isRespon
d
ing
,
suggestedQuestions
,
suggestedQuestions
,
}
=
useChat
(
}
=
useChat
(
appConfig
,
appConfig
,
...
@@ -130,7 +130,7 @@ const ChatWrapper = () => {
...
@@ -130,7 +130,7 @@ const ChatWrapper = () => {
<
Chat
<
Chat
config=
{
appConfig
}
config=
{
appConfig
}
chatList=
{
chatList
}
chatList=
{
chatList
}
isRespon
sing=
{
isRespons
ing
}
isRespon
ding=
{
isRespond
ing
}
chatContainerInnerClassName=
{
`mx-auto pt-6 w-full max-w-[720px] ${isMobile && 'px-4'}`
}
chatContainerInnerClassName=
{
`mx-auto pt-6 w-full max-w-[720px] ${isMobile && 'px-4'}`
}
chatFooterClassName=
'pb-4'
chatFooterClassName=
'pb-4'
chatFooterInnerClassName=
{
`mx-auto w-full max-w-[720px] ${isMobile && 'px-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'
...
@@ -11,12 +11,12 @@ import type { Emoji } from '@/app/components/tools/types'
type
AgentContentProps
=
{
type
AgentContentProps
=
{
item
:
ChatItem
item
:
ChatItem
respon
s
ing
?:
boolean
respon
d
ing
?:
boolean
allToolIcons
?:
Record
<
string
,
string
|
Emoji
>
allToolIcons
?:
Record
<
string
,
string
|
Emoji
>
}
}
const
AgentContent
:
FC
<
AgentContentProps
>
=
({
const
AgentContent
:
FC
<
AgentContentProps
>
=
({
item
,
item
,
respon
s
ing
,
respon
d
ing
,
allToolIcons
,
allToolIcons
,
})
=>
{
})
=>
{
const
{
const
{
...
@@ -46,7 +46,7 @@ const AgentContent: FC<AgentContentProps> = ({
...
@@ -46,7 +46,7 @@ const AgentContent: FC<AgentContentProps> = ({
<
Thought
<
Thought
thought=
{
thought
}
thought=
{
thought
}
allToolIcons=
{
allToolIcons
||
{}
}
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 = {
...
@@ -25,7 +25,7 @@ type AnswerProps = {
index
:
number
index
:
number
config
?:
ChatConfig
config
?:
ChatConfig
answerIcon
?:
ReactNode
answerIcon
?:
ReactNode
respon
s
ing
?:
boolean
respon
d
ing
?:
boolean
allToolIcons
?:
Record
<
string
,
string
|
Emoji
>
allToolIcons
?:
Record
<
string
,
string
|
Emoji
>
}
}
const
Answer
:
FC
<
AnswerProps
>
=
({
const
Answer
:
FC
<
AnswerProps
>
=
({
...
@@ -34,7 +34,7 @@ const Answer: FC<AnswerProps> = ({
...
@@ -34,7 +34,7 @@ const Answer: FC<AnswerProps> = ({
index
,
index
,
config
,
config
,
answerIcon
,
answerIcon
,
respon
s
ing
,
respon
d
ing
,
allToolIcons
,
allToolIcons
,
})
=>
{
})
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
...
@@ -58,7 +58,7 @@ const Answer: FC<AnswerProps> = ({
...
@@ -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'
>
<
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'
/>
<
LoadingAnim
type=
'avatar'
/>
</
div
>
</
div
>
...
@@ -70,7 +70,7 @@ const Answer: FC<AnswerProps> = ({
...
@@ -70,7 +70,7 @@ const Answer: FC<AnswerProps> = ({
<
AnswerTriangle
className=
'absolute -left-2 top-0 w-2 h-3 text-gray-100'
/>
<
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'
>
<
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
<
Operation
item=
{
item
}
item=
{
item
}
question=
{
question
}
question=
{
question
}
...
@@ -79,7 +79,7 @@ const Answer: FC<AnswerProps> = ({
...
@@ -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'
>
<
div
className=
'flex items-center justify-center w-6 h-5'
>
<
LoadingAnim
type=
'text'
/>
<
LoadingAnim
type=
'text'
/>
</
div
>
</
div
>
...
@@ -94,7 +94,7 @@ const Answer: FC<AnswerProps> = ({
...
@@ -94,7 +94,7 @@ const Answer: FC<AnswerProps> = ({
hasAgentThoughts
&&
(
hasAgentThoughts
&&
(
<
AgentContent
<
AgentContent
item=
{
item
}
item=
{
item
}
respon
sing=
{
respons
ing
}
respon
ding=
{
respond
ing
}
allToolIcons=
{
allToolIcons
}
allToolIcons=
{
allToolIcons
}
/>
/>
)
)
...
@@ -109,7 +109,7 @@ const Answer: FC<AnswerProps> = ({
...
@@ -109,7 +109,7 @@ const Answer: FC<AnswerProps> = ({
}
}
<
SuggestedQuestions
item=
{
item
}
/>
<
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
}
/>
<
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'
...
@@ -5,7 +5,7 @@ import { createContext, useContext } from 'use-context-selector'
import
type
{
ChatProps
}
from
'./index'
import
type
{
ChatProps
}
from
'./index'
export
type
ChatContextValue
=
Pick
<
ChatProps
,
'config'
export
type
ChatContextValue
=
Pick
<
ChatProps
,
'config'
|
'isRespon
s
ing'
|
'isRespon
d
ing'
|
'chatList'
|
'chatList'
|
'showPromptLog'
|
'showPromptLog'
|
'questionIcon'
|
'questionIcon'
...
@@ -29,7 +29,7 @@ type ChatContextProviderProps = {
...
@@ -29,7 +29,7 @@ type ChatContextProviderProps = {
export
const
ChatContextProvider
=
({
export
const
ChatContextProvider
=
({
children
,
children
,
config
,
config
,
isRespon
s
ing
,
isRespon
d
ing
,
chatList
,
chatList
,
showPromptLog
,
showPromptLog
,
questionIcon
,
questionIcon
,
...
@@ -44,7 +44,7 @@ export const ChatContextProvider = ({
...
@@ -44,7 +44,7 @@ export const ChatContextProvider = ({
return
(
return
(
<
ChatContext
.
Provider
value=
{
{
<
ChatContext
.
Provider
value=
{
{
config
,
config
,
isRespon
s
ing
,
isRespon
d
ing
,
chatList
:
chatList
||
[],
chatList
:
chatList
||
[],
showPromptLog
,
showPromptLog
,
questionIcon
,
questionIcon
,
...
...
web/app/components/base/chat/chat/hooks.ts
View file @
70525653
...
@@ -80,8 +80,8 @@ export const useChat = (
...
@@ -80,8 +80,8 @@ export const useChat = (
const
{
notify
}
=
useToastContext
()
const
{
notify
}
=
useToastContext
()
const
connversationId
=
useRef
(
''
)
const
connversationId
=
useRef
(
''
)
const
hasStopResponded
=
useRef
(
false
)
const
hasStopResponded
=
useRef
(
false
)
const
[
isRespon
sing
,
setIsRespons
ing
]
=
useState
(
false
)
const
[
isRespon
ding
,
setIsRespond
ing
]
=
useState
(
false
)
const
isRespon
s
ingRef
=
useRef
(
false
)
const
isRespon
d
ingRef
=
useRef
(
false
)
const
[
chatList
,
setChatList
]
=
useState
<
ChatItem
[]
>
(
prevChatList
||
[])
const
[
chatList
,
setChatList
]
=
useState
<
ChatItem
[]
>
(
prevChatList
||
[])
const
chatListRef
=
useRef
<
ChatItem
[]
>
(
prevChatList
||
[])
const
chatListRef
=
useRef
<
ChatItem
[]
>
(
prevChatList
||
[])
const
taskIdRef
=
useRef
(
''
)
const
taskIdRef
=
useRef
(
''
)
...
@@ -101,9 +101,9 @@ export const useChat = (
...
@@ -101,9 +101,9 @@ export const useChat = (
setChatList
(
newChatList
)
setChatList
(
newChatList
)
chatListRef
.
current
=
newChatList
chatListRef
.
current
=
newChatList
},
[])
},
[])
const
handleRespon
sing
=
useCallback
((
isRespons
ing
:
boolean
)
=>
{
const
handleRespon
ding
=
useCallback
((
isRespond
ing
:
boolean
)
=>
{
setIsRespon
sing
(
isRespons
ing
)
setIsRespon
ding
(
isRespond
ing
)
isRespon
singRef
.
current
=
isRespons
ing
isRespon
dingRef
.
current
=
isRespond
ing
},
[])
},
[])
const
getIntroduction
=
useCallback
((
str
:
string
)
=>
{
const
getIntroduction
=
useCallback
((
str
:
string
)
=>
{
...
@@ -136,14 +136,14 @@ export const useChat = (
...
@@ -136,14 +136,14 @@ export const useChat = (
const
handleStop
=
useCallback
(()
=>
{
const
handleStop
=
useCallback
(()
=>
{
hasStopResponded
.
current
=
true
hasStopResponded
.
current
=
true
handleRespon
s
ing
(
false
)
handleRespon
d
ing
(
false
)
if
(
stopChat
&&
taskIdRef
.
current
)
if
(
stopChat
&&
taskIdRef
.
current
)
stopChat
(
taskIdRef
.
current
)
stopChat
(
taskIdRef
.
current
)
if
(
conversationMessagesAbortControllerRef
.
current
)
if
(
conversationMessagesAbortControllerRef
.
current
)
conversationMessagesAbortControllerRef
.
current
.
abort
()
conversationMessagesAbortControllerRef
.
current
.
abort
()
if
(
suggestedQuestionsAbortControllerRef
.
current
)
if
(
suggestedQuestionsAbortControllerRef
.
current
)
suggestedQuestionsAbortControllerRef
.
current
.
abort
()
suggestedQuestionsAbortControllerRef
.
current
.
abort
()
},
[
stopChat
,
handleRespon
s
ing
])
},
[
stopChat
,
handleRespon
d
ing
])
const
handleRestart
=
useCallback
(()
=>
{
const
handleRestart
=
useCallback
(()
=>
{
connversationId
.
current
=
''
connversationId
.
current
=
''
...
@@ -200,7 +200,7 @@ export const useChat = (
...
@@ -200,7 +200,7 @@ export const useChat = (
)
=>
{
)
=>
{
setSuggestQuestions
([])
setSuggestQuestions
([])
if
(
isRespon
s
ingRef
.
current
)
{
if
(
isRespon
d
ingRef
.
current
)
{
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
return
false
return
false
}
}
...
@@ -235,7 +235,7 @@ export const useChat = (
...
@@ -235,7 +235,7 @@ export const useChat = (
isAnswer
:
true
,
isAnswer
:
true
,
}
}
handleRespon
s
ing
(
true
)
handleRespon
d
ing
(
true
)
hasStopResponded
.
current
=
false
hasStopResponded
.
current
=
false
const
bodyParams
=
{
const
bodyParams
=
{
...
@@ -295,7 +295,7 @@ export const useChat = (
...
@@ -295,7 +295,7 @@ export const useChat = (
})
})
},
},
async
onCompleted
(
hasError
?:
boolean
)
{
async
onCompleted
(
hasError
?:
boolean
)
{
handleRespon
s
ing
(
false
)
handleRespon
d
ing
(
false
)
if
(
hasError
)
if
(
hasError
)
return
return
...
@@ -416,7 +416,7 @@ export const useChat = (
...
@@ -416,7 +416,7 @@ export const useChat = (
responseItem
.
content
=
messageReplace
.
answer
responseItem
.
content
=
messageReplace
.
answer
},
},
onError
()
{
onError
()
{
handleRespon
s
ing
(
false
)
handleRespon
d
ing
(
false
)
const
newChatList
=
produce
(
chatListRef
.
current
,
(
draft
)
=>
{
const
newChatList
=
produce
(
chatListRef
.
current
,
(
draft
)
=>
{
draft
.
splice
(
draft
.
findIndex
(
item
=>
item
.
id
===
placeholderAnswerId
),
1
)
draft
.
splice
(
draft
.
findIndex
(
item
=>
item
.
id
===
placeholderAnswerId
),
1
)
})
})
...
@@ -432,7 +432,7 @@ export const useChat = (
...
@@ -432,7 +432,7 @@ export const useChat = (
notify
,
notify
,
promptVariablesConfig
,
promptVariablesConfig
,
handleUpdateChatList
,
handleUpdateChatList
,
handleRespon
s
ing
,
handleRespon
d
ing
,
])
])
const
handleAnnotationEdited
=
useCallback
((
query
:
string
,
answer
:
string
,
index
:
number
)
=>
{
const
handleAnnotationEdited
=
useCallback
((
query
:
string
,
answer
:
string
,
index
:
number
)
=>
{
...
@@ -506,8 +506,8 @@ export const useChat = (
...
@@ -506,8 +506,8 @@ export const useChat = (
chatList
,
chatList
,
setChatList
,
setChatList
,
conversationId
:
connversationId
.
current
,
conversationId
:
connversationId
.
current
,
isRespon
s
ing
,
isRespon
d
ing
,
setIsRespon
s
ing
,
setIsRespon
d
ing
,
handleSend
,
handleSend
,
suggestedQuestions
,
suggestedQuestions
,
handleRestart
,
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
...
@@ -28,7 +28,7 @@ import { StopCircle } from '@/app/components/base/icons/src/vender/solid/mediaAn
export
type
ChatProps
=
{
export
type
ChatProps
=
{
chatList
:
ChatItem
[]
chatList
:
ChatItem
[]
config
?:
ChatConfig
config
?:
ChatConfig
isRespon
s
ing
?:
boolean
isRespon
d
ing
?:
boolean
noStopResponding
?:
boolean
noStopResponding
?:
boolean
onStopResponding
?:
()
=>
void
onStopResponding
?:
()
=>
void
noChatInput
?:
boolean
noChatInput
?:
boolean
...
@@ -52,7 +52,7 @@ const Chat: FC<ChatProps> = ({
...
@@ -52,7 +52,7 @@ const Chat: FC<ChatProps> = ({
config
,
config
,
onSend
,
onSend
,
chatList
,
chatList
,
isRespon
s
ing
,
isRespon
d
ing
,
noStopResponding
,
noStopResponding
,
onStopResponding
,
onStopResponding
,
noChatInput
,
noChatInput
,
...
@@ -125,7 +125,7 @@ const Chat: FC<ChatProps> = ({
...
@@ -125,7 +125,7 @@ const Chat: FC<ChatProps> = ({
<
ChatContextProvider
<
ChatContextProvider
config=
{
config
}
config=
{
config
}
chatList=
{
chatList
}
chatList=
{
chatList
}
isRespon
sing=
{
isRespons
ing
}
isRespon
ding=
{
isRespond
ing
}
showPromptLog=
{
showPromptLog
}
showPromptLog=
{
showPromptLog
}
questionIcon=
{
questionIcon
}
questionIcon=
{
questionIcon
}
answerIcon=
{
answerIcon
}
answerIcon=
{
answerIcon
}
...
@@ -158,7 +158,7 @@ const Chat: FC<ChatProps> = ({
...
@@ -158,7 +158,7 @@ const Chat: FC<ChatProps> = ({
index=
{
index
}
index=
{
index
}
config=
{
config
}
config=
{
config
}
answerIcon=
{
answerIcon
}
answerIcon=
{
answerIcon
}
respon
sing=
{
isLast
&&
isRespons
ing
}
respon
ding=
{
isLast
&&
isRespond
ing
}
allToolIcons=
{
allToolIcons
}
allToolIcons=
{
allToolIcons
}
/>
/>
)
)
...
@@ -169,7 +169,7 @@ const Chat: FC<ChatProps> = ({
...
@@ -169,7 +169,7 @@ const Chat: FC<ChatProps> = ({
item=
{
item
}
item=
{
item
}
showPromptLog=
{
showPromptLog
}
showPromptLog=
{
showPromptLog
}
questionIcon=
{
questionIcon
}
questionIcon=
{
questionIcon
}
isRespon
sing=
{
isRespons
ing
}
isRespon
ding=
{
isRespond
ing
}
/>
/>
)
)
})
})
...
@@ -188,7 +188,7 @@ const Chat: FC<ChatProps> = ({
...
@@ -188,7 +188,7 @@ const Chat: FC<ChatProps> = ({
className=
{
`${chatFooterInnerClassName}`
}
className=
{
`${chatFooterInnerClassName}`
}
>
>
{
{
!
noStopResponding
&&
isRespon
s
ing
&&
(
!
noStopResponding
&&
isRespon
d
ing
&&
(
<
div
className=
'flex justify-center mb-2'
>
<
div
className=
'flex justify-center mb-2'
>
<
Button
className=
'py-0 px-3 h-7 bg-white shadow-xs'
onClick=
{
onStopResponding
}
>
<
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'
/>
<
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 = {
...
@@ -17,12 +17,12 @@ type QuestionProps = {
item
:
ChatItem
item
:
ChatItem
showPromptLog
?:
boolean
showPromptLog
?:
boolean
questionIcon
?:
ReactNode
questionIcon
?:
ReactNode
isRespon
s
ing
?:
boolean
isRespon
d
ing
?:
boolean
}
}
const
Question
:
FC
<
QuestionProps
>
=
({
const
Question
:
FC
<
QuestionProps
>
=
({
item
,
item
,
showPromptLog
,
showPromptLog
,
isRespon
s
ing
,
isRespon
d
ing
,
questionIcon
,
questionIcon
,
})
=>
{
})
=>
{
const
ref
=
useRef
(
null
)
const
ref
=
useRef
(
null
)
...
@@ -38,7 +38,7 @@ const Question: FC<QuestionProps> = ({
...
@@ -38,7 +38,7 @@ const Question: FC<QuestionProps> = ({
<
div
className=
'group relative mr-4'
>
<
div
className=
'group relative mr-4'
>
<
QuestionTriangle
className=
'absolute -right-2 top-0 w-2 h-3 text-[#D1E9FF]/50'
/>
<
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
}
/>
<
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'
...
@@ -6,7 +6,7 @@ import { ssePost } from '@/service/base'
export
const
useTextGeneration
=
()
=>
{
export
const
useTextGeneration
=
()
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
{
notify
}
=
useToastContext
()
const
{
notify
}
=
useToastContext
()
const
[
isRespon
sing
,
setIsRespons
ing
]
=
useState
(
false
)
const
[
isRespon
ding
,
setIsRespond
ing
]
=
useState
(
false
)
const
[
completion
,
setCompletion
]
=
useState
(
''
)
const
[
completion
,
setCompletion
]
=
useState
(
''
)
const
[
messageId
,
setMessageId
]
=
useState
<
string
|
null
>
(
null
)
const
[
messageId
,
setMessageId
]
=
useState
<
string
|
null
>
(
null
)
...
@@ -14,12 +14,12 @@ export const useTextGeneration = () => {
...
@@ -14,12 +14,12 @@ export const useTextGeneration = () => {
url
:
string
,
url
:
string
,
data
:
any
,
data
:
any
,
)
=>
{
)
=>
{
if
(
isRespon
s
ing
)
{
if
(
isRespon
d
ing
)
{
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
return
false
return
false
}
}
setIsRespon
s
ing
(
true
)
setIsRespon
d
ing
(
true
)
setCompletion
(
''
)
setCompletion
(
''
)
setMessageId
(
''
)
setMessageId
(
''
)
let
res
:
string
[]
=
[]
let
res
:
string
[]
=
[]
...
@@ -42,10 +42,10 @@ export const useTextGeneration = () => {
...
@@ -42,10 +42,10 @@ export const useTextGeneration = () => {
setCompletion
(
res
.
join
(
''
))
setCompletion
(
res
.
join
(
''
))
},
},
onCompleted
()
{
onCompleted
()
{
setIsRespon
s
ing
(
false
)
setIsRespon
d
ing
(
false
)
},
},
onError
()
{
onError
()
{
setIsRespon
s
ing
(
false
)
setIsRespon
d
ing
(
false
)
},
},
})
})
return
true
return
true
...
@@ -53,8 +53,8 @@ export const useTextGeneration = () => {
...
@@ -53,8 +53,8 @@ export const useTextGeneration = () => {
return
{
return
{
completion
,
completion
,
isRespon
s
ing
,
isRespon
d
ing
,
setIsRespon
s
ing
,
setIsRespon
d
ing
,
handleSend
,
handleSend
,
messageId
,
messageId
,
}
}
...
...
web/app/components/share/chat/index.tsx
View file @
70525653
...
@@ -190,7 +190,7 @@ const Main: FC<IMainProps> = ({
...
@@ -190,7 +190,7 @@ const Main: FC<IMainProps> = ({
const
[
citationConfig
,
setCitationConfig
]
=
useState
<
CitationConfig
|
null
>
(
null
)
const
[
citationConfig
,
setCitationConfig
]
=
useState
<
CitationConfig
|
null
>
(
null
)
const
[
chatList
,
setChatList
,
getChatList
]
=
useGetState
<
IChatItem
[]
>
([])
const
[
chatList
,
setChatList
,
getChatList
]
=
useGetState
<
IChatItem
[]
>
([])
const
chatListDomRef
=
useRef
<
HTMLDivElement
>
(
null
)
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
[
abortController
,
setAbortController
]
=
useState
<
AbortController
|
null
>
(
null
)
const
[
conversationIdChangeBecauseOfNew
,
setConversationIdChangeBecauseOfNew
,
getConversationIdChangeBecauseOfNew
]
=
useGetState
(
false
)
const
[
conversationIdChangeBecauseOfNew
,
setConversationIdChangeBecauseOfNew
,
getConversationIdChangeBecauseOfNew
]
=
useGetState
(
false
)
const
[
isChatStarted
,
{
setTrue
:
setChatStarted
,
setFalse
:
setChatNotStarted
}]
=
useBoolean
(
false
)
const
[
isChatStarted
,
{
setTrue
:
setChatStarted
,
setFalse
:
setChatNotStarted
}]
=
useBoolean
(
false
)
...
@@ -198,7 +198,7 @@ const Main: FC<IMainProps> = ({
...
@@ -198,7 +198,7 @@ const Main: FC<IMainProps> = ({
const
createNewChat
=
useCallback
(
async
()
=>
{
const
createNewChat
=
useCallback
(
async
()
=>
{
// if new chat is already exist, do not create new chat
// if new chat is already exist, do not create new chat
abortController
?.
abort
()
abortController
?.
abort
()
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
if
(
conversationList
.
some
(
item
=>
item
.
id
===
'-1'
))
if
(
conversationList
.
some
(
item
=>
item
.
id
===
'-1'
))
return
return
...
@@ -212,7 +212,7 @@ const Main: FC<IMainProps> = ({
...
@@ -212,7 +212,7 @@ const Main: FC<IMainProps> = ({
}))
}))
},
[
},
[
abortController
,
abortController
,
setRespon
s
ingFalse
,
setRespon
d
ingFalse
,
setConversationList
,
setConversationList
,
conversationList
,
conversationList
,
newConversationInputs
,
newConversationInputs
,
...
@@ -504,11 +504,11 @@ const Main: FC<IMainProps> = ({
...
@@ -504,11 +504,11 @@ const Main: FC<IMainProps> = ({
},
[
currConversationId
,
currInputs
,
promptConfig
,
t
,
logError
])
},
[
currConversationId
,
currInputs
,
promptConfig
,
t
,
logError
])
const
[
controlFocus
,
setControlFocus
]
=
useState
(
0
)
const
[
controlFocus
,
setControlFocus
]
=
useState
(
0
)
const
doShowSuggestion
=
isShowSuggestion
&&
!
isRespon
s
ing
const
doShowSuggestion
=
isShowSuggestion
&&
!
isRespon
d
ing
const
[
openingSuggestedQuestions
,
setOpeningSuggestedQuestions
]
=
useState
<
string
[]
>
([])
const
[
openingSuggestedQuestions
,
setOpeningSuggestedQuestions
]
=
useState
<
string
[]
>
([])
const
[
messageTaskId
,
setMessageTaskId
]
=
useState
(
''
)
const
[
messageTaskId
,
setMessageTaskId
]
=
useState
(
''
)
const
[
hasStopResponded
,
setHasStopResponded
,
getHasStopResponded
]
=
useGetState
(
false
)
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
[
userQuery
,
setUserQuery
]
=
useState
(
''
)
const
[
visionConfig
,
setVisionConfig
]
=
useState
<
VisionSettings
>
({
const
[
visionConfig
,
setVisionConfig
]
=
useState
<
VisionSettings
>
({
enabled
:
false
,
enabled
:
false
,
...
@@ -541,7 +541,7 @@ const Main: FC<IMainProps> = ({
...
@@ -541,7 +541,7 @@ const Main: FC<IMainProps> = ({
}
}
const
handleSend
=
async
(
message
:
string
,
files
?:
VisionFile
[])
=>
{
const
handleSend
=
async
(
message
:
string
,
files
?:
VisionFile
[])
=>
{
if
(
isRespon
s
ing
)
{
if
(
isRespon
d
ing
)
{
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
return
return
}
}
...
@@ -605,9 +605,9 @@ const Main: FC<IMainProps> = ({
...
@@ -605,9 +605,9 @@ const Main: FC<IMainProps> = ({
let
tempNewConversationId
=
prevTempNewConversationId
let
tempNewConversationId
=
prevTempNewConversationId
setHasStopResponded
(
false
)
setHasStopResponded
(
false
)
setRespon
s
ingTrue
()
setRespon
d
ingTrue
()
setIsShowSuggestion
(
false
)
setIsShowSuggestion
(
false
)
setIsRespon
s
ingConCurrCon
(
true
)
setIsRespon
d
ingConCurrCon
(
true
)
sendChatMessage
(
data
,
{
sendChatMessage
(
data
,
{
getAbortController
:
(
abortController
)
=>
{
getAbortController
:
(
abortController
)
=>
{
setAbortController
(
abortController
)
setAbortController
(
abortController
)
...
@@ -632,7 +632,7 @@ const Main: FC<IMainProps> = ({
...
@@ -632,7 +632,7 @@ const Main: FC<IMainProps> = ({
setMessageTaskId
(
taskId
)
setMessageTaskId
(
taskId
)
// has switched to other conversation
// has switched to other conversation
if
(
prevTempNewConversationId
!==
getCurrConversationId
())
{
if
(
prevTempNewConversationId
!==
getCurrConversationId
())
{
setIsRespon
s
ingConCurrCon
(
false
)
setIsRespon
d
ingConCurrCon
(
false
)
return
return
}
}
updateCurrentQA
({
updateCurrentQA
({
...
@@ -660,12 +660,12 @@ const Main: FC<IMainProps> = ({
...
@@ -660,12 +660,12 @@ const Main: FC<IMainProps> = ({
resetNewConversationInputs
()
resetNewConversationInputs
()
setChatNotStarted
()
setChatNotStarted
()
setCurrConversationId
(
tempNewConversationId
,
appId
,
true
)
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
)
const
{
data
}:
any
=
await
fetchSuggestedQuestions
(
responseItem
.
id
,
isInstalledApp
,
installedAppInfo
?.
id
)
setSuggestQuestions
(
data
)
setSuggestQuestions
(
data
)
setIsShowSuggestion
(
true
)
setIsShowSuggestion
(
true
)
}
}
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
},
},
onFile
(
file
)
{
onFile
(
file
)
{
const
lastThought
=
responseItem
.
agent_thoughts
?.[
responseItem
.
agent_thoughts
?.
length
-
1
]
const
lastThought
=
responseItem
.
agent_thoughts
?.[
responseItem
.
agent_thoughts
?.
length
-
1
]
...
@@ -704,7 +704,7 @@ const Main: FC<IMainProps> = ({
...
@@ -704,7 +704,7 @@ const Main: FC<IMainProps> = ({
}
}
// has switched to other conversation
// has switched to other conversation
if
(
prevTempNewConversationId
!==
getCurrConversationId
())
{
if
(
prevTempNewConversationId
!==
getCurrConversationId
())
{
setIsRespon
s
ingConCurrCon
(
false
)
setIsRespon
d
ingConCurrCon
(
false
)
return
false
return
false
}
}
...
@@ -766,7 +766,7 @@ const Main: FC<IMainProps> = ({
...
@@ -766,7 +766,7 @@ const Main: FC<IMainProps> = ({
}
}
},
},
onError
()
{
onError
()
{
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
// role back placeholder answer
// role back placeholder answer
setChatList
(
produce
(
getChatList
(),
(
draft
)
=>
{
setChatList
(
produce
(
getChatList
(),
(
draft
)
=>
{
draft
.
splice
(
draft
.
findIndex
(
item
=>
item
.
id
===
placeholderAnswerId
),
1
)
draft
.
splice
(
draft
.
findIndex
(
item
=>
item
.
id
===
placeholderAnswerId
),
1
)
...
@@ -832,10 +832,10 @@ const Main: FC<IMainProps> = ({
...
@@ -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
)
await
stopChatMessageResponding
(
appId
,
messageTaskId
,
isInstalledApp
,
installedAppInfo
?.
id
)
setHasStopResponded
(
true
)
setHasStopResponded
(
true
)
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
},
[
appId
,
messageTaskId
,
isInstalledApp
,
installedAppInfo
?.
id
])
},
[
appId
,
messageTaskId
,
isInstalledApp
,
installedAppInfo
?.
id
])
if
(
appUnavailable
)
if
(
appUnavailable
)
...
@@ -905,7 +905,7 @@ const Main: FC<IMainProps> = ({
...
@@ -905,7 +905,7 @@ const Main: FC<IMainProps> = ({
{
{
hasSetInputs
&&
(
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
}
>
<
div
className=
'h-full overflow-y-auto'
ref=
{
chatListDomRef
}
>
<
Chat
<
Chat
chatList=
{
chatList
}
chatList=
{
chatList
}
...
@@ -914,9 +914,9 @@ const Main: FC<IMainProps> = ({
...
@@ -914,9 +914,9 @@ const Main: FC<IMainProps> = ({
onSend=
{
handleSend
}
onSend=
{
handleSend
}
isHideFeedbackEdit
isHideFeedbackEdit
onFeedback=
{
handleFeedback
}
onFeedback=
{
handleFeedback
}
isRespon
sing=
{
isRespons
ing
}
isRespon
ding=
{
isRespond
ing
}
canStopRespon
sing=
{
!!
messageTaskId
&&
isRespons
ingConIsCurrCon
}
canStopRespon
ding=
{
!!
messageTaskId
&&
isRespond
ingConIsCurrCon
}
abortRespon
sing=
{
handleAbortRespons
ing
}
abortRespon
ding=
{
handleAbortRespond
ing
}
checkCanSend=
{
checkCanSend
}
checkCanSend=
{
checkCanSend
}
controlFocus=
{
controlFocus
}
controlFocus=
{
controlFocus
}
isShowSuggestion=
{
doShowSuggestion
}
isShowSuggestion=
{
doShowSuggestion
}
...
...
web/app/components/share/chatbot/index.tsx
View file @
70525653
...
@@ -203,7 +203,7 @@ const Main: FC<IMainProps> = ({
...
@@ -203,7 +203,7 @@ const Main: FC<IMainProps> = ({
}
}
// update chat list of current conversation
// 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
)
=>
{
fetchChatList
(
currConversationId
,
isInstalledApp
,
installedAppInfo
?.
id
).
then
((
res
:
any
)
=>
{
const
{
data
}
=
res
const
{
data
}
=
res
const
newChatList
:
IChatItem
[]
=
generateNewChatListWithOpenstatement
(
notSyncToStateIntroduction
,
notSyncToStateInputs
)
const
newChatList
:
IChatItem
[]
=
generateNewChatListWithOpenstatement
(
notSyncToStateIntroduction
,
notSyncToStateInputs
)
...
@@ -252,7 +252,7 @@ const Main: FC<IMainProps> = ({
...
@@ -252,7 +252,7 @@ const Main: FC<IMainProps> = ({
const
createNewChat
=
async
()
=>
{
const
createNewChat
=
async
()
=>
{
// if new chat is already exist, do not create new chat
// if new chat is already exist, do not create new chat
abortController
?.
abort
()
abortController
?.
abort
()
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
if
(
conversationList
.
some
(
item
=>
item
.
id
===
'-1'
))
if
(
conversationList
.
some
(
item
=>
item
.
id
===
'-1'
))
return
return
...
@@ -369,7 +369,7 @@ const Main: FC<IMainProps> = ({
...
@@ -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
[
abortController
,
setAbortController
]
=
useState
<
AbortController
|
null
>
(
null
)
const
{
notify
}
=
useContext
(
ToastContext
)
const
{
notify
}
=
useContext
(
ToastContext
)
const
logError
=
(
message
:
string
)
=>
{
const
logError
=
(
message
:
string
)
=>
{
...
@@ -407,11 +407,11 @@ const Main: FC<IMainProps> = ({
...
@@ -407,11 +407,11 @@ const Main: FC<IMainProps> = ({
const
[
controlFocus
,
setControlFocus
]
=
useState
(
0
)
const
[
controlFocus
,
setControlFocus
]
=
useState
(
0
)
const
[
isShowSuggestion
,
setIsShowSuggestion
]
=
useState
(
false
)
const
[
isShowSuggestion
,
setIsShowSuggestion
]
=
useState
(
false
)
const
doShowSuggestion
=
isShowSuggestion
&&
!
isRespon
s
ing
const
doShowSuggestion
=
isShowSuggestion
&&
!
isRespon
d
ing
const
[
suggestQuestions
,
setSuggestQuestions
]
=
useState
<
string
[]
>
([])
const
[
suggestQuestions
,
setSuggestQuestions
]
=
useState
<
string
[]
>
([])
const
[
messageTaskId
,
setMessageTaskId
]
=
useState
(
''
)
const
[
messageTaskId
,
setMessageTaskId
]
=
useState
(
''
)
const
[
hasStopResponded
,
setHasStopResponded
,
getHasStopResponded
]
=
useGetState
(
false
)
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
[
shouldReload
,
setShouldReload
]
=
useState
(
false
)
const
[
userQuery
,
setUserQuery
]
=
useState
(
''
)
const
[
userQuery
,
setUserQuery
]
=
useState
(
''
)
const
[
visionConfig
,
setVisionConfig
]
=
useState
<
VisionSettings
>
({
const
[
visionConfig
,
setVisionConfig
]
=
useState
<
VisionSettings
>
({
...
@@ -445,7 +445,7 @@ const Main: FC<IMainProps> = ({
...
@@ -445,7 +445,7 @@ const Main: FC<IMainProps> = ({
}
}
const
handleSend
=
async
(
message
:
string
,
files
?:
VisionFile
[])
=>
{
const
handleSend
=
async
(
message
:
string
,
files
?:
VisionFile
[])
=>
{
if
(
isRespon
s
ing
)
{
if
(
isRespon
d
ing
)
{
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
return
return
}
}
...
@@ -507,7 +507,7 @@ const Main: FC<IMainProps> = ({
...
@@ -507,7 +507,7 @@ const Main: FC<IMainProps> = ({
let
tempNewConversationId
=
prevTempNewConversationId
let
tempNewConversationId
=
prevTempNewConversationId
setHasStopResponded
(
false
)
setHasStopResponded
(
false
)
setRespon
s
ingTrue
()
setRespon
d
ingTrue
()
setIsShowSuggestion
(
false
)
setIsShowSuggestion
(
false
)
sendChatMessage
(
data
,
{
sendChatMessage
(
data
,
{
getAbortController
:
(
abortController
)
=>
{
getAbortController
:
(
abortController
)
=>
{
...
@@ -533,7 +533,7 @@ const Main: FC<IMainProps> = ({
...
@@ -533,7 +533,7 @@ const Main: FC<IMainProps> = ({
setMessageTaskId
(
taskId
)
setMessageTaskId
(
taskId
)
// has switched to other conversation
// has switched to other conversation
if
(
prevTempNewConversationId
!==
getCurrConversationId
())
{
if
(
prevTempNewConversationId
!==
getCurrConversationId
())
{
setIsRespon
s
ingConCurrCon
(
false
)
setIsRespon
d
ingConCurrCon
(
false
)
return
return
}
}
updateCurrentQA
({
updateCurrentQA
({
...
@@ -565,7 +565,7 @@ const Main: FC<IMainProps> = ({
...
@@ -565,7 +565,7 @@ const Main: FC<IMainProps> = ({
setSuggestQuestions
(
data
)
setSuggestQuestions
(
data
)
setIsShowSuggestion
(
true
)
setIsShowSuggestion
(
true
)
}
}
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
},
},
onFile
(
file
)
{
onFile
(
file
)
{
const
lastThought
=
responseItem
.
agent_thoughts
?.[
responseItem
.
agent_thoughts
?.
length
-
1
]
const
lastThought
=
responseItem
.
agent_thoughts
?.[
responseItem
.
agent_thoughts
?.
length
-
1
]
...
@@ -604,7 +604,7 @@ const Main: FC<IMainProps> = ({
...
@@ -604,7 +604,7 @@ const Main: FC<IMainProps> = ({
}
}
// has switched to other conversation
// has switched to other conversation
if
(
prevTempNewConversationId
!==
getCurrConversationId
())
{
if
(
prevTempNewConversationId
!==
getCurrConversationId
())
{
setIsRespon
s
ingConCurrCon
(
false
)
setIsRespon
d
ingConCurrCon
(
false
)
return
false
return
false
}
}
...
@@ -666,7 +666,7 @@ const Main: FC<IMainProps> = ({
...
@@ -666,7 +666,7 @@ const Main: FC<IMainProps> = ({
}
}
},
},
onError
()
{
onError
()
{
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
// role back placeholder answer
// role back placeholder answer
setChatList
(
produce
(
getChatList
(),
(
draft
)
=>
{
setChatList
(
produce
(
getChatList
(),
(
draft
)
=>
{
draft
.
splice
(
draft
.
findIndex
(
item
=>
item
.
id
===
placeholderAnswerId
),
1
)
draft
.
splice
(
draft
.
findIndex
(
item
=>
item
.
id
===
placeholderAnswerId
),
1
)
...
@@ -773,7 +773,7 @@ const Main: FC<IMainProps> = ({
...
@@ -773,7 +773,7 @@ const Main: FC<IMainProps> = ({
}
}
{
{
hasSetInputs
&&
(
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
}
>
<
div
className=
'h-full overflow-y-auto'
ref=
{
chatListDomRef
}
>
<
Chat
<
Chat
chatList=
{
chatList
}
chatList=
{
chatList
}
...
@@ -782,12 +782,12 @@ const Main: FC<IMainProps> = ({
...
@@ -782,12 +782,12 @@ const Main: FC<IMainProps> = ({
onSend=
{
handleSend
}
onSend=
{
handleSend
}
isHideFeedbackEdit
isHideFeedbackEdit
onFeedback=
{
handleFeedback
}
onFeedback=
{
handleFeedback
}
isRespon
sing=
{
isRespons
ing
}
isRespon
ding=
{
isRespond
ing
}
canStopRespon
sing=
{
!!
messageTaskId
&&
isRespons
ingConIsCurrCon
}
canStopRespon
ding=
{
!!
messageTaskId
&&
isRespond
ingConIsCurrCon
}
abortRespon
s
ing=
{
async
()
=>
{
abortRespon
d
ing=
{
async
()
=>
{
await
stopChatMessageResponding
(
appId
,
messageTaskId
,
isInstalledApp
,
installedAppInfo
?.
id
)
await
stopChatMessageResponding
(
appId
,
messageTaskId
,
isInstalledApp
,
installedAppInfo
?.
id
)
setHasStopResponded
(
true
)
setHasStopResponded
(
true
)
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
}
}
}
}
checkCanSend=
{
checkCanSend
}
checkCanSend=
{
checkCanSend
}
controlFocus=
{
controlFocus
}
controlFocus=
{
controlFocus
}
...
...
web/app/components/share/text-generation/result/index.tsx
View file @
70525653
...
@@ -60,10 +60,10 @@ const Result: FC<IResultProps> = ({
...
@@ -60,10 +60,10 @@ const Result: FC<IResultProps> = ({
visionConfig
,
visionConfig
,
completionFiles
,
completionFiles
,
})
=>
{
})
=>
{
const
[
isRespon
sing
,
{
setTrue
:
setResponsingTrue
,
setFalse
:
setRespons
ingFalse
}]
=
useBoolean
(
false
)
const
[
isRespon
ding
,
{
setTrue
:
setRespondingTrue
,
setFalse
:
setRespond
ingFalse
}]
=
useBoolean
(
false
)
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
controlStopResponding
)
if
(
controlStopResponding
)
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
},
[
controlStopResponding
])
},
[
controlStopResponding
])
const
[
completionRes
,
doSetCompletionRes
]
=
useState
(
''
)
const
[
completionRes
,
doSetCompletionRes
]
=
useState
(
''
)
...
@@ -130,7 +130,7 @@ const Result: FC<IResultProps> = ({
...
@@ -130,7 +130,7 @@ const Result: FC<IResultProps> = ({
}
}
const
handleSend
=
async
()
=>
{
const
handleSend
=
async
()
=>
{
if
(
isRespon
s
ing
)
{
if
(
isRespon
d
ing
)
{
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
return
false
return
false
}
}
...
@@ -165,13 +165,13 @@ const Result: FC<IResultProps> = ({
...
@@ -165,13 +165,13 @@ const Result: FC<IResultProps> = ({
if
(
!
isPC
)
if
(
!
isPC
)
onShowRes
()
onShowRes
()
setRespon
s
ingTrue
()
setRespon
d
ingTrue
()
const
startTime
=
Date
.
now
()
const
startTime
=
Date
.
now
()
let
isTimeout
=
false
let
isTimeout
=
false
const
runId
=
setInterval
(()
=>
{
const
runId
=
setInterval
(()
=>
{
if
(
Date
.
now
()
-
startTime
>
1000
*
60
)
{
// 1min timeout
if
(
Date
.
now
()
-
startTime
>
1000
*
60
)
{
// 1min timeout
clearInterval
(
runId
)
clearInterval
(
runId
)
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
onCompleted
(
getCompletionRes
(),
taskId
,
false
)
onCompleted
(
getCompletionRes
(),
taskId
,
false
)
isTimeout
=
true
isTimeout
=
true
}
}
...
@@ -186,7 +186,7 @@ const Result: FC<IResultProps> = ({
...
@@ -186,7 +186,7 @@ const Result: FC<IResultProps> = ({
if
(
isTimeout
)
if
(
isTimeout
)
return
return
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
setMessageId
(
tempMessageId
)
setMessageId
(
tempMessageId
)
onCompleted
(
getCompletionRes
(),
taskId
,
true
)
onCompleted
(
getCompletionRes
(),
taskId
,
true
)
clearInterval
(
runId
)
clearInterval
(
runId
)
...
@@ -199,7 +199,7 @@ const Result: FC<IResultProps> = ({
...
@@ -199,7 +199,7 @@ const Result: FC<IResultProps> = ({
if
(
isTimeout
)
if
(
isTimeout
)
return
return
setRespon
s
ingFalse
()
setRespon
d
ingFalse
()
onCompleted
(
getCompletionRes
(),
taskId
,
false
)
onCompleted
(
getCompletionRes
(),
taskId
,
false
)
clearInterval
(
runId
)
clearInterval
(
runId
)
},
},
...
@@ -234,7 +234,7 @@ const Result: FC<IResultProps> = ({
...
@@ -234,7 +234,7 @@ const Result: FC<IResultProps> = ({
isMobile=
{
isMobile
}
isMobile=
{
isMobile
}
isInstalledApp=
{
isInstalledApp
}
isInstalledApp=
{
isInstalledApp
}
installedAppId=
{
installedAppInfo
?.
id
}
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
}
taskId=
{
isCallBatchAPI
?
((
taskId
as
number
)
<
10
?
`0${taskId}`
:
`${taskId}`
)
:
undefined
}
controlClearMoreLikeThis=
{
controlClearMoreLikeThis
}
controlClearMoreLikeThis=
{
controlClearMoreLikeThis
}
isShowTextToSpeech=
{
isShowTextToSpeech
}
isShowTextToSpeech=
{
isShowTextToSpeech
}
...
@@ -244,7 +244,7 @@ const Result: FC<IResultProps> = ({
...
@@ -244,7 +244,7 @@ const Result: FC<IResultProps> = ({
return
(
return
(
<
div
className=
{
cn
(
isNoData
&&
!
isCallBatchAPI
&&
'h-full'
)
}
>
<
div
className=
{
cn
(
isNoData
&&
!
isCallBatchAPI
&&
'h-full'
)
}
>
{
!
isCallBatchAPI
&&
(
{
!
isCallBatchAPI
&&
(
(
isRespon
s
ing
&&
!
completionRes
)
(
isRespon
d
ing
&&
!
completionRes
)
?
(
?
(
<
div
className=
'flex h-full w-full justify-center items-center'
>
<
div
className=
'flex h-full w-full justify-center items-center'
>
<
Loading
type=
'area'
/>
<
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