Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
# Simple rule-based chatbot logic
|
| 4 |
+
def chatbot_response(message):
|
| 5 |
+
message = message.lower()
|
| 6 |
+
|
| 7 |
+
if any(word in message for word in ["shipping", "deliver", "arrive"]):
|
| 8 |
+
return "Shipping usually takes 3-5 business days. You'll receive a tracking number via email."
|
| 9 |
+
elif any(word in message for word in ["return", "refund", "send back"]):
|
| 10 |
+
return "You can return the SmartHome Hub Pro within 30 days of delivery."
|
| 11 |
+
elif any(word in message for word in ["product", "smarthome", "hub"]):
|
| 12 |
+
return "The SmartHome Hub Pro is an AI-powered device that connects and automates all your smart home gadgets."
|
| 13 |
+
elif any(word in message for word in ["issue", "problem", "trouble", "not working"]):
|
| 14 |
+
return "Try restarting the device. If problems persist, contact our support team at [email protected]."
|
| 15 |
+
elif message in ["exit", "quit", "bye"]:
|
| 16 |
+
return "Goodbye! Thanks for chatting with us."
|
| 17 |
+
else:
|
| 18 |
+
return "I'm not sure how to help with that. Can you ask about shipping, returns, or the product?"
|
| 19 |
+
|
| 20 |
+
iface = gr.Interface(
|
| 21 |
+
fn=chatbot_response,
|
| 22 |
+
inputs=gr.Textbox(placeholder="Ask me about the SmartHome Hub Pro..."),
|
| 23 |
+
outputs="text",
|
| 24 |
+
title="Tech Gadget Chatbot",
|
| 25 |
+
description="Ask about product features, returns, or shipping."
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
if __name__ == "__main__":
|
| 29 |
+
iface.launch()
|