Spaces:
Runtime error
Runtime error
Gopala Krishna
commited on
Commit
·
66cd45e
1
Parent(s):
88ede6c
clean code
Browse files- .vs/ContentModeration/v17/.wsuo +0 -0
- app.py +6 -11
.vs/ContentModeration/v17/.wsuo
CHANGED
Binary files a/.vs/ContentModeration/v17/.wsuo and b/.vs/ContentModeration/v17/.wsuo differ
|
|
app.py
CHANGED
@@ -5,20 +5,15 @@ import gradio as gr
|
|
5 |
openai.api_key = os.environ["OPENAPI_API_KEY"]
|
6 |
|
7 |
def chatbot(input):
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
return
|
14 |
|
15 |
inputs = gr.inputs.Textbox(lines=7, label="Query")
|
16 |
outputs = gr.outputs.Textbox(label="Response")
|
17 |
|
18 |
gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="",
|
19 |
theme="compact").launch()
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
5 |
openai.api_key = os.environ["OPENAPI_API_KEY"]
|
6 |
|
7 |
def chatbot(input):
|
8 |
+
response = openai.Moderation.create(input=input)
|
9 |
+
reply = response["results"][0].flagged
|
10 |
+
if reply == True:
|
11 |
+
return "This content should be moderated"
|
12 |
+
else:
|
13 |
+
return "This content doesn't need moderation"
|
14 |
|
15 |
inputs = gr.inputs.Textbox(lines=7, label="Query")
|
16 |
outputs = gr.outputs.Textbox(label="Response")
|
17 |
|
18 |
gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="",
|
19 |
theme="compact").launch()
|
|
|
|
|
|
|
|
|
|