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
b2c28b0b
Commit
b2c28b0b
authored
Jul 21, 2023
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: show check serapi
parent
75dc73e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
37 deletions
+49
-37
index.tsx
...ts/explore/universal-chat/config/plugins-config/index.tsx
+49
-37
No files found.
web/app/components/explore/universal-chat/config/plugins-config/index.tsx
View file @
b2c28b0b
...
@@ -7,6 +7,7 @@ import FeaturePanel from '@/app/components/app/configuration/base/feature-panel'
...
@@ -7,6 +7,7 @@ import FeaturePanel from '@/app/components/app/configuration/base/feature-panel'
import
{
Google
,
WebReader
,
Wikipedia
}
from
'@/app/components/base/icons/src/public/plugins'
import
{
Google
,
WebReader
,
Wikipedia
}
from
'@/app/components/base/icons/src/public/plugins'
import
{
getToolProviders
}
from
'@/service/explore'
import
{
getToolProviders
}
from
'@/service/explore'
import
Loading
from
'@/app/components/base/loading'
import
Loading
from
'@/app/components/base/loading'
import
AccountSetting
from
'@/app/components/header/account-setting'
export
type
IPluginsProps
=
{
export
type
IPluginsProps
=
{
readonly
?:
boolean
readonly
?:
boolean
...
@@ -26,17 +27,19 @@ const Plugins: FC<IPluginsProps> = ({
...
@@ -26,17 +27,19 @@ const Plugins: FC<IPluginsProps> = ({
})
=>
{
})
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
[
isLoading
,
setIsLoading
]
=
React
.
useState
(
true
)
const
[
isLoading
,
setIsLoading
]
=
React
.
useState
(
true
)
const
[
isSerp
apiValid
,
setIsSerpa
piValid
]
=
React
.
useState
(
false
)
const
[
isSerp
ApiValid
,
setIsSerpA
piValid
]
=
React
.
useState
(
false
)
const
init
=
async
()
=>
{
const
checkSerpApiKey
=
async
()
=>
{
const
provides
:
any
=
await
getToolProviders
()
const
provides
:
any
=
await
getToolProviders
()
const
isSer
a
piValid
=
!!
provides
.
find
((
v
:
any
)
=>
v
.
tool_name
===
'serpapi'
&&
v
.
is_enabled
)
const
isSer
pA
piValid
=
!!
provides
.
find
((
v
:
any
)
=>
v
.
tool_name
===
'serpapi'
&&
v
.
is_enabled
)
setIsSerp
apiValid
(
isSera
piValid
)
setIsSerp
ApiValid
(
isSerpA
piValid
)
setIsLoading
(
false
)
setIsLoading
(
false
)
}
}
useEffect
(()
=>
{
useEffect
(()
=>
{
init
()
checkSerpApiKey
()
},
[])
},
[])
const
[
showSetSerpAPIKeyModal
,
setShowSetAPIKeyModal
]
=
React
.
useState
(
false
)
const
itemConfigs
=
plugins
.
map
((
plugin
)
=>
{
const
itemConfigs
=
plugins
.
map
((
plugin
)
=>
{
const
res
:
Record
<
string
,
any
>
=
{
...
plugin
}
const
res
:
Record
<
string
,
any
>
=
{
...
plugin
}
const
{
key
}
=
plugin
const
{
key
}
=
plugin
...
@@ -44,12 +47,12 @@ const Plugins: FC<IPluginsProps> = ({
...
@@ -44,12 +47,12 @@ const Plugins: FC<IPluginsProps> = ({
if
(
key
===
'web_reader'
)
if
(
key
===
'web_reader'
)
res
.
description
=
t
(
`explore.universalChat.plugins.
${
key
}
.description`
)
res
.
description
=
t
(
`explore.universalChat.plugins.
${
key
}
.description`
)
if
(
key
===
'google_search'
&&
!
isSerp
a
piValid
&&
!
readonly
)
{
if
(
key
===
'google_search'
&&
!
isSerp
A
piValid
&&
!
readonly
)
{
res
.
readonly
=
true
res
.
readonly
=
true
res
.
more
=
(
res
.
more
=
(
<
div
className=
'border-t border-[#FEF0C7] flex items-center h-[34px] pl-2 bg-[#FFFAEB] text-gray-700 text-xs '
>
<
div
className=
'border-t border-[#FEF0C7] flex items-center h-[34px] pl-2 bg-[#FFFAEB] text-gray-700 text-xs '
>
<
span
className=
'whitespace-pre'
>
{
t
(
'explore.universalChat.plugins.google_search.more.left'
)
}
</
span
>
<
span
className=
'whitespace-pre'
>
{
t
(
'explore.universalChat.plugins.google_search.more.left'
)
}
</
span
>
<
span
className=
'cursor-pointer text-[#155EEF]'
>
{
t
(
'explore.universalChat.plugins.google_search.more.link'
)
}
</
span
>
<
span
className=
'cursor-pointer text-[#155EEF]'
onClick=
{
()
=>
setShowSetAPIKeyModal
(
true
)
}
>
{
t
(
'explore.universalChat.plugins.google_search.more.link'
)
}
</
span
>
<
span
className=
'whitespace-pre'
>
{
t
(
'explore.universalChat.plugins.google_search.more.right'
)
}
</
span
>
<
span
className=
'whitespace-pre'
>
{
t
(
'explore.universalChat.plugins.google_search.more.right'
)
}
</
span
>
</
div
>
</
div
>
)
)
...
@@ -60,37 +63,46 @@ const Plugins: FC<IPluginsProps> = ({
...
@@ -60,37 +63,46 @@ const Plugins: FC<IPluginsProps> = ({
const
enabledPluginNum
=
Object
.
values
(
config
).
filter
(
v
=>
v
).
length
const
enabledPluginNum
=
Object
.
values
(
config
).
filter
(
v
=>
v
).
length
return
(
return
(
<
FeaturePanel
<>
className=
'mt-3'
<
FeaturePanel
title=
{
className=
'mt-3'
<
div
className=
'flex space-x-1'
>
title=
{
<
div
>
{
t
(
'explore.universalChat.plugins.name'
)
}
</
div
>
<
div
className=
'flex space-x-1'
>
<
div
className=
'text-[13px] font-normal text-gray-500'
>
(
{
enabledPluginNum
}
/
{
plugins
.
length
}
)
</
div
>
<
div
>
{
t
(
'explore.universalChat.plugins.name'
)
}
</
div
>
</
div
>
}
<
div
className=
'text-[13px] font-normal text-gray-500'
>
(
{
enabledPluginNum
}
/
{
plugins
.
length
}
)
</
div
>
hasHeaderBottomBorder=
{
false
}
</
div
>
}
>
hasHeaderBottomBorder=
{
false
}
{
isLoading
>
?
(
{
isLoading
<
div
className=
'flex items-center h-[200px]'
>
?
(
<
Loading
type=
'area'
/>
<
div
className=
'flex items-center h-[200px]'
>
</
div
>
<
Loading
type=
'area'
/>
</
div
>
)
:
(<
div
className=
'space-y-2'
>
{
itemConfigs
.
map
(
item
=>
(
<
Item
key=
{
item
.
key
}
icon=
{
item
.
icon
}
name=
{
item
.
name
}
description=
{
item
.
description
}
more=
{
item
.
more
}
enabled=
{
config
[
item
.
key
]
}
onChange=
{
enabled
=>
onChange
?.(
item
.
key
,
enabled
)
}
readonly=
{
readonly
||
item
.
readonly
}
/>
))
}
</
div
>)
}
</
FeaturePanel
>
{
showSetSerpAPIKeyModal
&&
(
<
AccountSetting
activeTab=
"data-source"
onCancel=
{
async
()
=>
{
setShowSetAPIKeyModal
(
false
)
await
checkSerpApiKey
()
}
}
/>
)
)
:
(<
div
className=
'space-y-2'
>
}
{
itemConfigs
.
map
(
item
=>
(
</>
<
Item
key=
{
item
.
key
}
icon=
{
item
.
icon
}
name=
{
item
.
name
}
description=
{
item
.
description
}
more=
{
item
.
more
}
enabled=
{
config
[
item
.
key
]
}
onChange=
{
enabled
=>
onChange
?.(
item
.
key
,
enabled
)
}
readonly=
{
readonly
||
item
.
readonly
}
/>
))
}
</
div
>)
}
</
FeaturePanel
>
)
)
}
}
export
default
React
.
memo
(
Plugins
)
export
default
React
.
memo
(
Plugins
)
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