Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from tabs.chat import create_chat_tab, load_chatbot_with_timeout | |
| from tabs.create_chatbot import create_chatbot_tab | |
| # from tabs.admin import create_admin_tab | |
| print("Gradio Version:", gr.__version__) | |
| def create_app(): | |
| with gr.Blocks( | |
| title="codora KI-App-Ersteller v0", | |
| head=""" | |
| <script> | |
| function copyToClipboard(elementId) { | |
| var copyText = document.getElementById(elementId).querySelector('textarea').value; | |
| navigator.clipboard.writeText(copyText).then(function() { | |
| alert("Text kopiert: " + copyText); | |
| }, function(err) { | |
| console.error("Konnte Text nicht kopieren: ", err); | |
| }); | |
| } | |
| </script> | |
| """ | |
| ) as demo: | |
| gr.Markdown("# codora KI-App-Ersteller v0") | |
| with gr.Tabs(): | |
| with gr.Tab("Chat"): | |
| chat_tab = create_chat_tab() | |
| with gr.Tab("Chatbot erstellen"): | |
| create_tab = 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_with_timeout(chatbot_id) | |
| return ( | |
| gr.update(value="Willkommen beim Chatbot"), | |
| gr.update(value="", visible=True), | |
| gr.update(value=""), | |
| gr.update(value="") | |
| ) | |
| # Add event listener to automatically load newly created chatbot | |
| create_tab["chatbot_id_output"].change( | |
| fn=load_chatbot_with_timeout, | |
| inputs=[create_tab["chatbot_id_output"]], | |
| outputs=[chat_tab['title'], chat_tab['chatbot_id_input'], chat_tab['share_link'], chat_tab['load_message']] | |
| ) | |
| return demo | |
| demo = create_app() | |
| if __name__ == "__main__": | |
| demo.launch() | |