Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
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 KI-App-Creator v0", | |
head=""" | |
<script> | |
function copyToClipboard() { | |
var copyText = document.querySelector("#share_link textarea").value; | |
navigator.clipboard.writeText(copyText).then(function() { | |
alert("Link kopiert: " + copyText); | |
}, function(err) { | |
console.error("Konnte Link nicht kopieren: ", err); | |
}); | |
} | |
</script> | |
""" | |
) as demo: | |
gr.Markdown("# codora KI-App-Ersteller v0") | |
chatbot_id_input = gr.Textbox(label="Chatbot-ID eingeben") | |
load_button = gr.Button("Chatbot laden") | |
load_message = gr.Textbox(label="Lademeldung", interactive=False) | |
gr.Examples( | |
examples=["shiny-platypus-699", "delightful-red-panda-273", "glowing-toucan-982", "mellow-toucan-512", "upbeat-elephant-433"], | |
inputs=chatbot_id_input, | |
label="Beispiel-Chatbots" | |
) | |
with gr.Tabs(): | |
with gr.Tab("Chat"): | |
chat_tab = create_chat_tab(chatbot_id_input, load_button, load_message) | |
with gr.Tab("Chatbot erstellen"): | |
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="Willkommen beim Chatbot"), | |
gr.update(value="", visible=True), | |
gr.update(value=""), | |
gr.update(value="") | |
) | |
return demo | |
demo = create_app() | |
if __name__ == "__main__": | |
demo.launch() | |