Bndo commited on
Commit
d5c35d5
·
verified ·
1 Parent(s): ae59c6d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -1
app.py CHANGED
@@ -1,3 +1,29 @@
1
  import gradio as gr
2
 
3
- gr.load("models/HuggingFaceH4/zephyr-7b-beta").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
+ # Define the chatbot function
4
+ def chat_response(history, user_input):
5
+ """Handles chatbot interactions."""
6
+ if not user_input.strip():
7
+ return history + [("User", user_input), ("Bot", "Please enter a valid message.")]
8
+
9
+ response = f"You said: {user_input}" # Replace this with actual chatbot logic (e.g., OpenAI API)
10
+ history.append({"role": "user", "content": user_input})
11
+ history.append({"role": "assistant", "content": response})
12
+
13
+ return history, ""
14
+
15
+ # Initialize Gradio chatbot with the correct type
16
+ with gr.Blocks() as demo:
17
+ gr.Markdown("## 🚀 AI Chatbot - Powered by Gradio")
18
+
19
+ chatbot = gr.Chatbot(type="messages") # ✅ Fix: Use 'messages' format
20
+ user_input = gr.Textbox(label="Your Message")
21
+ submit_button = gr.Button("Send")
22
+
23
+ # Button click or Enter key submits the message
24
+ submit_button.click(chat_response, inputs=[chatbot, user_input], outputs=[chatbot, user_input])
25
+ user_input.submit(chat_response, inputs=[chatbot, user_input], outputs=[chatbot, user_input])
26
+
27
+ # Run the Gradio app
28
+ if __name__ == "__main__":
29
+ demo.launch(share=True) # 🚀 Allows sharing via public Gradio link