Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
import gradio as gr | |
from tabs.chat import create_chat_tab | |
from tabs.create_chatbot import create_chatbot_tab | |
from tabs.admin import create_admin_tab | |
def create_app(): | |
with gr.Blocks(title="codora AI App Creator v0") as demo: | |
gr.Markdown("# codora AI App Creator v0") | |
chatbot_id_input = gr.Textbox(label="Enter Chatbot ID", visible=False) | |
with gr.Tabs(): | |
with gr.Tab("Chat"): | |
chat_tab = create_chat_tab(chatbot_id_input) | |
with gr.Tab("Create Chatbot"): | |
create_chatbot_tab() | |
with gr.Tab("Admin"): | |
create_admin_tab() | |
def load_chatbot(chatbot_id, request: gr.Request): | |
params = request.query_params | |
if "chatbot_id" in params: | |
chatbot_id = params["chatbot_id"] | |
from database import get_chatbot | |
chatbot = get_chatbot(chatbot_id) | |
if chatbot: | |
return ( | |
gr.update(value=f"Welcome to {chatbot.name}"), | |
gr.update(value=chatbot_id, visible=True), | |
gr.update(value=f"https://huggingface.co/spaces/codora/ai-app-creator?chatbot_id={chatbot_id}") | |
) | |
return ( | |
gr.update(value="Welcome to the Chatbot"), | |
gr.update(value="", visible=True), | |
gr.update(value="") | |
) | |
return demo | |
if __name__ == "__main__": | |
demo = create_app() | |
demo.launch() |