BurnerBot / app.py
Abhlash's picture
updated app
ffd0494 verified
raw
history blame
2.79 kB
import os
import gradio as gr
import asyncio
import logging
# Set up logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Import chat_interface after environment variables are loaded
from bot.chat import chat_interface
# Custom CSS for Burning Man theme
custom_css = """
body {
background-color: #f4a460;
background-image: url('https://i.imgur.com/JZjMiZR.jpg');
background-size: cover;
background-attachment: fixed;
font-family: 'Roboto', sans-serif;
}
.container {
max-width: 800px !important;
margin: auto;
background-color: rgba(0, 0, 0, 0.7);
border-radius: 15px;
padding: 20px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}
.gr-button {
background-color: #ff6b35 !important;
border: none !important;
}
.gr-button:hover {
background-color: #ff8c61 !important;
}
.gr-input {
border-color: #ff6b35 !important;
}
.gr-input:focus {
border-color: #ff8c61 !important;
box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.25) !important;
}
.gr-box {
border-radius: 15px !important;
background-color: rgba(255, 255, 255, 0.1) !important;
}
.gr-padded {
padding: 15px !important;
}
"""
async def bot(history):
try:
user_message = history[-1][0]
bot_message = await chat_interface(user_message, history[:-1])
history[-1][1] = bot_message
return history
except Exception as e:
logger.error(f"Error in bot function: {str(e)}")
history[-1][1] = "Oops! Something went wrong. Please try again later."
return history
with gr.Blocks(css=custom_css) as demo:
gr.HTML("<h1 style='text-align: center; color: #ff6b35;'>BurnerBot</h1>")
gr.HTML("<p style='text-align: center; color: #ffffff;'>Your dusty digital companion for all things Burning Man!</p>")
chatbot = gr.Chatbot(height=400)
msg = gr.Textbox(label="Ask about Burning Man", placeholder="What would you like to know about Burning Man?")
clear = gr.Button("Clear Chat")
async def user(user_message, history):
return "", history + [[user_message, None]]
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
bot, chatbot, chatbot
)
clear.click(lambda: None, None, chatbot, queue=False)
gr.Markdown(
"""
### πŸ”₯ Welcome to the Playa, Burner! πŸ”₯
Ask me about:
- πŸ“… Event dates and tickets
- πŸ•οΈ Survival guide and packing tips
- 🌟 The 10 Principles
- 🎨 Art installations and theme camps
- 🚲 Transportation and arrival
- And much more!
Remember, participation is key. Let's co-create an amazing experience! )'(
"""
)
if __name__ == "__main__":
demo.queue()
demo.launch()