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
0a5de0ff
Unverified
Commit
0a5de0ff
authored
Jan 20, 2024
by
Garfield Dai
Committed by
GitHub
Jan 20, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: empty keywords moderation. (#2108)
parent
9c4bad8f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
keywords.py
api/core/moderation/keywords/keywords.py
+6
-1
No files found.
api/core/moderation/keywords/keywords.py
View file @
0a5de0ff
...
@@ -30,7 +30,10 @@ class KeywordsModeration(Moderation):
...
@@ -30,7 +30,10 @@ class KeywordsModeration(Moderation):
if
query
:
if
query
:
inputs
[
'query__'
]
=
query
inputs
[
'query__'
]
=
query
# Filter out empty values
keywords_list
=
[
keyword
for
keyword
in
self
.
config
[
'keywords'
]
.
split
(
'
\n
'
)
if
keyword
]
keywords_list
=
[
keyword
for
keyword
in
self
.
config
[
'keywords'
]
.
split
(
'
\n
'
)
if
keyword
]
flagged
=
self
.
_is_violated
(
inputs
,
keywords_list
)
flagged
=
self
.
_is_violated
(
inputs
,
keywords_list
)
return
ModerationInputsResult
(
flagged
=
flagged
,
action
=
ModerationAction
.
DIRECT_OUTPUT
,
preset_response
=
preset_response
)
return
ModerationInputsResult
(
flagged
=
flagged
,
action
=
ModerationAction
.
DIRECT_OUTPUT
,
preset_response
=
preset_response
)
...
@@ -40,7 +43,9 @@ class KeywordsModeration(Moderation):
...
@@ -40,7 +43,9 @@ class KeywordsModeration(Moderation):
preset_response
=
""
preset_response
=
""
if
self
.
config
[
'outputs_config'
][
'enabled'
]:
if
self
.
config
[
'outputs_config'
][
'enabled'
]:
keywords_list
=
self
.
config
[
'keywords'
]
.
split
(
'
\n
'
)
# Filter out empty values
keywords_list
=
[
keyword
for
keyword
in
self
.
config
[
'keywords'
]
.
split
(
'
\n
'
)
if
keyword
]
flagged
=
self
.
_is_violated
({
'text'
:
text
},
keywords_list
)
flagged
=
self
.
_is_violated
({
'text'
:
text
},
keywords_list
)
preset_response
=
self
.
config
[
'outputs_config'
][
'preset_response'
]
preset_response
=
self
.
config
[
'outputs_config'
][
'preset_response'
]
...
...
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