Spaces:
Sleeping
Sleeping
Upload 3 files
Browse filesFiles changed (3)
- README.md+50-12
- app.pyAdded+64
- requirements.txtAdded+1
123456789101112---title: Flaskbotemoji: 🌖colorFrom: indigocolorTo: indigosdk: gradiosdk_version: 5.49.1app_file: app.pypinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950---title: AI Chatbotemoji: 🤖colorFrom: bluecolorTo: purplesdk: gradiosdk_version: 4.0.0app_file: app.pypinned: falselicense: mitshort_description: A simple AI chatbot built with Gradio---# AI ChatbotA simple conversational AI chatbot built with Gradio. This chatbot can respond to basic greetings and engage in simple conversations.## Features- Interactive chat interface- Simple pattern-based responses- Clean and modern UI- Easy to use and deploy## How to Use1. Type your message in the text box2. Click "Send" or press Enter3. The chatbot will respond based on your input4. Try saying "hello" or "bye" to see the chatbot in action!## Local DevelopmentTo run this chatbot locally:1. Install the requirements:```bashpip install -r requirements.txt```2. Run the application:```bashpython app.py```3. Open your browser and go to `http://localhost:7860`## DeploymentThis app is designed to be deployed on Hugging Face Spaces. Simply push this repository to a Hugging Face Space and it will automatically deploy with Gradio.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364# app.py
import gradio as gr
def chatbot_response(message, history):
"""Process user input and return chatbot response"""
user_input = message.lower()
if "hello" in user_input:
return "Hello there! How can I help you today?"
elif "bye" in user_input:
return "Goodbye! 👋"
else:
return f"You said: {message}. I'm still learning!"
# Create Gradio interface
with gr.Blocks(title="AI Chatbot", theme=gr.themes.Soft()) as demo:
gr.Markdown("# 🤖 AI Chatbot")
gr.Markdown("Welcome to my simple AI chatbot! Try saying 'hello' or 'bye'.")
# Chat interface
chatbot = gr.Chatbot(
label="Chat",
height=400,
show_label=True,
container=True,
bubble_full_width=False
)
# Text input
msg = gr.Textbox(
label="Your message",
placeholder="Type your message here...",
lines=1,
max_lines=3,
show_label=True
)
# Submit button
submit_btn = gr.Button("Send", variant="primary")
# Clear button
clear_btn = gr.Button("Clear", variant="secondary")
# Event handlers
def user(user_message, history):
return "", history + [[user_message, None]]
def bot(history):
user_message = history[-1][0]
bot_message = chatbot_response(user_message, history)
history[-1][1] = bot_message
return history
# Connect the interface
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
bot, chatbot, chatbot
)
submit_btn.click(user, [msg, chatbot], [msg, chatbot], queue=False).then(
bot, chatbot, chatbot
)
clear_btn.click(lambda: None, None, chatbot, queue=False)
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", server_port=7860)1gradio>=4.0.0README.md+50-12
app.pyAdded+64
requirements.txtAdded+1