BurnerBot / app.py
Abhlash's picture
updated app with error
da67b4c verified
raw
history blame
1.48 kB
import sys
import os
import logging
# Add the current directory to the Python path
current_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.append(current_dir)
import gradio as gr
from bot.chat import bot # Import the bot function from chat.py
# Set up logging
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()