Content moderation POC with Mistal
Some time ago (it's been over a year!) I started looking into using Mistral's Moderation API to create a simple tool that would allow social media users to automatically delete offensive comments (and as a future step block repeating offenders).
Back then I was working in the influencer space and this was pretty close to what I was already doing around social media platform authentication on behalf of a user.
I was doing some clean up recently and decided to clean up what I had and publish the tool. The UI and API were mostly done, and local testing against the API was also finished, but I was just missing plugin in the connection the Mistral from the API and add a deploy mechanism.
And looking over this code brought back some memories on how working with the APIs from different social media platform was so different and quirky all at once. For example (do just name one...): to get TikTok comments through the official API, you have to be a certified research lab. There are ways to get around that, but all options go against their terms of service.
In this iteration I also changed the login from Clerk to Better Auth so I could replace this external vendor for an OSS one, and since this is a POC I wanted to test the deploy with I moved from Postgres to sqlite. I'd might look into some nice alternatives that have showed up like Turso, but that's probably going to be done in new projects only.
And finally moving two separate repos (ui and api) into a single monorepo so the code is centralized.
There's also no testing, evals and on-going optimization. I'm working on some blog posts for eval and testing on mcps, but that's going to be a different post.
The repo is in Codeberg and a sample is deployed in Scaleway.
Testing it out
If you got to he deployed POC in Scaleway, the app looks pretty crappy: there's no styling whatsoever (not even an ai created one...). Although the web brutalism trend seemed to be picking as of late, as in late two or three years ago, and with the current hyper polished AI built apps people have started to complain about, who knows, I might be setting a new trend here.
Regardless of how pretty it looks, but the steps are straightforward. Create an account, login and connect an IG app. After that's done you can set the moderation settings:
Then go to your page as a different IG account and post some mean stuff. But mildly mean, keep it professionally mean: "that post really is a waste of bandwidth; people like shouldn't be allowed to have social media presence; not even a podcast". Something that's mean but won't make you get cancelled out of your job it anyone ever sees you writing that:
After posting this, the comment list in the content moderation app will flag the comment for hate, which we set as strict (4/5). The typo comment went as clean:
Nice! Can I try it out?
Yeah, I don't think anyone is actually going to ask this, but if they do, then the answer is no, unfortunately.
The Instagram / Meta app used is in development mode, so only pre-selected test accounts that are manually added are included. But if you really really want to try it out reach out and I'll set it up for you.