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
08d2a427
Commit
08d2a427
authored
Mar 08, 2024
by
StyleZhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cache toolsmap
parent
d79b6869
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
index.tsx
web/app/components/workflow/nodes/index.tsx
+1
-1
use-config.ts
web/app/components/workflow/nodes/tool/use-config.ts
+15
-1
No files found.
web/app/components/workflow/nodes/index.tsx
View file @
08d2a427
...
...
@@ -25,7 +25,7 @@ export const Panel = memo((props: Node) => {
const
PanelComponent
=
PanelComponentMap
[
nodeData
.
type
]
return
(
<
BasePanel
{
...
props
}
>
<
BasePanel
key=
{
props
.
id
}
{
...
props
}
>
<
PanelComponent
/>
</
BasePanel
>
)
...
...
web/app/components/workflow/nodes/tool/use-config.ts
View file @
08d2a427
import
{
useCallback
,
useEffect
,
useState
}
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
produce
from
'immer'
import
{
useBoolean
}
from
'ahooks'
import
{
useStore
}
from
'../../store'
import
type
{
ToolNodeType
,
ToolVarInput
}
from
'./types'
import
useNodeCrud
from
'@/app/components/workflow/nodes/_base/hooks/use-node-crud'
import
{
CollectionType
}
from
'@/app/components/tools/types'
...
...
@@ -11,6 +13,8 @@ import Toast from '@/app/components/base/toast'
const
useConfig
=
(
id
:
string
,
payload
:
ToolNodeType
)
=>
{
const
{
t
}
=
useTranslation
()
const
toolsMap
=
useStore
(
s
=>
s
.
toolsMap
)
const
setToolsMap
=
useStore
(
s
=>
s
.
setToolsMap
)
const
{
inputs
,
setInputs
}
=
useNodeCrud
<
ToolNodeType
>
(
id
,
payload
)
const
{
provider_id
,
provider_name
,
provider_type
,
tool_name
,
tool_parameters
}
=
inputs
...
...
@@ -78,7 +82,17 @@ const useConfig = (id: string, payload: ToolNodeType) => {
useEffect
(()
=>
{
(
async
()
=>
{
const
list
=
isBuiltIn
?
await
fetchBuiltInToolList
(
provider_name
||
provider_id
)
:
await
fetchCustomToolList
(
provider_name
)
let
list
:
Tool
[]
=
[]
if
(
toolsMap
[
provider_id
]?.
length
)
{
list
=
toolsMap
[
provider_id
]
}
else
{
list
=
isBuiltIn
?
await
fetchBuiltInToolList
(
provider_name
||
provider_id
)
:
await
fetchCustomToolList
(
provider_name
)
setToolsMap
(
produce
(
toolsMap
,
(
draft
)
=>
{
draft
[
provider_id
]
=
list
}))
}
const
currTool
=
list
.
find
(
tool
=>
tool
.
name
===
tool_name
)
if
(
currTool
)
setCurrTool
(
currTool
)
...
...
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