mirror of
https://github.com/langgenius/dify.git
synced 2026-10-16 15:35:32 +08:00
fix: ignore blank keyword rows in moderation limit (#42212)
This commit is contained in:
@@ -25,8 +25,8 @@ class KeywordsModeration(Moderation):
|
||||
if len(config.get("keywords", [])) > 10000:
|
||||
raise ValueError("keywords length must be less than 10000")
|
||||
|
||||
keywords_row_len = config["keywords"].split("\n")
|
||||
if len(keywords_row_len) > 100:
|
||||
keywords_rows = cls._keyword_rows(config["keywords"])
|
||||
if len(keywords_rows) > 100:
|
||||
raise ValueError("the number of rows for the keywords must be less than 100")
|
||||
|
||||
@override
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
from core.moderation.keywords.keywords import KeywordsModeration
|
||||
|
||||
|
||||
def test_validate_config_ignores_trailing_blank_keyword_row() -> None:
|
||||
config = {
|
||||
"inputs_config": {"enabled": True, "preset_response": "Blocked"},
|
||||
"outputs_config": {"enabled": False},
|
||||
"keywords": "\n".join(f"word{i}" for i in range(100)) + "\n",
|
||||
}
|
||||
|
||||
KeywordsModeration.validate_config("tenant", config)
|
||||
Reference in New Issue
Block a user