Gopala Krishna commited on
Commit
6227b42
·
1 Parent(s): 0d8e3b5

initial Commit

Browse files
.vs/ContentModeration/FileContentIndex/166bc59b-1bfd-4c9b-b3a4-70c8e4bb1fd7.vsidx ADDED
Binary file (202 Bytes). View file
 
.vs/ContentModeration/FileContentIndex/6907054c-6fa5-4516-8155-30250f9b9c45.vsidx ADDED
Binary file (4.78 kB). View file
 
.vs/ContentModeration/FileContentIndex/b771ed29-d4bf-4799-85b3-74b832443376.vsidx ADDED
Binary file (272 Bytes). View file
 
.vs/ContentModeration/FileContentIndex/read.lock ADDED
File without changes
.vs/ContentModeration/v17/.wsuo ADDED
Binary file (22.5 kB). View file
 
.vs/VSWorkspaceState.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "ExpandedNodes": [
3
+ ""
4
+ ],
5
+ "SelectedNode": "\\C:\\Python\\Programs\\Gradio\\HuggingSpace\\ContentModeration",
6
+ "PreviewInSolutionExplorer": false
7
+ }
.vs/slnx.sqlite ADDED
Binary file (90.1 kB). View file
 
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import openai
3
+ import gradio as gr
4
+
5
+ openai.api_key = os.environ["OPENAPI_API_KEY"]
6
+
7
+ messages = [
8
+ {"role": "system", "content": "My AI Assistant"},
9
+ ]
10
+
11
+ def chatbot(input):
12
+ if input:
13
+ messages.append({"role": "user", "content": input})
14
+ response = openai.Moderation.create(
15
+ messages=messages
16
+ )
17
+ reply = response["results"][0].flagged
18
+ messages.append({"role": "assistant", "content": reply})
19
+ return reply
20
+
21
+ inputs = gr.inputs.Textbox(lines=7, label="Query")
22
+ outputs = gr.outputs.Textbox(label="Response")
23
+
24
+ gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="",
25
+ theme="compact").launch()
26
+
27
+
28
+
29
+
30
+
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ openai