|
import os |
|
import sys |
|
import gradio as gr |
|
|
|
|
|
current_dir = os.path.dirname(os.path.abspath(__file__)) |
|
sys.path.append(current_dir) |
|
|
|
|
|
|
|
if 'GROQ_API_KEY' not in os.environ: |
|
raise EnvironmentError("GROQ_API_KEY is not set in the environment variables or .env file") |
|
|
|
|
|
os.environ['GROQ_API_KEY'] = os.getenv('GROQ_API_KEY') |
|
|
|
|
|
from bot.chat import chat_interface |
|
|
|
|
|
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 = """ |
|
<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() |