Spaces:
Sleeping
Sleeping
Tobias Geisler
commited on
Commit
·
e6d4d36
1
Parent(s):
521cb12
more extensive error handling
Browse files- tabs/chat.py +13 -2
tabs/chat.py
CHANGED
|
@@ -11,6 +11,15 @@ def load_chatbot(chatbot_id):
|
|
| 11 |
logger.info(f"Attempting to load chatbot with ID: {chatbot_id}")
|
| 12 |
try:
|
| 13 |
chatbot = get_chatbot(chatbot_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
if chatbot:
|
| 15 |
logger.info(f"Chatbot {chatbot_id} loaded successfully")
|
| 16 |
return (
|
|
@@ -27,7 +36,7 @@ def load_chatbot(chatbot_id):
|
|
| 27 |
gr.update(value="Ungültige Chatbot-ID oder Chatbot nicht aktiv.")
|
| 28 |
)
|
| 29 |
except Exception as e:
|
| 30 |
-
logger.error(f"Error
|
| 31 |
return (
|
| 32 |
gr.update(value="# Chatbot\n\nWillkommen beim Chatbot"),
|
| 33 |
gr.update(value="", visible=True),
|
|
@@ -43,12 +52,14 @@ def load_chatbot_with_timeout(chatbot_id, timeout=5):
|
|
| 43 |
return result
|
| 44 |
except concurrent.futures.TimeoutError:
|
| 45 |
logger.error(f"Timeout while loading chatbot {chatbot_id}")
|
| 46 |
-
|
| 47 |
gr.update(value="# Chatbot\n\nWillkommen beim Chatbot"),
|
| 48 |
gr.update(value="", visible=True),
|
| 49 |
gr.update(value=""),
|
| 50 |
gr.update(value="Zeitüberschreitung beim Laden des Chatbots.")
|
| 51 |
)
|
|
|
|
|
|
|
| 52 |
except Exception as e:
|
| 53 |
logger.error(f"Unexpected error while loading chatbot {chatbot_id}: {str(e)}")
|
| 54 |
return (
|
|
|
|
| 11 |
logger.info(f"Attempting to load chatbot with ID: {chatbot_id}")
|
| 12 |
try:
|
| 13 |
chatbot = get_chatbot(chatbot_id)
|
| 14 |
+
except Exception as e:
|
| 15 |
+
logger.error(f"Error loading chatbot {chatbot_id}: {str(e)}")
|
| 16 |
+
return (
|
| 17 |
+
gr.update(value="# Chatbot\n\nWillkommen beim Chatbot"),
|
| 18 |
+
gr.update(value="", visible=True),
|
| 19 |
+
gr.update(value=""),
|
| 20 |
+
gr.update(value=f"Ein Fehler ist aufgetreten: {str(e)}")
|
| 21 |
+
)
|
| 22 |
+
try:
|
| 23 |
if chatbot:
|
| 24 |
logger.info(f"Chatbot {chatbot_id} loaded successfully")
|
| 25 |
return (
|
|
|
|
| 36 |
gr.update(value="Ungültige Chatbot-ID oder Chatbot nicht aktiv.")
|
| 37 |
)
|
| 38 |
except Exception as e:
|
| 39 |
+
logger.error(f"Error filling chatbot fields for {chatbot_id}: {str(e)}")
|
| 40 |
return (
|
| 41 |
gr.update(value="# Chatbot\n\nWillkommen beim Chatbot"),
|
| 42 |
gr.update(value="", visible=True),
|
|
|
|
| 52 |
return result
|
| 53 |
except concurrent.futures.TimeoutError:
|
| 54 |
logger.error(f"Timeout while loading chatbot {chatbot_id}")
|
| 55 |
+
result = (
|
| 56 |
gr.update(value="# Chatbot\n\nWillkommen beim Chatbot"),
|
| 57 |
gr.update(value="", visible=True),
|
| 58 |
gr.update(value=""),
|
| 59 |
gr.update(value="Zeitüberschreitung beim Laden des Chatbots.")
|
| 60 |
)
|
| 61 |
+
gr.refresh() # Force UI refresh
|
| 62 |
+
return result
|
| 63 |
except Exception as e:
|
| 64 |
logger.error(f"Unexpected error while loading chatbot {chatbot_id}: {str(e)}")
|
| 65 |
return (
|