Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(api/core/moderation/output_moderation.py): Fix config call. (#6769)

-LAN-8dd68e2034a8
diff --git a/api/configs/app_config.py b/api/configs/app_config.py
index d1099a90363..a5a4fc788d0 100644
--- a/api/configs/app_config.py
+++ b/api/configs/app_config.py
@@ -64,4 +64,6 @@ class DifyConfig(
return f'{self.HTTP_REQUEST_NODE_MAX_TEXT_SIZE / 1024 / 1024:.2f}MB'
SSRF_PROXY_HTTP_URL: str | None = None
- SSRF_PROXY_HTTPS_URL: str | None = None
\ No newline at end of file
+ SSRF_PROXY_HTTPS_URL: str | None = None
+
+ MODERATION_BUFFER_SIZE: int = Field(default=300, description='The buffer size for moderation.')
diff --git a/api/core/moderation/output_moderation.py b/api/core/moderation/output_moderation.py
index 4fd08ca0212..9a4d8db4e2f 100644
--- a/api/core/moderation/output_moderation.py
+++ b/api/core/moderation/output_moderation.py
@@ -21,8 +21,6 @@ class ModerationRule(BaseModel):
class OutputModeration(BaseModel):
- DEFAULT_BUFFER_SIZE: int = 300
-
tenant_id: str
app_id: str
@@ -77,10 +75,10 @@ class OutputModeration(BaseModel):
return final_output
def start_thread(self) -> threading.Thread:
- buffer_size = int(dify_config.config.MODERATION_BUFFER_SIZE)
+ buffer_size = dify_config.MODERATION_BUFFER_SIZE
thread = threading.Thread(target=self.worker, kwargs={
'flask_app': current_app._get_current_object(),
- 'buffer_size': buffer_size if buffer_size > 0 else self.DEFAULT_BUFFER_SIZE
+ 'buffer_size': buffer_size if buffer_size > 0 else dify_config.MODERATION_BUFFER_SIZE
})
thread.start()