Skip to content

Conversation

narenoai
Copy link
Contributor

This example provides a way to use the moderation api to check if images are potentially harmful and if so why.

Summary

This commit adds a python example to check an image using the moderation API. It also provides a way to batch check multiple images from URLs.

Motivation

Using the moderation api to check if an image is complaint or not can be very useful for a lot of use cases.


For new content

When contributing new content, read through our contribution guidelines, and mark the following action items as completed:

  • I have added a new entry in registry.yaml (and, optionally, in authors.yaml) so that my content renders on the cookbook website.
  • I have conducted a self-review of my content based on the contribution guidelines:
    • Relevance: This content is related to building with OpenAI technologies and is useful to others.
    • Uniqueness: I have searched for related examples in the OpenAI Cookbook, and verified that my content offers new insights or unique information compared to existing documentation.
    • Spelling and Grammar: I have checked for spelling or grammatical mistakes.
    • Clarity: I have done a final read-through and verified that my submission is well-organized and easy to understand.
    • Correctness: The information I include is correct and all of my code executes successfully.
    • Completeness: I have explained everything fully, including all necessary references and citations.

We will rate each of these areas on a scale from 1 to 4, and will only accept contributions that score 3 or higher on all areas. Refer to our contribution guidelines for more details.

This example provides a way to use the moderation api to check if images are potentially harmful and if so why.
@phundal-openai
Copy link
Contributor

Hi Naren,

Great work here... 2 items I would offer for consideration:

  1. Borrow the layout, explanation, and dependency setup from this cookbook: https://cookbook.openai.com/examples/gpt4o/introduction_to_gpt4o

  2. Consider taking this work and creating an additional image moderation section to this existing cookbook:

It may or may not make sense to build on the existing cookbook, but worth considering.

As per the feedback from Patrick, added an example in the existing moderation api cookbook that shows how to check an image for appropriateness
@narenoai
Copy link
Contributor Author

@phundal-openai I deleted the new cookbook and modified the existing moderation cookbook and added checking an image as an additional example. d0e5241

Copy link
Contributor

@phundal-openai phundal-openai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great - nice addition.

@phundal-openai phundal-openai merged commit f29c15a into openai:main Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants