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
297d0f1f
Unverified
Commit
297d0f1f
authored
Feb 20, 2024
by
zxhlyh
Committed by
GitHub
Feb 20, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: code-based extension (#2490)
parent
eedbe1b7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
25 deletions
+26
-25
index.tsx
web/app/components/app/configuration/config-var/index.tsx
+2
-1
index.tsx
web/app/components/app/configuration/debug/index.tsx
+1
-1
form-generation.tsx
.../app/configuration/toolbox/moderation/form-generation.tsx
+1
-1
hooks.ts
web/app/components/base/chat/chat/hooks.ts
+1
-1
model-config.ts
web/utils/model-config.ts
+21
-21
No files found.
web/app/components/app/configuration/config-var/index.tsx
View file @
297d0f1f
...
@@ -147,6 +147,7 @@ const ConfigVar: FC<IConfigVarProps> = ({ promptVariables, readonly, onPromptVar
...
@@ -147,6 +147,7 @@ const ConfigVar: FC<IConfigVarProps> = ({ promptVariables, readonly, onPromptVar
)
=>
{
)
=>
{
setShowExternalDataToolModal
({
setShowExternalDataToolModal
({
payload
:
{
payload
:
{
type
,
variable
:
key
,
variable
:
key
,
label
:
name
,
label
:
name
,
config
,
config
,
...
@@ -245,7 +246,7 @@ const ConfigVar: FC<IConfigVarProps> = ({ promptVariables, readonly, onPromptVar
...
@@ -245,7 +246,7 @@ const ConfigVar: FC<IConfigVarProps> = ({ promptVariables, readonly, onPromptVar
const
handleConfig
=
({
key
,
type
,
index
,
name
,
config
,
icon
,
icon_background
}:
ExternalDataToolParams
)
=>
{
const
handleConfig
=
({
key
,
type
,
index
,
name
,
config
,
icon
,
icon_background
}:
ExternalDataToolParams
)
=>
{
setCurrKey
(
key
)
setCurrKey
(
key
)
if
(
type
===
'api
'
)
{
if
(
type
!==
'string'
&&
type
!==
'paragraph'
&&
type
!==
'select
'
)
{
handleOpenExternalDataToolModal
({
key
,
type
,
index
,
name
,
config
,
icon
,
icon_background
},
promptVariables
)
handleOpenExternalDataToolModal
({
key
,
type
,
index
,
name
,
config
,
icon
,
icon_background
},
promptVariables
)
return
return
}
}
...
...
web/app/components/app/configuration/debug/index.tsx
View file @
297d0f1f
...
@@ -149,7 +149,7 @@ const Debug: FC<IDebug> = ({
...
@@ -149,7 +149,7 @@ const Debug: FC<IDebug> = ({
}
}
let
hasEmptyInput
=
''
let
hasEmptyInput
=
''
const
requiredVars
=
modelConfig
.
configs
.
prompt_variables
.
filter
(({
key
,
name
,
required
,
type
})
=>
{
const
requiredVars
=
modelConfig
.
configs
.
prompt_variables
.
filter
(({
key
,
name
,
required
,
type
})
=>
{
if
(
type
===
'api
'
)
if
(
type
!==
'string'
&&
type
!==
'paragraph'
&&
type
!==
'select
'
)
return
false
return
false
const
res
=
(
!
key
||
!
key
.
trim
())
||
(
!
name
||
!
name
.
trim
())
||
(
required
||
required
===
undefined
||
required
===
null
)
const
res
=
(
!
key
||
!
key
.
trim
())
||
(
!
name
||
!
name
.
trim
())
||
(
required
||
required
===
undefined
||
required
===
null
)
return
res
return
res
...
...
web/app/components/app/configuration/toolbox/moderation/form-generation.tsx
View file @
297d0f1f
...
@@ -65,7 +65,7 @@ const FormGeneration: FC<FormGenerationProps> = ({
...
@@ -65,7 +65,7 @@ const FormGeneration: FC<FormGenerationProps> = ({
}
}
})
}
})
}
onSelect=
{
item
=>
handleFormChange
(
form
.
variable
,
item
.
value
as
string
)
}
onSelect=
{
item
=>
handleFormChange
(
form
.
variable
,
item
.
value
as
string
)
}
popupClassName=
'w-[576px]'
popupClassName=
'w-[576px]
!z-[102]
'
/>
/>
)
)
}
}
...
...
web/app/components/base/chat/chat/hooks.ts
View file @
297d0f1f
...
@@ -42,7 +42,7 @@ export const useCheckPromptVariables = () => {
...
@@ -42,7 +42,7 @@ export const useCheckPromptVariables = () => {
}
=
promptVariablesConfig
}
=
promptVariablesConfig
let
hasEmptyInput
=
''
let
hasEmptyInput
=
''
const
requiredVars
=
promptVariables
.
filter
(({
key
,
name
,
required
,
type
})
=>
{
const
requiredVars
=
promptVariables
.
filter
(({
key
,
name
,
required
,
type
})
=>
{
if
(
type
===
'api
'
)
if
(
type
!==
'string'
&&
type
!==
'paragraph'
&&
type
!==
'select
'
)
return
false
return
false
const
res
=
(
!
key
||
!
key
.
trim
())
||
(
!
name
||
!
name
.
trim
())
||
(
required
||
required
===
undefined
||
required
===
null
)
const
res
=
(
!
key
||
!
key
.
trim
())
||
(
!
name
||
!
name
.
trim
())
||
(
required
||
required
===
undefined
||
required
===
null
)
return
res
return
res
...
...
web/utils/model-config.ts
View file @
297d0f1f
...
@@ -16,7 +16,7 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
...
@@ -16,7 +16,7 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
return
[
'string'
,
item
[
'text-input'
]]
return
[
'string'
,
item
[
'text-input'
]]
if
(
item
.
external_data_tool
)
if
(
item
.
external_data_tool
)
return
[
'api'
,
item
.
external_data_tool
]
return
[
item
.
external_data_tool
.
type
,
item
.
external_data_tool
]
return
[
'select'
,
item
.
select
]
return
[
'select'
,
item
.
select
]
})()
})()
...
@@ -33,16 +33,13 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
...
@@ -33,16 +33,13 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
is_context_var
,
is_context_var
,
})
})
}
}
else
if
(
type
===
'
api
'
)
{
else
if
(
type
===
'
select
'
)
{
promptVariables
.
push
({
promptVariables
.
push
({
key
:
content
.
variable
,
key
:
content
.
variable
,
name
:
content
.
label
,
name
:
content
.
label
,
required
:
content
.
required
,
required
:
content
.
required
,
type
:
content
.
type
,
type
:
'select'
,
enabled
:
content
.
enabled
,
options
:
content
.
options
,
config
:
content
.
config
,
icon
:
content
.
icon
,
icon_background
:
content
.
icon_background
,
is_context_var
,
is_context_var
,
})
})
}
}
...
@@ -51,8 +48,11 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
...
@@ -51,8 +48,11 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
key
:
content
.
variable
,
key
:
content
.
variable
,
name
:
content
.
label
,
name
:
content
.
label
,
required
:
content
.
required
,
required
:
content
.
required
,
type
:
'select'
,
type
:
content
.
type
,
options
:
content
.
options
,
enabled
:
content
.
enabled
,
config
:
content
.
config
,
icon
:
content
.
icon
,
icon_background
:
content
.
icon_background
,
is_context_var
,
is_context_var
,
})
})
}
}
...
@@ -79,28 +79,28 @@ export const promptVariablesToUserInputsForm = (promptVariables: PromptVariable[
...
@@ -79,28 +79,28 @@ export const promptVariablesToUserInputsForm = (promptVariables: PromptVariable[
},
},
}
as
any
)
}
as
any
)
}
}
else
if
(
item
.
type
===
'
api
'
)
{
else
if
(
item
.
type
===
'
select
'
)
{
userInputs
.
push
({
userInputs
.
push
({
external_data_tool
:
{
select
:
{
label
:
item
.
name
,
label
:
item
.
name
,
variable
:
item
.
key
,
variable
:
item
.
key
,
enabled
:
item
.
enabled
,
required
:
item
.
required
!==
false
,
// default true
type
:
item
.
type
,
options
:
item
.
options
,
config
:
item
.
config
,
default
:
''
,
required
:
item
.
required
,
icon
:
item
.
icon
,
icon_background
:
item
.
icon_background
,
},
},
}
as
any
)
}
as
any
)
}
}
else
{
else
{
userInputs
.
push
({
userInputs
.
push
({
select
:
{
external_data_tool
:
{
label
:
item
.
name
,
label
:
item
.
name
,
variable
:
item
.
key
,
variable
:
item
.
key
,
required
:
item
.
required
!==
false
,
// default true
enabled
:
item
.
enabled
,
options
:
item
.
options
,
type
:
item
.
type
,
default
:
''
,
config
:
item
.
config
,
required
:
item
.
required
,
icon
:
item
.
icon
,
icon_background
:
item
.
icon_background
,
},
},
}
as
any
)
}
as
any
)
}
}
...
...
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