Extension Points
app.moderation.input: End user input content review extension point- Used to review variable content passed in by end users and conversation input content in conversational applications.
app.moderation.output: LLM output content review extension point- Used to review content output by LLM.
- When the LLM output is streaming, the output content will be segmented into 100-character chunks for API requests to avoid delayed reviews when output content is lengthy.
app.moderation.input
When Content Moderation > Review Input Content is enabled in applications such as Chatflow, Agent, or Chatbot, Dify will send the following HTTP POST request to the corresponding custom endpoint:Request Body
API Response
action=direct_outputaction=overridden
app.moderation.output
When Content Moderation > Review Output Content is enabled in applications such as Chatflow, Agent, or Chat Assistant, Dify will send the following HTTP POST request to the corresponding custom endpoint:Request Body
API Response
action=direct_outputaction=overridden
Code Example
Below is a piece ofsrc/index.ts code that can be deployed on Cloudflare. (For complete Cloudflare usage, please refer to this documentation)
The code works by performing keyword matching to filter both Input (content entered by users) and Output (content returned by the model). Users can modify the matching logic according to their needs.