File size: 3,118 Bytes
e94e9ff c5329f9 135d188 ea4e5e4 135d188 ea4e5e4 e94e9ff cc7a125 c5329f9 da67b4c c5329f9 53d762c c5329f9 |
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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
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() |