Spaces:
Runtime error
Runtime error
import os | |
import gradio as gr | |
import openai | |
openai.api_key = os.environ['OPENAI_API_KEY'] | |
def moderation(text): | |
response = openai.Moderation.create(input=text) | |
output = response["results"][0] | |
return output | |
iface = gr.Interface( | |
fn=moderation, | |
inputs=gr.inputs.Textbox(lines=10, label="Text"), | |
outputs="text", | |
title="OpenAI Moderation API", | |
description="This is a demo of the OpenAI Moderation API. Enter text in the box below and click submit to see the output.", | |
allow_flagging=False, | |
layout="vertical", | |
theme="huggingface", | |
) | |
iface.launch() |