Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 1,641 Bytes
0a440b6 71736e8 8379016 71736e8 8379016 71736e8 0a440b6 71736e8 0a440b6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
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()
@demo.load(inputs=[chatbot_id_input], outputs=[chat_tab['title'], chatbot_id_input, chat_tab['share_link']])
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() |