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
0850c953
Unverified
Commit
0850c953
authored
Feb 12, 2024
by
zxhlyh
Committed by
GitHub
Feb 12, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: variable in opener (#2437)
parent
23e95fd7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
15 deletions
+29
-15
chat-wrapper.tsx
...p/components/base/chat/chat-with-history/chat-wrapper.tsx
+6
-2
hooks.ts
web/app/components/base/chat/chat/hooks.ts
+23
-13
No files found.
web/app/components/base/chat/chat-with-history/chat-wrapper.tsx
View file @
0850c953
...
@@ -36,8 +36,9 @@ const ChatWrapper = () => {
...
@@ -36,8 +36,9 @@ const ChatWrapper = () => {
return
{
return
{
...
config
,
...
config
,
supportFeedback
:
true
,
supportFeedback
:
true
,
opening_statement
:
currentConversationId
?
currentConversationItem
?.
introduction
:
(
config
as
any
).
opening_statement
,
}
as
ChatConfig
}
as
ChatConfig
},
[
appParams
])
},
[
appParams
,
currentConversationItem
?.
introduction
,
currentConversationId
])
const
{
const
{
chatList
,
chatList
,
handleSend
,
handleSend
,
...
@@ -46,7 +47,10 @@ const ChatWrapper = () => {
...
@@ -46,7 +47,10 @@ const ChatWrapper = () => {
suggestedQuestions
,
suggestedQuestions
,
}
=
useChat
(
}
=
useChat
(
appConfig
,
appConfig
,
undefined
,
{
inputs
:
(
currentConversationId
?
currentConversationItem
?.
inputs
:
newConversationInputs
)
as
any
,
promptVariables
:
inputsForms
,
},
appPrevChatList
,
appPrevChatList
,
taskId
=>
stopChatMessageResponding
(
''
,
taskId
,
isInstalledApp
,
appId
),
taskId
=>
stopChatMessageResponding
(
''
,
taskId
,
isInstalledApp
,
appId
),
)
)
...
...
web/app/components/base/chat/chat/hooks.ts
View file @
0850c953
...
@@ -100,7 +100,7 @@ export const useChat = (
...
@@ -100,7 +100,7 @@ export const useChat = (
const
handleUpdateChatList
=
useCallback
((
newChatList
:
ChatItem
[])
=>
{
const
handleUpdateChatList
=
useCallback
((
newChatList
:
ChatItem
[])
=>
{
setChatList
(
newChatList
)
setChatList
(
newChatList
)
chatListRef
.
current
=
newChatList
chatListRef
.
current
=
newChatList
},
[
setChatList
])
},
[])
const
handleResponsing
=
useCallback
((
isResponsing
:
boolean
)
=>
{
const
handleResponsing
=
useCallback
((
isResponsing
:
boolean
)
=>
{
setIsResponsing
(
isResponsing
)
setIsResponsing
(
isResponsing
)
isResponsingRef
.
current
=
isResponsing
isResponsingRef
.
current
=
isResponsing
...
@@ -110,19 +110,29 @@ export const useChat = (
...
@@ -110,19 +110,29 @@ export const useChat = (
return
replaceStringWithValues
(
str
,
promptVariablesConfig
?.
promptVariables
||
[],
promptVariablesConfig
?.
inputs
||
{})
return
replaceStringWithValues
(
str
,
promptVariablesConfig
?.
promptVariables
||
[],
promptVariablesConfig
?.
inputs
||
{})
},
[
promptVariablesConfig
?.
inputs
,
promptVariablesConfig
?.
promptVariables
])
},
[
promptVariablesConfig
?.
inputs
,
promptVariablesConfig
?.
promptVariables
])
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
config
?.
opening_statement
&&
chatListRef
.
current
.
filter
(
item
=>
item
.
isOpeningStatement
).
length
===
0
)
{
if
(
config
?.
opening_statement
)
{
handleUpdateChatList
([
handleUpdateChatList
(
produce
(
chatListRef
.
current
,
(
draft
)
=>
{
{
const
index
=
draft
.
findIndex
(
item
=>
item
.
isOpeningStatement
)
id
:
`
${
Date
.
now
()}
`
,
content
:
getIntroduction
(
config
.
opening_statement
),
if
(
index
>
-
1
)
{
isAnswer
:
true
,
draft
[
index
]
=
{
isOpeningStatement
:
true
,
...
draft
[
index
],
suggestedQuestions
:
config
.
suggested_questions
,
content
:
getIntroduction
(
config
.
opening_statement
),
},
suggestedQuestions
:
config
.
suggested_questions
,
...
chatListRef
.
current
,
}
])
}
else
{
draft
.
unshift
({
id
:
`
${
Date
.
now
()}
`
,
content
:
getIntroduction
(
config
.
opening_statement
),
isAnswer
:
true
,
isOpeningStatement
:
true
,
suggestedQuestions
:
config
.
suggested_questions
,
})
}
}))
}
}
},
[])
},
[
config
?.
opening_statement
,
getIntroduction
,
config
?.
suggested_questions
,
handleUpdateChatList
])
const
handleStop
=
useCallback
(()
=>
{
const
handleStop
=
useCallback
(()
=>
{
hasStopResponded
.
current
=
true
hasStopResponded
.
current
=
true
...
...
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