NOUKAI

Content Moderation

Independent checks (toxicity, spam, off-topic) run in parallel, then a deterministic code block combines the scores into a verdict.

Run several independent checks on user-generated content in parallel, then combine into a single moderation verdict.

Tree

Flow: "moderate-content"
├── Container (parallel)
│     ├── Block: "toxicity-check" (llm)
│     ├── Block: "spam-check" (llm)
│     └── Block: "off-topic-check" (llm)
└── Block: "final-verdict" (code)

Blocks

toxicity-check (llm)

Score the following text for toxicity from 0 (safe) to 1 (severely toxic). Identify the toxicity category if any: harassment, hate, violence, sexual, none.

Text: {{message}}

spam-check (llm)

Score the following text for spam likelihood from 0 (genuine) to 1 (clearly spam). Note any spam signals you detect (excessive links, promotional language, repetition).

Text: {{message}}

off-topic-check (llm)

The expected topic for this forum is: {{parameters.topic}}.

Score the following text for topic relevance from 0 (entirely off-topic) to 1 (perfectly on-topic).

Text: {{message}}

final-verdict (code) — Python

tox = inputs["toxicity_check"]["score"]
spam = inputs["spam_check"]["score"]
off = inputs["off_topic_check"]["score"]
 
action = "approve"
if tox > 0.8 or spam > 0.9:
    action = "block"
elif tox > 0.5 or spam > 0.6 or off < 0.2:
    action = "review"
 
return {
    "action": action,
    "scores": {"toxicity": tox, "spam": spam, "off_topic": off},
    "reasons": inputs,
}

Why this shape?

  • Three checks, three parallel blocks. Each check is independent — toxicity doesn't depend on spam likelihood. Sequential would multiply latency for no gain.
  • The final verdict is a code block, not an llm block. Threshold logic is deterministic and cheap. Asking an LLM to combine three numeric scores wastes tokens and introduces variance you don't want in moderation decisions.
  • Each LLM block returns a structured score, not free-form prose. The code block needs numbers — schemas keep the contract honest.
  • Code blocks run Python. Earlier drafts of this recipe used a JavaScript snippet; that was a doc bug — the platform's code runtime is Python, and prompts that say otherwise will mislead authors and LLM clients.
  • No prompt engineering on the aggregator. When the combination logic is "if X > threshold, do Y," that's not an LLM job.

On this page