File size: 2,207 Bytes
0a440b6
5d557f1
71736e8
420aaf5
71736e8
7db7d27
 
71736e8
5d557f1
6ba3c65
5d557f1
 
6ba3c65
 
5d557f1
6ba3c65
5d557f1
6ba3c65
5d557f1
 
 
 
727bb86
9e991a9
71736e8
 
 
168235c
71736e8
9e991a9
6ba3c65
71736e8
420aaf5
 
71736e8
727bb86
5d557f1
71736e8
 
 
5d557f1
8379016
9e991a9
71736e8
5d557f1
71736e8
8379016
71736e8
6ba3c65
50897a8
6ba3c65
 
 
168235c
6ba3c65
 
727bb86
0a440b6
727bb86
5d557f1
0a440b6
727bb86
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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

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()

        @demo.load(inputs=[chat_tab['chatbot_id_input']], outputs=[chat_tab['title'], chat_tab['chatbot_id_input'], chat_tab['share_link'], chat_tab['load_message']])
        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="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,
            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()