mrprycep069 commited on
Commit
ad3c865
1 Parent(s): 97200ab

ChatGPT-Clone

Browse files
Files changed (1) hide show
  1. app.py +86 -0
app.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """ChatGPT Clone & Text to Image Generator.ipynb
3
+
4
+ Automatically generated by Colaboratory.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1OoArwT6lYDyxjBUGRznDfFv1xQF8szJV
8
+ """
9
+
10
+ !pip install gradio
11
+
12
+ import gradio as gr
13
+
14
+ def greet(name):
15
+ return "Hello " + name + "!"
16
+
17
+ demo = gr.Interface(fn=greet, inputs="text", outputs="text")
18
+
19
+ demo.launch()
20
+
21
+
22
+
23
+
24
+
25
+ !pip install -Uqq ipdb
26
+
27
+ import ipdb
28
+
29
+ # Commented out IPython magic to ensure Python compatibility.
30
+ # %pdb on
31
+
32
+ import gradio as gr
33
+
34
+ def greet(name):
35
+ return "Hello " + name + "!"
36
+
37
+ demo = gr.Interface(fn=greet, inputs="text", outputs="text")
38
+
39
+ demo.launch()
40
+
41
+ import gradio as gr
42
+
43
+ def greet(name):
44
+ return "Hello " + name + "!"
45
+
46
+ demo = gr.Interface(fn=greet, inputs="text", outputs="text")
47
+
48
+ demo.launch()
49
+
50
+ import gradio as gr
51
+
52
+ def greet(name):
53
+ return "Hello " + name + "!"
54
+
55
+ demo = gr.Interface(fn=greet, inputs="text", outputs="text")
56
+
57
+ demo.launch(share=True)
58
+
59
+ !pip install openai
60
+
61
+ # Commented out IPython magic to ensure Python compatibility.
62
+ import openai
63
+ import gradio
64
+ import ipdb
65
+
66
+ # %pdb on
67
+ openai.api_key = "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"
68
+
69
+ menulist = [{"role": "system", "content": "You are ChatGPT Clone AI Robot"}]
70
+
71
+ def ChatGPTclone(input):
72
+ menulist.append({"role": "user", "content": input})
73
+ response = openai.ChatCompletion.create(
74
+ model = "gpt-3.5-turbo",
75
+ messages = menulist
76
+ )
77
+ reply = response['choices'][0]['message']['content']
78
+ menulist.append({"role": "user", "content": reply})
79
+ return reply
80
+
81
+
82
+ def application():
83
+ app = gradio.Interface(fn=ChatGPTclone, inputs="text", outputs="text", title="ChatGPT Clone")
84
+ return app.launch(share=True)
85
+
86
+ application()