fix: images that fail content filter are added to failed directory#2780
fix: images that fail content filter are added to failed directory#2780IzaakGough wants to merge 7 commits intonextfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the image moderation and placeholder replacement logic, introducing a new placeholder module and updating the main handler. Several critical issues were identified: a regression prevents resized placeholders from being generated when an image is blocked, and the original blocked image is overwritten by the placeholder before it can be moved to the failed directory for review. Additionally, the content filter logic should be optimized by moving initialization and file reading outside the retry loop, and event metadata should correctly report the filter status.
| category, | ||
| threshold: filterLevel, | ||
| })); | ||
| })) as any; |
There was a problem hiding this comment.
not a fan of as any escape hatch here, can we fix
| const HARM_CATEGORIES = [ | ||
| "HARM_CATEGORY_HATE_SPEECH", | ||
| "HARM_CATEGORY_DANGEROUS_CONTENT", | ||
| "HARM_CATEGORY_UNSPECIFIED", |
There was a problem hiding this comment.
I think this was an actual category from the API, we should double check we're OK to remove this
| } | ||
| : undefined; | ||
|
|
||
| // Determine max tokens based on whether we're using custom prompt |
There was a problem hiding this comment.
let's not remove this comment
Fixes #2762 and refactors content filtering functionality.