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
1ebf7409
Unverified
Commit
1ebf7409
authored
Feb 04, 2024
by
zxhlyh
Committed by
GitHub
Feb 04, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: webapp stop chat & citation (#2376)
parent
51d35926
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
21 additions
and
23 deletions
+21
-23
popup.tsx
web/app/components/app/chat/citation/popup.tsx
+13
-11
index.tsx
...app/configuration/debug/debug-with-single-model/index.tsx
+1
-5
hooks.tsx
web/app/components/app/configuration/debug/hooks.tsx
+1
-0
chat-wrapper.tsx
...p/components/base/chat/chat-with-history/chat-wrapper.tsx
+2
-0
index.tsx
web/app/components/base/chat/chat/answer/index.tsx
+1
-1
hooks.ts
web/app/components/base/chat/chat/hooks.ts
+2
-6
types.ts
web/app/components/base/chat/types.ts
+1
-0
No files found.
web/app/components/app/chat/citation/popup.tsx
View file @
1ebf7409
...
@@ -32,7 +32,7 @@ const Popup: FC<PopupProps> = ({
...
@@ -32,7 +32,7 @@ const Popup: FC<PopupProps> = ({
})
=>
{
})
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
[
open
,
setOpen
]
=
useState
(
false
)
const
[
open
,
setOpen
]
=
useState
(
false
)
const
fileType
=
data
.
dataSourceType
===
'upload_file
'
const
fileType
=
data
.
dataSourceType
!==
'notion
'
?
(
/
\.([^
.
]
*
)
$/g
.
exec
(
data
.
documentName
)?.[
1
]
||
''
)
?
(
/
\.([^
.
]
*
)
$/g
.
exec
(
data
.
documentName
)?.[
1
]
||
''
)
:
'notion'
:
'notion'
...
@@ -65,22 +65,24 @@ const Popup: FC<PopupProps> = ({
...
@@ -65,22 +65,24 @@ const Popup: FC<PopupProps> = ({
data
.
sources
.
map
((
source
,
index
)
=>
(
data
.
sources
.
map
((
source
,
index
)
=>
(
<
Fragment
key=
{
index
}
>
<
Fragment
key=
{
index
}
>
<
div
className=
'group py-3'
>
<
div
className=
'group py-3'
>
{
<
div
className=
'flex items-center justify-between mb-2'
>
showHitInfo
&&
(
<
div
className=
'flex items-center px-1.5 h-5 border border-gray-200 rounded-md'
>
<
div
className=
'flex items-center justify-between mb-2'
>
<
Hash02
className=
'mr-0.5 w-3 h-3 text-gray-400'
/>
<
div
className=
'flex items-center px-1.5 h-5 border border-gray-200 rounded-md'
>
<
div
className=
'text-[11px] font-medium text-gray-500'
>
<
Hash02
className=
'mr-0.5 w-3 h-3 text-gray-400'
/>
{
source
.
segment_position
||
index
+
1
}
<
div
className=
'text-[11px] font-medium text-gray-500'
>
{
source
.
segment_position
}
</
div
>
</
div
>
</
div
>
</
div
>
{
showHitInfo
&&
(
<
Link
<
Link
href=
{
`/datasets/${source.dataset_id}/documents/${source.document_id}`
}
href=
{
`/datasets/${source.dataset_id}/documents/${source.document_id}`
}
className=
'hidden items-center h-[18px] text-xs text-primary-600 group-hover:flex'
>
className=
'hidden items-center h-[18px] text-xs text-primary-600 group-hover:flex'
>
{
t
(
'common.chat.citation.linkToDataset'
)
}
{
t
(
'common.chat.citation.linkToDataset'
)
}
<
ArrowUpRight
className=
'ml-1 w-3 h-3'
/>
<
ArrowUpRight
className=
'ml-1 w-3 h-3'
/>
</
Link
>
</
Link
>
</
div
>
)
)
}
}
</
div
>
<
div
className=
'text-[13px] text-gray-800'
>
{
source
.
content
}
</
div
>
<
div
className=
'text-[13px] text-gray-800'
>
{
source
.
content
}
</
div
>
{
{
showHitInfo
&&
(
showHitInfo
&&
(
...
...
web/app/components/app/configuration/debug/debug-with-single-model/index.tsx
View file @
1ebf7409
...
@@ -54,11 +54,7 @@ const DebugWithSingleModel = forwardRef<DebugWithSingleModelRefType, DebugWithSi
...
@@ -54,11 +54,7 @@ const DebugWithSingleModel = forwardRef<DebugWithSingleModelRefType, DebugWithSi
handleAnnotationEdited
,
handleAnnotationEdited
,
handleAnnotationRemoved
,
handleAnnotationRemoved
,
}
=
useChat
(
}
=
useChat
(
{
config
,
...
config
,
supportAnnotation
:
true
,
appId
,
},
{
{
inputs
,
inputs
,
promptVariables
:
modelConfig
.
configs
.
prompt_variables
,
promptVariables
:
modelConfig
.
configs
.
prompt_variables
,
...
...
web/app/components/app/configuration/debug/hooks.tsx
View file @
1ebf7409
...
@@ -126,6 +126,7 @@ export const useConfigFromDebugContext = () => {
...
@@ -126,6 +126,7 @@ export const useConfigFromDebugContext = () => {
supportAnnotation
:
true
,
supportAnnotation
:
true
,
appId
,
appId
,
supportCitationHitInfo
:
true
,
}
}
return
config
return
config
...
...
web/app/components/base/chat/chat-with-history/chat-wrapper.tsx
View file @
1ebf7409
...
@@ -11,6 +11,7 @@ import ConfigPanel from './config-panel'
...
@@ -11,6 +11,7 @@ import ConfigPanel from './config-panel'
import
{
import
{
fetchSuggestedQuestions
,
fetchSuggestedQuestions
,
getUrl
,
getUrl
,
stopChatMessageResponding
,
}
from
'@/service/share'
}
from
'@/service/share'
const
ChatWrapper
=
()
=>
{
const
ChatWrapper
=
()
=>
{
...
@@ -47,6 +48,7 @@ const ChatWrapper = () => {
...
@@ -47,6 +48,7 @@ const ChatWrapper = () => {
appConfig
,
appConfig
,
undefined
,
undefined
,
appPrevChatList
,
appPrevChatList
,
taskId
=>
stopChatMessageResponding
(
''
,
taskId
,
isInstalledApp
,
appId
),
)
)
useEffect
(()
=>
{
useEffect
(()
=>
{
...
...
web/app/components/base/chat/chat/answer/index.tsx
View file @
1ebf7409
...
@@ -97,7 +97,7 @@ const Answer: FC<AnswerProps> = ({
...
@@ -97,7 +97,7 @@ const Answer: FC<AnswerProps> = ({
<
SuggestedQuestions
item=
{
item
}
/>
<
SuggestedQuestions
item=
{
item
}
/>
{
{
!!
citation
?.
length
&&
config
?.
retriever_resource
?.
enabled
&&
!
responsing
&&
(
!!
citation
?.
length
&&
config
?.
retriever_resource
?.
enabled
&&
!
responsing
&&
(
<
Citation
data=
{
citation
}
showHitInfo
/>
<
Citation
data=
{
citation
}
showHitInfo
=
{
config
.
supportCitationHitInfo
}
/>
)
)
}
}
</
div
>
</
div
>
...
...
web/app/components/base/chat/chat/hooks.ts
View file @
1ebf7409
...
@@ -87,7 +87,6 @@ export const useChat = (
...
@@ -87,7 +87,6 @@ export const useChat = (
const
chatListRef
=
useRef
<
ChatItem
[]
>
(
prevChatList
||
[])
const
chatListRef
=
useRef
<
ChatItem
[]
>
(
prevChatList
||
[])
const
taskIdRef
=
useRef
(
''
)
const
taskIdRef
=
useRef
(
''
)
const
[
suggestedQuestions
,
setSuggestQuestions
]
=
useState
<
string
[]
>
([])
const
[
suggestedQuestions
,
setSuggestQuestions
]
=
useState
<
string
[]
>
([])
const
abortControllerRef
=
useRef
<
AbortController
|
null
>
(
null
)
const
conversationMessagesAbortControllerRef
=
useRef
<
AbortController
|
null
>
(
null
)
const
conversationMessagesAbortControllerRef
=
useRef
<
AbortController
|
null
>
(
null
)
const
suggestedQuestionsAbortControllerRef
=
useRef
<
AbortController
|
null
>
(
null
)
const
suggestedQuestionsAbortControllerRef
=
useRef
<
AbortController
|
null
>
(
null
)
const
checkPromptVariables
=
useCheckPromptVariables
()
const
checkPromptVariables
=
useCheckPromptVariables
()
...
@@ -131,8 +130,6 @@ export const useChat = (
...
@@ -131,8 +130,6 @@ export const useChat = (
handleResponsing
(
false
)
handleResponsing
(
false
)
if
(
stopChat
&&
taskIdRef
.
current
)
if
(
stopChat
&&
taskIdRef
.
current
)
stopChat
(
taskIdRef
.
current
)
stopChat
(
taskIdRef
.
current
)
if
(
abortControllerRef
.
current
)
abortControllerRef
.
current
.
abort
()
if
(
conversationMessagesAbortControllerRef
.
current
)
if
(
conversationMessagesAbortControllerRef
.
current
)
conversationMessagesAbortControllerRef
.
current
.
abort
()
conversationMessagesAbortControllerRef
.
current
.
abort
()
if
(
suggestedQuestionsAbortControllerRef
.
current
)
if
(
suggestedQuestionsAbortControllerRef
.
current
)
...
@@ -192,6 +189,8 @@ export const useChat = (
...
@@ -192,6 +189,8 @@ export const useChat = (
}:
SendCallback
,
}:
SendCallback
,
)
=>
{
)
=>
{
setSuggestQuestions
([])
setSuggestQuestions
([])
if
(
!
data
.
query
||
!
data
.
query
.
trim
())
return
if
(
isResponsingRef
.
current
)
{
if
(
isResponsingRef
.
current
)
{
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
return
false
return
false
...
@@ -257,9 +256,6 @@ export const useChat = (
...
@@ -257,9 +256,6 @@ export const useChat = (
},
},
{
{
isPublicAPI
,
isPublicAPI
,
getAbortController
:
(
abortController
)
=>
{
abortControllerRef
.
current
=
abortController
},
onData
:
(
message
:
string
,
isFirstMessage
:
boolean
,
{
conversationId
:
newConversationId
,
messageId
,
taskId
}:
any
)
=>
{
onData
:
(
message
:
string
,
isFirstMessage
:
boolean
,
{
conversationId
:
newConversationId
,
messageId
,
taskId
}:
any
)
=>
{
if
(
!
isAgentMode
)
{
if
(
!
isAgentMode
)
{
responseItem
.
content
=
responseItem
.
content
+
message
responseItem
.
content
=
responseItem
.
content
+
message
...
...
web/app/components/base/chat/types.ts
View file @
1ebf7409
...
@@ -45,6 +45,7 @@ export type ChatConfig = Omit<ModelConfig, 'model'> & {
...
@@ -45,6 +45,7 @@ export type ChatConfig = Omit<ModelConfig, 'model'> & {
supportAnnotation
?:
boolean
supportAnnotation
?:
boolean
appId
?:
string
appId
?:
string
supportFeedback
?:
boolean
supportFeedback
?:
boolean
supportCitationHitInfo
?:
boolean
}
}
export
type
ChatItem
=
IChatItem
export
type
ChatItem
=
IChatItem
...
...
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