Okuhle commited on
Commit
28b1aee
1 Parent(s): a2692b3
.idea/.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
.idea/chatgpthugging.iml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="PYTHON_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$" />
5
+ <orderEntry type="inheritedJdk" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
+ </component>
8
+ </module>
.idea/inspectionProfiles/Project_Default.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
5
+ <option name="ignoredPackages">
6
+ <value>
7
+ <list size="1">
8
+ <item index="0" class="java.lang.String" itemvalue="MarkupSafe" />
9
+ </list>
10
+ </value>
11
+ </option>
12
+ </inspection_tool>
13
+ </profile>
14
+ </component>
.idea/inspectionProfiles/profiles_settings.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <settings>
3
+ <option name="USE_PROJECT_PROFILE" value="false" />
4
+ <version value="1.0" />
5
+ </settings>
6
+ </component>
.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
4
+ </project>
.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/chatgpthugging.iml" filepath="$PROJECT_DIR$/.idea/chatgpthugging.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import openai
3
+ import gradio as gr
4
+
5
+ openai.api_key = "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"
6
+
7
+ start_sequence = "\nAI:"
8
+ restart_sequence = "\nHuman: "
9
+
10
+ prompt = ""
11
+
12
+ def openai_create(prompt):
13
+
14
+ response = openai.Completion.create(
15
+ model="text-davinci-003",
16
+ prompt=prompt,
17
+ temperature=0.9,
18
+ max_tokens=4000-int(len(prompt)),
19
+ top_p=1,
20
+ frequency_penalty=0,
21
+ presence_penalty=0.6,
22
+ stop=[" Human:", " AI:"]
23
+ )
24
+
25
+ return response.choices[0].text
26
+
27
+
28
+
29
+ def chatgpt_clone(input, history):
30
+ history = history or []
31
+ s = list(sum(history, ()))
32
+ s.append(input)
33
+ inp = ' '.join(s)
34
+ output = openai_create(inp)
35
+ history.append((input, output))
36
+ return history, history
37
+
38
+
39
+ block = gr.Blocks()
40
+
41
+
42
+ with block:
43
+ gr.Markdown("""<h1><center>Answer Your Questions By GPT</center></h1>
44
+ """)
45
+
46
+ chatbot = gr.Chatbot()
47
+ message = gr.Textbox(placeholder=prompt)
48
+ state = gr.State()
49
+ submit = gr.Button("SEND")
50
+ submit.click(chatgpt_clone, inputs=[message, state], outputs=[chatbot, state])
51
+
52
+ block.launch(share= True)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ openai
2
+ gradio