fgvsdfvdbsfdvsadvf commited on
Commit
4a56e7d
·
verified ·
1 Parent(s): cab5a94

Upload chatbot.py

Browse files
Files changed (1) hide show
  1. chatbot.py +25 -0
chatbot.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import gradio as gr
3
+
4
+ # Set your OpenAI API key
5
+ openai.api_key = "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"
6
+
7
+ # Define the chatbot function
8
+ def chatbot(input_text):
9
+ response = openai.ChatCompletion.create(
10
+ model="gpt-3.5-turbo",
11
+ messages=[{"role": "user", "content": input_text}]
12
+ )
13
+ return response['choices'][0]['message']['content']
14
+
15
+ # Create a Gradio interface
16
+ interface = gr.Interface(
17
+ fn=chatbot,
18
+ inputs="text",
19
+ outputs="text",
20
+ title="ChatGPT Clone",
21
+ description="A simple chatbot powered by OpenAI's GPT-3.5 Turbo."
22
+ )
23
+
24
+ # Launch the interface
25
+ interface.launch()