baconxfy commited on
Commit
71fc85b
1 Parent(s): b56ff00

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +24 -0
main.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import gradio as gr
3
+
4
+ openai.api_key = "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"
5
+
6
+
7
+
8
+ def chatbot(text):
9
+ return openai.Completion.create(
10
+ engine="text-davinci-003",
11
+ prompt=text,
12
+ max_tokens = 1024,
13
+ n=1,
14
+ temperature=0.5,
15
+ ).choices[0].text.strip()
16
+
17
+ def gradio_interface(prompt, history=[]):
18
+ output = chatbot(prompt)
19
+ history.append((prompt,output))
20
+ return history, history
21
+
22
+ gr.Interface(fn = gradio_interface,
23
+ inputs = ["text", 'state'],
24
+ outputs = ["chatbot", 'state']).launch(debug = False, share=True)