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
7b26c9e2
Unverified
Commit
7b26c9e2
authored
Nov 07, 2023
by
zxhlyh
Committed by
GitHub
Nov 07, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: code-based extension (#1477)
parent
6bcafdbc
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
18 deletions
+37
-18
form-generation.tsx
.../app/configuration/toolbox/moderation/form-generation.tsx
+2
-2
moderation-setting-modal.tsx
...iguration/toolbox/moderation/moderation-setting-modal.tsx
+11
-2
external-data-tool-modal.tsx
...ents/app/configuration/tools/external-data-tool-modal.tsx
+11
-2
app-debug.en.ts
web/i18n/lang/app-debug.en.ts
+1
-1
app-debug.zh.ts
web/i18n/lang/app-debug.zh.ts
+10
-10
common.ts
web/models/common.ts
+2
-1
No files found.
web/app/components/app/configuration/toolbox/moderation/form-generation.tsx
View file @
7b26c9e2
...
@@ -60,8 +60,8 @@ const FormGeneration: FC<FormGenerationProps> = ({
...
@@ -60,8 +60,8 @@ const FormGeneration: FC<FormGenerationProps> = ({
defaultValue=
{
value
?.[
form
.
variable
]
}
defaultValue=
{
value
?.[
form
.
variable
]
}
items=
{
form
.
options
.
map
((
option
)
=>
{
items=
{
form
.
options
.
map
((
option
)
=>
{
return
{
return
{
value
:
option
,
name
:
option
.
label
[
locale
===
'zh-Hans'
?
'zh-Hans'
:
'en-US'
]
,
name
:
option
,
value
:
option
.
value
,
}
}
})
}
})
}
onSelect=
{
item
=>
handleFormChange
(
form
.
variable
,
item
.
value
as
string
)
}
onSelect=
{
item
=>
handleFormChange
(
form
.
variable
,
item
.
value
as
string
)
}
...
...
web/app/components/app/configuration/toolbox/moderation/moderation-setting-modal.tsx
View file @
7b26c9e2
...
@@ -91,10 +91,19 @@ const ModerationSettingModal: FC<ModerationSettingModalProps> = ({
...
@@ -91,10 +91,19 @@ const ModerationSettingModal: FC<ModerationSettingModalProps> = ({
const
currentProvider
=
providers
.
find
(
provider
=>
provider
.
key
===
localeData
.
type
)
const
currentProvider
=
providers
.
find
(
provider
=>
provider
.
key
===
localeData
.
type
)
const
handleDataTypeChange
=
(
type
:
string
)
=>
{
const
handleDataTypeChange
=
(
type
:
string
)
=>
{
let
config
:
undefined
|
Record
<
string
,
any
>
const
currProvider
=
providers
.
find
(
provider
=>
provider
.
key
===
type
)
if
(
systemTypes
.
findIndex
(
t
=>
t
===
type
)
<
0
&&
currProvider
?.
form_schema
)
{
config
=
currProvider
?.
form_schema
.
reduce
((
prev
,
next
)
=>
{
prev
[
next
.
variable
]
=
next
.
default
return
prev
},
{}
as
Record
<
string
,
any
>
)
}
setLocaleData
({
setLocaleData
({
...
localeData
,
...
localeData
,
type
,
type
,
config
:
undefined
,
config
,
})
})
}
}
...
@@ -198,7 +207,7 @@ const ModerationSettingModal: FC<ModerationSettingModalProps> = ({
...
@@ -198,7 +207,7 @@ const ModerationSettingModal: FC<ModerationSettingModalProps> = ({
if
(
systemTypes
.
findIndex
(
t
=>
t
===
localeData
.
type
)
<
0
&&
currentProvider
?.
form_schema
)
{
if
(
systemTypes
.
findIndex
(
t
=>
t
===
localeData
.
type
)
<
0
&&
currentProvider
?.
form_schema
)
{
for
(
let
i
=
0
;
i
<
currentProvider
.
form_schema
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
currentProvider
.
form_schema
.
length
;
i
++
)
{
if
(
!
localeData
.
config
?.[
currentProvider
.
form_schema
[
i
].
variable
])
{
if
(
!
localeData
.
config
?.[
currentProvider
.
form_schema
[
i
].
variable
]
&&
currentProvider
.
form_schema
[
i
].
required
)
{
notify
({
notify
({
type
:
'error'
,
type
:
'error'
,
message
:
t
(
'appDebug.errorMessage.valueOfVarRequired'
,
{
key
:
locale
===
'en'
?
currentProvider
.
form_schema
[
i
].
label
[
'en-US'
]
:
currentProvider
.
form_schema
[
i
].
label
[
'zh-Hans'
]
}),
message
:
t
(
'appDebug.errorMessage.valueOfVarRequired'
,
{
key
:
locale
===
'en'
?
currentProvider
.
form_schema
[
i
].
label
[
'en-US'
]
:
currentProvider
.
form_schema
[
i
].
label
[
'zh-Hans'
]
}),
...
...
web/app/components/app/configuration/tools/external-data-tool-modal.tsx
View file @
7b26c9e2
...
@@ -67,10 +67,19 @@ const ExternalDataToolModal: FC<ExternalDataToolModalProps> = ({
...
@@ -67,10 +67,19 @@ const ExternalDataToolModal: FC<ExternalDataToolModalProps> = ({
const
currentProvider
=
providers
.
find
(
provider
=>
provider
.
key
===
localeData
.
type
)
const
currentProvider
=
providers
.
find
(
provider
=>
provider
.
key
===
localeData
.
type
)
const
handleDataTypeChange
=
(
type
:
string
)
=>
{
const
handleDataTypeChange
=
(
type
:
string
)
=>
{
let
config
:
undefined
|
Record
<
string
,
any
>
const
currProvider
=
providers
.
find
(
provider
=>
provider
.
key
===
type
)
if
(
systemTypes
.
findIndex
(
t
=>
t
===
type
)
<
0
&&
currProvider
?.
form_schema
)
{
config
=
currProvider
?.
form_schema
.
reduce
((
prev
,
next
)
=>
{
prev
[
next
.
variable
]
=
next
.
default
return
prev
},
{}
as
Record
<
string
,
any
>
)
}
setLocaleData
({
setLocaleData
({
...
localeData
,
...
localeData
,
type
,
type
,
config
:
undefined
,
config
,
})
})
}
}
...
@@ -152,7 +161,7 @@ const ExternalDataToolModal: FC<ExternalDataToolModalProps> = ({
...
@@ -152,7 +161,7 @@ const ExternalDataToolModal: FC<ExternalDataToolModalProps> = ({
if
(
systemTypes
.
findIndex
(
t
=>
t
===
localeData
.
type
)
<
0
&&
currentProvider
?.
form_schema
)
{
if
(
systemTypes
.
findIndex
(
t
=>
t
===
localeData
.
type
)
<
0
&&
currentProvider
?.
form_schema
)
{
for
(
let
i
=
0
;
i
<
currentProvider
.
form_schema
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
currentProvider
.
form_schema
.
length
;
i
++
)
{
if
(
!
localeData
.
config
?.[
currentProvider
.
form_schema
[
i
].
variable
])
{
if
(
!
localeData
.
config
?.[
currentProvider
.
form_schema
[
i
].
variable
]
&&
currentProvider
.
form_schema
[
i
].
required
)
{
notify
({
notify
({
type
:
'error'
,
type
:
'error'
,
message
:
t
(
'appDebug.errorMessage.valueOfVarRequired'
,
{
key
:
locale
===
'en'
?
currentProvider
.
form_schema
[
i
].
label
[
'en-US'
]
:
currentProvider
.
form_schema
[
i
].
label
[
'zh-Hans'
]
}),
message
:
t
(
'appDebug.errorMessage.valueOfVarRequired'
,
{
key
:
locale
===
'en'
?
currentProvider
.
form_schema
[
i
].
label
[
'en-US'
]
:
currentProvider
.
form_schema
[
i
].
label
[
'zh-Hans'
]
}),
...
...
web/i18n/lang/app-debug.en.ts
View file @
7b26c9e2
...
@@ -134,7 +134,7 @@ const translation = {
...
@@ -134,7 +134,7 @@ const translation = {
},
},
moderation
:
{
moderation
:
{
title
:
'Content moderation'
,
title
:
'Content moderation'
,
description
:
'
Content moderation
'
,
description
:
'
Secure model output by using moderation API or maintaining a sensitive word list.
'
,
allEnabled
:
'INPUT/OUTPUT Content Enabled'
,
allEnabled
:
'INPUT/OUTPUT Content Enabled'
,
inputEnabled
:
'INPUT Content Enabled'
,
inputEnabled
:
'INPUT Content Enabled'
,
outputEnabled
:
'OUTPUT Content Enabled'
,
outputEnabled
:
'OUTPUT Content Enabled'
,
...
...
web/i18n/lang/app-debug.zh.ts
View file @
7b26c9e2
...
@@ -133,13 +133,13 @@ const translation = {
...
@@ -133,13 +133,13 @@ const translation = {
title
:
'工具箱'
,
title
:
'工具箱'
,
},
},
moderation
:
{
moderation
:
{
title
:
'内容审
核
'
,
title
:
'内容审
查
'
,
description
:
'
内容审核
'
,
description
:
'
您可以调用审查 API 或者维护敏感词库来使模型更安全地输出。
'
,
allEnabled
:
'审
核输入/审核
输出 内容已启用'
,
allEnabled
:
'审
查输入/审查
输出 内容已启用'
,
inputEnabled
:
'审
核
输入内容已启用'
,
inputEnabled
:
'审
查
输入内容已启用'
,
outputEnabled
:
'审
核
输出内容已启用'
,
outputEnabled
:
'审
查
输出内容已启用'
,
modal
:
{
modal
:
{
title
:
'内容审
核
设置'
,
title
:
'内容审
查
设置'
,
provider
:
{
provider
:
{
title
:
'类别'
,
title
:
'类别'
,
openai
:
'OpenAI Moderation'
,
openai
:
'OpenAI Moderation'
,
...
@@ -155,17 +155,17 @@ const translation = {
...
@@ -155,17 +155,17 @@ const translation = {
line
:
'行'
,
line
:
'行'
,
},
},
content
:
{
content
:
{
input
:
'审
核
输入内容'
,
input
:
'审
查
输入内容'
,
output
:
'审
核
输出内容'
,
output
:
'审
查
输出内容'
,
preset
:
'预设回复'
,
preset
:
'预设回复'
,
placeholder
:
'这里预设回复内容'
,
placeholder
:
'这里预设回复内容'
,
condition
:
'审
核输入内容和审核
输出内容至少启用一项'
,
condition
:
'审
查输入内容和审查
输出内容至少启用一项'
,
fromApi
:
'预设回复通过 API 返回'
,
fromApi
:
'预设回复通过 API 返回'
,
errorMessage
:
'预设回复不能为空'
,
errorMessage
:
'预设回复不能为空'
,
supportMarkdown
:
'支持 Markdown'
,
supportMarkdown
:
'支持 Markdown'
,
},
},
openaiNotConfig
:
{
openaiNotConfig
:
{
before
:
'OpenAI 内容审
核
需要在'
,
before
:
'OpenAI 内容审
查
需要在'
,
after
:
'中配置 OpenAI API 密钥。'
,
after
:
'中配置 OpenAI API 密钥。'
,
},
},
},
},
...
...
web/models/common.ts
View file @
7b26c9e2
...
@@ -214,9 +214,10 @@ export type CodeBasedExtensionForm = {
...
@@ -214,9 +214,10 @@ export type CodeBasedExtensionForm = {
label
:
I18nText
label
:
I18nText
variable
:
string
variable
:
string
required
:
boolean
required
:
boolean
options
:
string
[]
options
:
{
label
:
I18nText
;
value
:
string
}
[]
default
:
string
default
:
string
placeholder
:
string
placeholder
:
string
max_length
?:
number
}
}
export
type
CodeBasedExtensionItem
=
{
export
type
CodeBasedExtensionItem
=
{
...
...
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