From the course: Hands-On OpenAI API: Building a Real-World Solution

Unlock the full course today

Join today to access over 24,000 courses taught by industry experts.

Implementing the Moderations API in the Web API

Implementing the Moderations API in the Web API - OpenAI API Tutorial

From the course: Hands-On OpenAI API: Building a Real-World Solution

Implementing the Moderations API in the Web API

- [Instructor] In this video, we'll check out whether the message the user sent is safe for us to process. Okay, so let's get started. Here, I need to modify the read message function. So let's invoke client moderations and then create. And let's pass input with message. And let's put this in moderation response. And now we need to validate moderation response results, the first result. And if it's flagged, then I want to raise an exception. So let's import HTTP exception. And let's do something like raise HTTP exception. And the status code, I want it to be 400. And the detail say invalid prompt. Okay, so now we're ready to build a new Docker image and push it to the Docker hub. So let's save this. And here, let's execute Docker build. And then the tag, my username, KinderLogger. And this is going to be V two. And the context is this folder. So let's execute this, and after a while, this process is finished so we can verify with Docker image list. So we have two Docker images for the…

Contents