BurnerBot / app.py
Abhlash's picture
removed dotenv from app
aae12f6 verified
raw
history blame
3.12 kB
import os
import sys
import gradio as gr
# Add the current directory to the Python path
current_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.append(current_dir)
# Check if GROQ_API_KEY is set
if 'GROQ_API_KEY' not in os.environ:
raise EnvironmentError("GROQ_API_KEY is not set in the environment variables or .env file")
# Set GROQ_API_KEY as a global variable
os.environ['GROQ_API_KEY'] = os.getenv('GROQ_API_KEY')
# Now import the chat_interface
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;
}
"""
# Custom HTML for header and footer
custom_html = """
<div style="text-align: center; max-width: 800px; margin: 0 auto;">
<h1 style="color: #ff6b35; font-size: 3em; margin-bottom: 10px;">BurnerBot</h1>
<p style="color: #ffffff; font-size: 1.2em; margin-bottom: 20px;">Your dusty digital companion for all things Burning Man!</p>
</div>
"""
with gr.Blocks(css=custom_css) as demo:
gr.HTML(custom_html)
chatbot = gr.Chatbot(
[],
elem_id="chatbot",
bubble_full_width=False,
avatar_images=(None, "https://i.imgur.com/nAcdSry.png"),
height=400
)
msg = gr.Textbox(
show_label=False,
placeholder="Ask me anything about Burning Man...",
container=False
)
clear = gr.Button("Clear")
def user(user_message, history):
return "", history + [[user_message, None]]
def bot(history):
user_message = history[-1][0]
bot_message = chat_interface(user_message, history[:-1])
history[-1][1] = bot_message
return history
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! )'(
"""
)
demo.launch()