File size: 2,787 Bytes
e94e9ff c5329f9 ff12aa6 135d188 ff12aa6 e94e9ff cc7a125 ff12aa6 c5329f9 ff12aa6 c5329f9 ff12aa6 c5329f9 ff12aa6 c5329f9 53d762c c5329f9 ff12aa6 ffd0494 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
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() |