AI DevKit
Glitch9 Inc.Glitch9 DocsDiscordIssues
  • Introduction
    • AI DevKit 3.0
    • Update Logs
    • Troubleshooting
      • ❗Issues After Updating AIDevKit?
      • ❗The type or namespace name 'Newtonsoft' could not be found
      • ❗Build Error: The name 'UnityMenu' does not exist in the current context
      • ❗Model 'modelName' not found
      • ❗The model `model name` does not exist or you do not have access to it
      • ❗The type or namespace name 'AndroidJavaObject' could not be found
      • ❗The type or namaspace name 'Plastic' does not exist
      • ❗Build Error: The name 'Asset Database' does not exist in the current context
      • ❗'ModelData.Create(Provider, string, UnixTime?, string)': not all code paths return a value
      • ⚠️ Timeout Issues
      • ⚠️ Receiving a “HTTP/1.1 400 Bad Request” Error?
    • FAQ
      • My OpenAI API free trial has ended or is inactive.
  • Quick Start
    • Get API Keys
      • OpenAI API Key Guide
      • Google API Key Guide
      • ElevenLabs API Key Guide
    • Text Generation
    • C# Object Generation
    • Image Generation
    • Sound Effect Generation
    • Text to Speech (TTS)
    • Speech to Text (STT)
    • Voice Changer
    • Audio Isolation
  • Pro Features
    • Generation Menu
      • Code Generators
        • C# Script Generator
        • Unity Component Generator
    • Editor Chat
    • Editor Vision (TTI, ITI)
    • Editor Speech (TTS)
    • Management Tools
      • Prompt History Viewer
      • AI Model Manager
      • TTS Voice Manager
      • OpenAI File Manager
      • OpenAI Assistant Manager
      • ElevenLabs Voice Library
  • Assistants API (OpenAI)
    • How it works
    • Creating custom functions
    • Creating assistants API
  • Advanced API Supports
    • OpenAI API
      • 💬Chat completions
      • 🖼️Image operations
      • 🗣️Text to speech
      • 🎙️Speech to text
        • Recording real-time in Unity
      • 💾Files
      • 🔎Embeddings
      • 🛡️Moderations
      • ⚙️Fine-tuning
    • Google API
      • 📝System instructions
      • 💬Text generation
      • ⚙️Fine-tuning
      • ▶️Fucntion calling
      • 🔎Embeddings
      • 🛡️Safety
      • 💻Code execution
    • ElevenLabs API
  • Legacy Documents
    • AI DevKit 1.0 - 2.0
      • AI DevKit 2.0
      • AI DevKit 1.0
      • Preperation
      • Event Handlers
      • Scriptable Toolkits
        • Chat Streamer
        • Image Generator
        • Voice Transcriber
        • Voice Generator
      • Editor Tools
Powered by GitBook
On this page
  • Moderation Operations Overview:
  • Sample Code for Moderation Requests:
  1. Advanced API Supports
  2. OpenAI API

Moderations

PreviousEmbeddingsNextFine-tuning

Last updated 10 months ago

Integrating OpenAI's content moderation capabilities into your Unity project enables you to automatically filter and review generated content for appropriateness, safety, and compliance with community guidelines. By leveraging OpenAI's advanced moderation models, you can maintain a safe and welcoming environment for users across various interactions within your applications.

For an in-depth understanding of the moderation capabilities, available models, and how to effectively implement them in your project, refer to the .

Moderation Operations Overview:

  • Content Moderation: Evaluate user-generated content, including text and images, against a set of content policies to identify potential issues such as offensive language, sensitive topics, or inappropriate material.

Sample Code for Moderation Requests:

Analyze text or images for inappropriate content, receiving a detailed report on any issues found.

var request = new ModerationRequest.Builder()
    .SetInput("I want to kill them.")
    .Build();

var result = await request.ExecuteAsync();

if (result.TryGetResult(out List<ModerationData> moderationData))
{
    foreach (var data in moderationData)
    {
        Debug.Log($"Flagged: {data.Flagged}");
        Debug.Log($"Category: {data.Category}");
        Debug.Log($"Score: {data.Score}");
    }
}

// Or you can just
Debug.Log(result);
from openai import OpenAI
client = OpenAI()

moderation = client.moderations.create(input="I want to kill them.")
print(moderation)

This example demonstrates how to create and execute a moderation request for either text or images. The result provides detailed feedback on whether the content is flagged for potential issues, along with specifics about the concerns identified.

Implementing Moderation in Unity using OpenAI:

To use OpenAI's moderation services within your Unity project, follow these steps:

  1. Prepare the Content: Collect the user-generated content (UGC) you intend to moderate. This can be text input from chat systems, comments, user profiles, or images uploaded by users.

  2. Create a Moderation Request: Utilize the ModerationRequest builder to prepare your request, including the UGC as the content to be moderated.

  3. Execute the Request: Send the moderation request to OpenAI's API and await the results. The response will indicate whether the content is appropriate or flagged, along with detailed information on the type of issues detected, if any.

  4. Review and Act: Based on the moderation results, take appropriate actions such as removing flagged content, alerting users, or requesting manual review for borderline cases.

🛡️
Moderations API Reference