File size: 1,059 Bytes
71736e8
 
 
 
 
 
 
 
9e991a9
71736e8
 
 
 
 
9e991a9
71736e8
 
9e991a9
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from utils.utils import get_secret
from database import create_chatbot, filter_profanity

CREATE_APP_PW = get_secret("CREATE_APP_PW")

def create_chatbot_interface(name, custom_instruction, password):
    if password != CREATE_APP_PW:
        return "Ungültiges Passwort. Erstellung des Chatbots fehlgeschlagen."
    
    filtered_name = filter_profanity(name)
    filtered_instruction = filter_profanity(custom_instruction)
    
    chatbot = create_chatbot(filtered_name, filtered_instruction)
    return f"Chatbot erstellt mit ID: {chatbot.chatbot_id}"

def create_chatbot_tab():
    name = gr.Textbox(label="Chatbot-Name")
    instructions = gr.Textbox(label="Benutzerdefinierte Anweisungen für Ihren Chatbot eingeben")
    create_password = gr.Textbox(label="Erstellungspasswort", type="password")
    create_button = gr.Button("Chatbot erstellen")
    create_output = gr.Textbox(label="Ergebnis der Erstellung")
    create_button.click(create_chatbot_interface, inputs=[name, instructions, create_password], outputs=create_output)