Abhlash commited on
Commit
da67b4c
·
verified ·
1 Parent(s): c928b83

updated app with error

Browse files
Files changed (1) hide show
  1. app.py +18 -5
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
- def chat_interface(message, history):
12
- history.append((message, None))
13
- response = bot(history)
14
- history[-1] = (message, response[-1][1])
15
- return "", history
 
 
 
 
 
 
 
 
 
 
 
 
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,