From the course: Generative AI Imaging Tools for Developers
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Adding modification
From the course: Generative AI Imaging Tools for Developers
Adding modification
- [Instructor] In this one, we're going to implement some moderation. Now, creating software that generates images can be very scary because you never know what kind of imagery users are going to generate using your software. Luckily, we can use AI to help mitigate some of these risks. It's important to keep in mind that this automation should be part of an overall strategy to prevent misuse of your system. Now here, I have my enhance_prompt function, and right above it, I'm going to place my moderate_prompt function, which takes a client and a prompt. Now, what this is going to do is it's going to tell me that my moderation = client.moderations.create, input is prompt. Now, this moderation response can give you lots of detail about various aspects of what could be problematic with a prompt. But for this one, we're just going to see if it passes the flagged threshold. So I'm going to say that flagged = moderation.results[0].flagged. And this is the most bare-bones way of using the…