Spaces:
Running
Running
| import gradio as gr | |
| from tabs.chat import create_chat_tab, load_chatbot | |
| 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", | |
| head=""" | |
| <script> | |
| function copyToClipboard() { | |
| var copyText = document.querySelector("#share_link textarea").value; | |
| navigator.clipboard.writeText(copyText).then(function() { | |
| alert("Copied the text: " + copyText); | |
| }, function(err) { | |
| console.error("Could not copy text: ", err); | |
| }); | |
| } | |
| </script> | |
| """ | |
| ) as demo: | |
| gr.Markdown("# codora AI App Creator v0") | |
| chatbot_id_input = gr.Textbox(label="Enter Chatbot ID") | |
| load_button = gr.Button("Load Chatbot") | |
| load_message = gr.Textbox(label="Load Message", interactive=False) | |
| with gr.Tabs(): | |
| with gr.Tab("Chat"): | |
| chat_tab = create_chat_tab(chatbot_id_input, load_button, load_message) | |
| with gr.Tab("Create Chatbot"): | |
| create_chatbot_tab() | |
| with gr.Tab("Admin"): | |
| create_admin_tab() | |
| def load_chatbot_on_start(chatbot_id, request: gr.Request): | |
| params = request.query_params | |
| if "chatbot_id" in params: | |
| chatbot_id = params["chatbot_id"] | |
| return load_chatbot(chatbot_id) | |
| return ( | |
| gr.update(value="Welcome to the Chatbot"), | |
| gr.update(value="", visible=True), | |
| gr.update(value=""), | |
| gr.update(value="") | |
| ) | |
| return demo | |
| demo = create_app() | |
| if __name__ == "__main__": | |
| demo.launch() | |