Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
# Function to process the input
|
| 4 |
+
def chatbot_response(user_input):
|
| 5 |
+
# Simple logic for chatbot (e.g., greeting or keywords detection)
|
| 6 |
+
if "hello" in user_input.lower():
|
| 7 |
+
return "Hello! How can I help you today?"
|
| 8 |
+
elif "how are you" in user_input.lower():
|
| 9 |
+
return "I'm doing great, thank you for asking!"
|
| 10 |
+
else:
|
| 11 |
+
return "I'm sorry, I didn't understand that. Can you rephrase?"
|
| 12 |
+
|
| 13 |
+
# Define the Gradio interface
|
| 14 |
+
def create_interface():
|
| 15 |
+
# Gradio interface setup
|
| 16 |
+
with gr.Blocks() as demo:
|
| 17 |
+
gr.Markdown("## Chatbot Application")
|
| 18 |
+
with gr.Row():
|
| 19 |
+
chat_box = gr.Chatbot()
|
| 20 |
+
input_box = gr.Textbox(placeholder="Type a message...")
|
| 21 |
+
|
| 22 |
+
input_box.submit(chatbot_response, input_box, chat_box)
|
| 23 |
+
|
| 24 |
+
return demo
|
| 25 |
+
|
| 26 |
+
# Launch the interface
|
| 27 |
+
interface = create_interface()
|
| 28 |
+
|
| 29 |
+
# Launch Gradio app on Hugging Face Spaces
|
| 30 |
+
interface.launch()
|