Skip to content

LinkedInLearning/openai-api-moderation-4564114

Repository files navigation

OpenAI API: Moderation.

This is the repository for the LinkedIn Learning course OpenAI API: Moderation. The full course is available from LinkedIn Learning.

Left unchecked, AI systems can both process and output what can be considered harmful language. Sometimes this is necessary; other times it is unwanted. Using the OpenAI API, you can apply moderation tools to the communication between the user and the API to control both what goes into and what comes out of the system. In this course, you’ll get an overview of how these features work and how to implement them in your app.

course-name-alt-text

See the readme file in the main branch for updated instructions and information.

Instructions

This repository provides basic examples of how to use the Moderation feature of the OpenAI API in Python.

There are three examples: basic.py, conditional.py, and mod-assistant.py. Each example is stand-alone and runs in terminal.

To use these exercise files you need an OpenAI API key. You get that key at platform.openai.com

Running the examples in GitHub Codespaces

  1. Click the "Code" button and select "Codespaces."
  2. Create a new Codespace or open one you've already created.
  3. Create a new file named .env in the root folder.
  4. Add OPENAI_API_KEY= followed by your OpenAI API key to .env
  5. Note .env is not tracked by GitHub so the file will only exist in this Codespace.
  6. To run the Python example in terminal, use the python [filename].py command.

Running mod-assistant.py

To run mod-assistant.py you must first create an Assistant and add its ID into the file. You can create an assistant at platform.openai.com.

For further info on OpenAI Assistants check out our dedicated course on the subject.

About

This is a code repository for the LinkedIn Learning course OpenAI API: Moderation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages