Spaces:
				
			
			
	
			
			
		Runtime error
		
	
	
	
			
			
	
	
	
	
		
		
		Runtime error
		
	Commit 
							
							·
						
						9810626
	
1
								Parent(s):
							
							ccb34c7
								
Create app.py
Browse files
    	
        app.py
    ADDED
    
    | @@ -0,0 +1,19 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            openai.api_key = os.environ['OPENAI_API_KEY']
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            def moderation(text):
         | 
| 4 | 
            +
                response = openai.Moderation.create(input=text)
         | 
| 5 | 
            +
                output = response["results"][0]
         | 
| 6 | 
            +
                return output
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            iface = gr.Interface(
         | 
| 9 | 
            +
                fn=moderation,
         | 
| 10 | 
            +
                inputs=gr.inputs.Textbox(lines=10, label="Text"),
         | 
| 11 | 
            +
                outputs="text",
         | 
| 12 | 
            +
                title="OpenAI Moderation API",
         | 
| 13 | 
            +
                description="This is a demo of the OpenAI Moderation API. Enter text in the box below and click submit to see the output.",
         | 
| 14 | 
            +
                allow_flagging=False,
         | 
| 15 | 
            +
                layout="vertical",
         | 
| 16 | 
            +
                theme="huggingface",
         | 
| 17 | 
            +
            )
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            iface.launch()
         |