Storyblade commited on
Commit
786dace
·
verified ·
1 Parent(s): dacd62f

requirements.txt

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import openai
3
+
4
+ # Initialize OpenAI API (Replace with your API Key)
5
+ openai.api_key = "your_openai_api_key"
6
+
7
+ def chatbot_response(user_input):
8
+ response = openai.ChatCompletion.create(
9
+ model="gpt-3.5-turbo",
10
+ messages=[{"role": "system", "content": "You are a helpful AI assistant."},
11
+ {"role": "user", "content": user_input}]
12
+ )
13
+ return response["choices"][0]["message"]["content"]
14
+
15
+ # Gradio Interface
16
+ iface = gr.Interface(fn=chatbot_response,
17
+ inputs="text",
18
+ outputs="text",
19
+ title="AI Chatbot",
20
+ description="A simple AI chatbot running on Hugging Face Spaces.")
21
+
22
+ iface.launch()