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
eae670ea
Unverified
Commit
eae670ea
authored
Jul 27, 2023
by
Joel
Committed by
GitHub
Jul 27, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: enchance chat user experience (#660)
parent
b5825142
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
8 deletions
+43
-8
index.tsx
web/app/components/app/chat/thought/index.tsx
+6
-2
index.tsx
web/app/components/explore/universal-chat/index.tsx
+33
-4
explore.en.ts
web/i18n/lang/explore.en.ts
+2
-1
explore.zh.ts
web/i18n/lang/explore.zh.ts
+2
-1
No files found.
web/app/components/app/chat/thought/index.tsx
View file @
eae670ea
...
@@ -45,8 +45,12 @@ const Thought: FC<IThoughtProps> = ({
...
@@ -45,8 +45,12 @@ const Thought: FC<IThoughtProps> = ({
return
t
(
'explore.universalChat.thought.res.dataset'
).
replace
(
'{datasetName}'
,
`<span class="text-gray-700">
${
datasetName
}
</span>`
)
return
t
(
'explore.universalChat.thought.res.dataset'
).
replace
(
'{datasetName}'
,
`<span class="text-gray-700">
${
datasetName
}
</span>`
)
case
'web_reader'
:
case
'web_reader'
:
return
t
(
`explore.universalChat.thought.res.webReader.
${
!
input
.
cursor
?
'normal'
:
'hasPageInfo'
}
`
).
replace
(
'{url}'
,
`<a href="
${
input
.
url
}
" class="text-[#155EEF]">
${
input
.
url
}
</a>`
)
return
t
(
`explore.universalChat.thought.res.webReader.
${
!
input
.
cursor
?
'normal'
:
'hasPageInfo'
}
`
).
replace
(
'{url}'
,
`<a href="
${
input
.
url
}
" class="text-[#155EEF]">
${
input
.
url
}
</a>`
)
default
:
// google, wikipedia
case
'google_search'
:
return
t
(
'explore.universalChat.thought.res.search'
,
{
query
:
input
.
query
})
return
t
(
'explore.universalChat.thought.res.google'
,
{
query
:
input
.
query
})
case
'wikipedia'
:
return
t
(
'explore.universalChat.thought.res.wikipedia'
,
{
query
:
input
.
query
})
default
:
return
`Unknown tool:
${
item
.
tool
}
`
}
}
}
}
catch
(
error
)
{
catch
(
error
)
{
...
...
web/app/components/explore/universal-chat/index.tsx
View file @
eae670ea
...
@@ -47,6 +47,28 @@ const DEFAULT_PLUGIN = {
...
@@ -47,6 +47,28 @@ const DEFAULT_PLUGIN = {
web_reader
:
true
,
web_reader
:
true
,
wikipedia
:
true
,
wikipedia
:
true
,
}
}
const
CONFIG_KEY
=
'universal-chat-config'
type
CONFIG
=
{
modelId
:
string
plugin
:
{
google_search
:
boolean
web_reader
:
boolean
wikipedia
:
boolean
}
}
let
prevConfig
:
null
|
CONFIG
=
localStorage
.
getItem
(
CONFIG_KEY
)
?
JSON
.
parse
(
localStorage
.
getItem
(
CONFIG_KEY
)
as
string
)
as
CONFIG
:
null
const
setPrevConfig
=
(
config
:
CONFIG
)
=>
{
prevConfig
=
config
localStorage
.
setItem
(
CONFIG_KEY
,
JSON
.
stringify
(
prevConfig
))
}
const
getInitConfig
=
(
type
:
'model'
|
'plugin'
)
=>
{
if
(
type
===
'model'
)
return
prevConfig
?.
modelId
||
DEFAULT_MODEL_ID
if
(
type
===
'plugin'
)
return
prevConfig
?.
plugin
||
DEFAULT_PLUGIN
}
export
type
IMainProps
=
{}
export
type
IMainProps
=
{}
const
Main
:
FC
<
IMainProps
>
=
()
=>
{
const
Main
:
FC
<
IMainProps
>
=
()
=>
{
...
@@ -415,6 +437,13 @@ const Main: FC<IMainProps> = () => {
...
@@ -415,6 +437,13 @@ const Main: FC<IMainProps> = () => {
const
[
errorHappened
,
setErrorHappened
]
=
useState
(
false
)
const
[
errorHappened
,
setErrorHappened
]
=
useState
(
false
)
const
[
isResponsingConIsCurrCon
,
setIsResponsingConCurrCon
,
getIsResponsingConIsCurrCon
]
=
useGetState
(
true
)
const
[
isResponsingConIsCurrCon
,
setIsResponsingConCurrCon
,
getIsResponsingConIsCurrCon
]
=
useGetState
(
true
)
const
handleSend
=
async
(
message
:
string
)
=>
{
const
handleSend
=
async
(
message
:
string
)
=>
{
if
(
isNewConversation
)
{
setPrevConfig
({
modelId
,
plugin
:
plugins
as
any
,
})
}
if
(
isResponsing
)
{
if
(
isResponsing
)
{
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
notify
({
type
:
'info'
,
message
:
t
(
'appDebug.errorMessage.waitForResponse'
)
})
return
return
...
@@ -598,10 +627,10 @@ const Main: FC<IMainProps> = () => {
...
@@ -598,10 +627,10 @@ const Main: FC<IMainProps> = () => {
)
)
}
}
const
[
modelId
,
setModeId
]
=
useState
(
DEFAULT_MODEL_ID
)
const
[
modelId
,
setModeId
]
=
useState
<
string
>
(
getInitConfig
(
'model'
)
as
string
)
// const currModel = MODEL_LIST.find(item => item.id === modelId)
// const currModel = MODEL_LIST.find(item => item.id === modelId)
const
[
plugins
,
setPlugins
]
=
useState
<
Record
<
string
,
boolean
>>
(
DEFAULT_PLUGIN
)
const
[
plugins
,
setPlugins
]
=
useState
<
Record
<
string
,
boolean
>>
(
getInitConfig
(
'plugin'
)
as
Record
<
string
,
boolean
>
)
const
handlePluginsChange
=
(
key
:
string
,
value
:
boolean
)
=>
{
const
handlePluginsChange
=
(
key
:
string
,
value
:
boolean
)
=>
{
setPlugins
({
setPlugins
({
...
plugins
,
...
plugins
,
...
@@ -610,8 +639,8 @@ const Main: FC<IMainProps> = () => {
...
@@ -610,8 +639,8 @@ const Main: FC<IMainProps> = () => {
}
}
const
[
dataSets
,
setDateSets
]
=
useState
<
DataSet
[]
>
([])
const
[
dataSets
,
setDateSets
]
=
useState
<
DataSet
[]
>
([])
const
configSetDefaultValue
=
()
=>
{
const
configSetDefaultValue
=
()
=>
{
setModeId
(
DEFAULT_MODEL_ID
)
setModeId
(
getInitConfig
(
'model'
)
as
string
)
setPlugins
(
DEFAULT_PLUGIN
)
setPlugins
(
getInitConfig
(
'plugin'
)
as
any
)
setDateSets
([])
setDateSets
([])
}
}
const
isCurrConversationPinned
=
!!
pinnedConversationList
.
find
(
item
=>
item
.
id
===
currConversationId
)
const
isCurrConversationPinned
=
!!
pinnedConversationList
.
find
(
item
=>
item
.
id
===
currConversationId
)
...
...
web/i18n/lang/explore.en.ts
View file @
eae670ea
...
@@ -66,7 +66,8 @@ const translation = {
...
@@ -66,7 +66,8 @@ const translation = {
normal
:
'Reading {url}'
,
normal
:
'Reading {url}'
,
hasPageInfo
:
'Reading next page of {url}'
,
hasPageInfo
:
'Reading next page of {url}'
,
},
},
search
:
'Searching {{query}}'
,
google
:
'Searching Google {{query}}'
,
wikipedia
:
'Searching Wikipedia {{query}}'
,
dataset
:
'Retrieving dataset {datasetName}'
,
dataset
:
'Retrieving dataset {datasetName}'
,
},
},
},
},
...
...
web/i18n/lang/explore.zh.ts
View file @
eae670ea
...
@@ -66,7 +66,8 @@ const translation = {
...
@@ -66,7 +66,8 @@ const translation = {
normal
:
'解析链接 {url}'
,
normal
:
'解析链接 {url}'
,
hasPageInfo
:
'解析链接 {url} 的下一页'
,
hasPageInfo
:
'解析链接 {url} 的下一页'
,
},
},
search
:
'搜索 {{query}}'
,
google
:
'搜索谷歌 {{query}}'
,
wikipedia
:
'搜索维基百科 {{query}}'
,
dataset
:
'检索数据集 {datasetName}'
,
dataset
:
'检索数据集 {datasetName}'
,
},
},
},
},
...
...
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