updated app with error
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import sys
|
| 2 |
import os
|
|
|
|
| 3 |
|
| 4 |
# Add the current directory to the Python path
|
| 5 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
@@ -8,11 +9,23 @@ sys.path.append(current_dir)
|
|
| 8 |
import gradio as gr
|
| 9 |
from bot.chat import bot # Import the bot function from chat.py
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
gr.ChatInterface(
|
| 18 |
chat_interface,
|
|
|
|
| 1 |
import sys
|
| 2 |
import os
|
| 3 |
+
import logging
|
| 4 |
|
| 5 |
# Add the current directory to the Python path
|
| 6 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
| 9 |
import gradio as gr
|
| 10 |
from bot.chat import bot # Import the bot function from chat.py
|
| 11 |
|
| 12 |
+
# Set up logging
|
| 13 |
+
logging.basicConfig(level=logging.INFO)
|
| 14 |
+
logger = logging.getLogger(__name__)
|
| 15 |
+
|
| 16 |
+
async def chat_interface(message, history):
|
| 17 |
+
try:
|
| 18 |
+
history.append((message, None))
|
| 19 |
+
response = await bot(history)
|
| 20 |
+
history[-1] = (message, response[-1][1])
|
| 21 |
+
return "", history
|
| 22 |
+
except Exception as e:
|
| 23 |
+
logger.error(f"Error in chat_interface: {str(e)}")
|
| 24 |
+
burner_error_message = (
|
| 25 |
+
"Whoa there, playa pal! It seems the dust has clogged my circuits. "
|
| 26 |
+
"Let's take a deep breath and try that again. Radical self-reliance, remember?"
|
| 27 |
+
)
|
| 28 |
+
return "", history + [(message, burner_error_message)]
|
| 29 |
|
| 30 |
gr.ChatInterface(
|
| 31 |
chat_interface,
|