File size: 982 Bytes
461a1fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import gradio as gr
from openai import OpenAI

def Moderation(prompt,  api_key):
    if api_key == '':
        output= gr.Textbox("*** Please provide API Key ***")
    else:
        try:
            client = OpenAI(api_key= api_key)
            response = client.moderations.create(input=prompt)
            output = response.results[0]
        except :
           output = gr.Textbox("*** Please check your API-Key and try again ***")
    return output

title = "Enter your Prompt"
description = """
<img src = "https://upload.wikimedia.org/wikipedia/commons/4/4d/OpenAI_Logo.svg" width=300px>



# Provide OpenAI API Key

# Moderation tool : A fine-tuned model that can detect whether text may be sensitive or unsafe.

 
"""

gr.Interface(    
    Moderation,
    [
      gr.Textbox(label="Enter your Prompt"),
      gr.Textbox(type = 'password',label="Enter your API-Key", placeholder="API-Key", lines=1),
    ]
,outputs="text",
title=title,
description=description,


).launch()