Problem/Motivation
When loading content in bulk to a vector database, certain paragraphs may be flagged by moderation.
The interface does not show exactly what content caused the issue so that it can be addressed.
Proposed resolution
Add code similar to this to OpenAiProvider.php:
(lines 626-628)
if (!empty($response['results'][0]['flagged'])) {
$moderation_alert = 'This prompt was flagged by the moderation model: ' . $prompt;
\Drupal::logger('ai_provider_openai')->notice($moderation_alert);
throw new AiUnsafePromptException('The prompt was flagged by the moderation model.');
}
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | ai_provider_openai-log-flagged-prompts-3507407-1.patch | 634 bytes | nico heulsen |
Issue fork ai_provider_openai-3507407
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
Comment #4
nico heulsen commentedI have created a patch implementing the suggested solution. The patch is attached for review.
Comment #5
koustav_mondal commentedWorking on it.
Comment #7
koustav_mondal commentedComment #8
wouters_f commentedI have seen these logs and its absolutely better than nothing.
Even better would be a dead letter queue for these messages but that would be a search_api or core queue thing.
Comment #9
kenorb commentedSame error here.
Is there a way to disable or bypass the moderation model to flag the content?
Ok, I've found it (see: /admin/config/ai/providers/openai):
Comment #10
wouters_f commentedThere is a way to skip moderations for your content:
https://www.drupal.org/project/ai/issues/3510599#comment-16028722
Comment #11
koustav_mondal commentedHello @wouters_f, if the changes are good then please fix the issue.
Comment #12
jonas139 commentedI've created a feature to handle the flagged prompts in a more manageable way. It can be reviewed here https://www.drupal.org/project/ai_provider_openai/issues/3516044.
Comment #13
mrdalesmith commentedTests are failing because of a coding standards breach, so setting back to needs work.
Comment #15
prabha1997 commentedComment #16
divyansh.gupta commentedI have reviewed the issue and now the flagged prompts are also coming in logs.
The changes looks good to me, also the pipeline is green with no merge conflicts.
Thus moving this to RTBC!