Spaces:
Sleeping
Sleeping
Tobias Geisler
commited on
Commit
·
c91ccb6
1
Parent(s):
7db7d27
improved logging
Browse files- tabs/create_chatbot.py +8 -3
tabs/create_chatbot.py
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from utils.utils import get_secret
|
| 3 |
from database import create_chatbot, filter_profanity
|
| 4 |
-
|
| 5 |
import logging
|
|
|
|
|
|
|
| 6 |
logging.basicConfig(level=logging.INFO)
|
| 7 |
logger = logging.getLogger(__name__)
|
| 8 |
|
| 9 |
CREATE_APP_PW = get_secret("CREATE_APP_PW")
|
| 10 |
|
| 11 |
def create_chatbot_interface(name, custom_instruction, password):
|
|
|
|
| 12 |
if password != CREATE_APP_PW:
|
|
|
|
| 13 |
return "Ungültiges Passwort. Erstellung des Chatbots fehlgeschlagen.", None, None
|
| 14 |
|
| 15 |
filtered_name = filter_profanity(name)
|
|
@@ -17,10 +21,11 @@ def create_chatbot_interface(name, custom_instruction, password):
|
|
| 17 |
|
| 18 |
try:
|
| 19 |
chatbot = create_chatbot(filtered_name, filtered_instruction)
|
|
|
|
| 20 |
return f"Chatbot erstellt mit ID: {chatbot.chatbot_id}", chatbot.chatbot_id, chatbot.name
|
| 21 |
except Exception as e:
|
| 22 |
-
logger.error(
|
| 23 |
-
return "Fehler bei der Erstellung des Chatbots", None, None
|
| 24 |
|
| 25 |
def create_chatbot_tab():
|
| 26 |
with gr.Group():
|
|
|
|
| 1 |
+
# create_chatbot.py
|
| 2 |
import gradio as gr
|
| 3 |
from utils.utils import get_secret
|
| 4 |
from database import create_chatbot, filter_profanity
|
|
|
|
| 5 |
import logging
|
| 6 |
+
|
| 7 |
+
# Setup logging
|
| 8 |
logging.basicConfig(level=logging.INFO)
|
| 9 |
logger = logging.getLogger(__name__)
|
| 10 |
|
| 11 |
CREATE_APP_PW = get_secret("CREATE_APP_PW")
|
| 12 |
|
| 13 |
def create_chatbot_interface(name, custom_instruction, password):
|
| 14 |
+
logger.info("Creating chatbot with name: %s", name)
|
| 15 |
if password != CREATE_APP_PW:
|
| 16 |
+
logger.warning("Invalid password provided for chatbot creation.")
|
| 17 |
return "Ungültiges Passwort. Erstellung des Chatbots fehlgeschlagen.", None, None
|
| 18 |
|
| 19 |
filtered_name = filter_profanity(name)
|
|
|
|
| 21 |
|
| 22 |
try:
|
| 23 |
chatbot = create_chatbot(filtered_name, filtered_instruction)
|
| 24 |
+
logger.info("Chatbot created successfully with ID: %s", chatbot.chatbot_id)
|
| 25 |
return f"Chatbot erstellt mit ID: {chatbot.chatbot_id}", chatbot.chatbot_id, chatbot.name
|
| 26 |
except Exception as e:
|
| 27 |
+
logger.error("Error creating chatbot: %s", str(e))
|
| 28 |
+
return f"Fehler bei der Erstellung des Chatbots: {str(e)}", None, None
|
| 29 |
|
| 30 |
def create_chatbot_tab():
|
| 31 |
with gr.Group():
|