|
import sys |
|
import os |
|
import logging |
|
|
|
|
|
current_dir = os.path.dirname(os.path.abspath(__file__)) |
|
sys.path.append(current_dir) |
|
|
|
import gradio as gr |
|
from bot.chat import bot |
|
|
|
|
|
logging.basicConfig(level=logging.INFO) |
|
logger = logging.getLogger(__name__) |
|
|
|
async def chat_interface(message, history): |
|
try: |
|
history.append((message, None)) |
|
response = await bot(history) |
|
history[-1] = (message, response[-1][1]) |
|
return "", history |
|
except Exception as e: |
|
logger.error(f"Error in chat_interface: {str(e)}") |
|
burner_error_message = ( |
|
"Whoa there, playa pal! It seems the dust has clogged my circuits. " |
|
"Let's take a deep breath and try that again. Radical self-reliance, remember?" |
|
) |
|
return "", history + [(message, burner_error_message)] |
|
|
|
gr.ChatInterface( |
|
chat_interface, |
|
chatbot=gr.Chatbot(height=300), |
|
textbox=gr.Textbox(placeholder="Ask me anything about Burning Man!", container=False), |
|
title="BurnerBot", |
|
description="Chat with me about Burning Man! I can help with event dates, packing lists, principles, and more!", |
|
theme="soft", |
|
examples=["When is Burning Man this year?", "What are the 10 principles?", "Can you give me a packing list?"], |
|
cache_examples=False, |
|
retry_btn=None, |
|
undo_btn="Delete Previous", |
|
clear_btn="Clear", |
|
).launch() |
|
|