Problem/Motivation

OpenAI can analyze text and score content among various categories. This can be useful for content editors who may have sensitive audiences as well as hook into things like Comment submissions - like flagging for review.

https://platform.openai.com/docs/guides/moderation/overview

Proposed resolution

Start by adding it to nodes.

Remaining tasks

User interface changes

Add a new section on node edit forms for analyzing text.

API changes

Data model changes

Issue fork openai-3347276

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kevinquillen created an issue. See original summary.

kevinquillen’s picture

Adding this was not difficult to start out with.

Although... the scores in their documentation were well over 1.0 for no reason (despite not being flagged as violated) for technical content. In fact, when I try to add text that should violate categories, it does not at all.

kevinquillen’s picture

Next steps could be:

  • Adding configuration so you can set score thresholds on what content is, and is not acceptable, for your site.
  • Hook into Comment submissions so they can be flagged for review instead of published to the public
kevinquillen’s picture

Is it possible the OpenAI docs are outdated and the score range is no longer 0-1? You can see for example in this blog post, this persons scores came back well over 1 for categories too:

https://cobusgreyling.medium.com/adding-a-moderation-layer-to-your-opena...

ressa’s picture

That's a nice feature, thanks for working on it @kevinquillen. I have no opinion on the numbers ... but the ranges do look quite different between the documentation and the medium.com article.

Going the other way, checking user input for bad words and filtering out before submitting to ChatGPT can be done with https://github.com/ConsoleTVs/Profanity.

kevinquillen’s picture

It is more than a word filter though, the scores are designed or should indicate a direction the way the content leans, which some types of sites may find useful. Particularly with user submitted content. Using this endpoint is free of charge too. Its fine for content to have curse words, lets say, if that is the context of the content.

bogdog400’s picture

This could also be useful as a prefilter before calling the main OpenAI API. If a question/prompt has unacceptable things in it, the call to the main API could be pre-empted.

kevinquillen’s picture

That is true. On the upside these API calls appear to be free.

We're also considering it for a project that has user submitted content with Content Moderation module enabled. Until an individuals submission passes the score thresholds, the content will live as Draft and not come before the site managers who review content until that is satisfied.

At the same time, we could probably combine that with a "change the tone" style action after that to get content "in shape" for this particular org for display.. the possibilities are pretty cool.

bogdog400’s picture

Yes. The free price is a nice way to roll out the tech.

Rajeshreeputra made their first commit to this issue’s fork.

  • kevinquillen committed 9a6d22d1 on 1.0.x
    Issue #3347276 by kevinquillen, Rajeshreeputra: Implement basic content...
kevinquillen’s picture

Status: Active » Fixed

This seems to work alright, especially in combination with other sidebar tools:

https://www.youtube.com/watch?v=pN2GeUnxpl0

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.