Skip to content

feat: make AI Moderation provider-agnostic - #64

Merged
Alam-2U merged 1 commit into
release-ulmofrom
LP-1032
Aug 25, 2026
Merged

feat: make AI Moderation provider-agnostic#64
Alam-2U merged 1 commit into
release-ulmofrom
LP-1032

Conversation

@Alam-2U

@Alam-2U Alam-2U commented Aug 25, 2026

Copy link
Copy Markdown

Description

AI moderation was hard-wired to XPert. The service built the XPert request and parsed the XPert response itself, so the provider and the moderation workflow were one piece of code — there was no way to run this against anything else.

This separates them. Forum now defines a moderation interface and ships no provider of its own. AIModerationService orchestrates only — deduplication, caching, spam flagging, soft deletion, audit logging — and delegates classification to whichever backend AI_MODERATION_BACKEND names. XPert becomes one implementation of that interface, chosen by configuration rather than by being the only option.

No behaviour change for edX: XPert is selected in edx-internal and sends exactly the requests it sent before.

Changes

  • A provider-agnostic backend interface, plus shared handling for HTTP classifiers (endpoint, timeouts, error handling, response parsing). The generic layer holds no credential and sets no auth header — providers disagree about auth more than anything else, so that belongs to each backend.
  • XPert moved behind that interface, its request and response handling unchanged.
  • Backend selected by AI_MODERATION_BACKEND and loaded by dotted path.
  • A default prompt and timeouts ship with forum, so standing up a backend doesn't also mean writing a spam-classifier prompt.
  • Settings declared in forum's own plugin settings, deferring to whatever the deployment already configured. No edx-platform change is needed.
  • Provider failure and misconfiguration degrade moderation and log the reason; neither can block a learner from posting.
  • A how-to for operators writing their own backend.

Ticket ref

LP-1032

Related PR

  • edx-internal: <link>

@Alam-2U
Alam-2U marked this pull request as ready for review August 25, 2026 07:45
what comes back spam, and soft deletes it when auto-delete is enabled. Both
steps are gated on course waffle flags, and every spam verdict is recorded on a
moderation audit log.
"""

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small thing to confirm: since forum.ai_moderation is being moved from a single module to a package structure, please make sure there are no remaining imports using the old path in any other repo or downstream branch.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@santhosh-apphelix-2u I have confirmed there is no remaining imports using the old path in any other repo or downstream branch

@Alam-2U
Alam-2U merged commit aa3f415 into release-ulmo Aug 25, 2026
13 checks passed
@Alam-2U
Alam-2U deleted the LP-1032 branch August 25, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants