Samuelblue commited on
Commit
002afcd
·
1 Parent(s): fb4368a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pip install openai
2
+ import gradio as gr
3
+ import openai
4
+
5
+ # Initialize the API key
6
+ openai.api_key = "YOUR_API_KEY"
7
+
8
+ def generate_text(prompt):
9
+ completions = openai.Completion.create(
10
+ engine="text-davinci-002",
11
+ prompt=prompt,
12
+ max_tokens=1024,
13
+ n=1,
14
+ stop=None,
15
+ temperature=0.5,
16
+ )
17
+
18
+ message = completions.choices[0].text
19
+ return message.strip()
20
+
21
+ inputs = gr.inputs.Textbox(lines=1, label="Enter your message:")
22
+ outputs = gr.outputs.Textbox(label="Response:")
23
+
24
+ interface = gr.Interface(
25
+ generate_text,
26
+ inputs,
27
+ outputs,
28
+ title="GPT-3 Chatbot",
29
+ description="A chatbot powered by GPT-3"
30
+ )
31
+
32
+ interface.launch()
33
+