akhilhsingh commited on
Commit
c8a83e9
1 Parent(s): 9c63719

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import openai
3
+
4
+ # Replace the placeholder text with your actual OpenAI API key
5
+ openai.api_key = "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"
6
+
7
+ def chat_with_gpt3(prompt):
8
+ response = openai.ChatCompletion.create(
9
+ model="gpt-3.5-turbo",
10
+ messages=[
11
+ {"role": "system", "content": "You are a helpful assistant."},
12
+ {"role": "user", "content": prompt},
13
+ ],
14
+ )
15
+ return response.choices[0].message["content"]
16
+
17
+ interface = gr.Interface(
18
+ fn=chat_with_gpt3,
19
+ inputs=gr.Textbox(lines=2, placeholder="Enter your message here..."),
20
+ outputs="text",
21
+ title="Akhil's Basic Chatbot (powered by GPT-3.5 Turbo)",
22
+ description="This is a chatbot using OpenAI's GPT-3.5 Turbo. Ask it anything!",
23
+ )
24
+
25
+ if __name__ == "__main__":
26
+ interface.launch(share=True)