Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
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 "Invalid password. Chatbot creation failed." | |
filtered_name = filter_profanity(name) | |
filtered_instruction = filter_profanity(custom_instruction) | |
chatbot = create_chatbot(filtered_name, filtered_instruction) | |
return f"Chatbot created with ID: {chatbot.chatbot_id}" | |
def create_chatbot_tab(): | |
name = gr.Textbox(label="Chatbot Name") | |
instructions = gr.Textbox(label="Enter custom instructions for your chatbot") | |
create_password = gr.Textbox(label="Creation Password", type="password") | |
create_button = gr.Button("Create Chatbot") | |
create_output = gr.Textbox(label="Creation Result") | |
create_button.click(create_chatbot_interface, inputs=[name, instructions, create_password], outputs=create_output) |