Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -664,12 +664,14 @@ def custom_css():
|
|
| 664 |
########################################
|
| 665 |
# Bot- test gegen schädliche Bots die die Anwendung testen...
|
| 666 |
# Funktion zur Überprüfung der Benutzereingabe
|
| 667 |
-
|
|
|
|
| 668 |
user_input_hashed = hash_input(user_input.lower())
|
| 669 |
if user_input_hashed == correct_hash:
|
| 670 |
-
|
|
|
|
| 671 |
else:
|
| 672 |
-
return "Falsche Antwort!"
|
| 673 |
|
| 674 |
def launch_main_app(_):
|
| 675 |
# Schließt das Validierungs-Interface und startet die Hauptanwendung
|
|
@@ -680,13 +682,14 @@ def launch_main_app(_):
|
|
| 680 |
# Start Gui Vorabfrage
|
| 681 |
# Validierungs-Interface - Bots weghalten...
|
| 682 |
print ("Start GUI Vorabfrage")
|
|
|
|
| 683 |
validation_interface = gr.Interface(
|
| 684 |
fn=validate_input,
|
| 685 |
inputs=gr.Textbox(label="Bitte tippen Sie das oben im Moodle Kurs angegebene Wort ein, um zu beweisen, dass Sie kein Bot sind."),
|
| 686 |
outputs=[gr.Text(label="Überprüfungsergebnis")],
|
| 687 |
live=True # Aktiviert die Live-Aktualisierung ohne Submit-Button
|
| 688 |
)
|
| 689 |
-
|
| 690 |
#################################################################################################
|
| 691 |
print ("Start GUI Hauptanwendung")
|
| 692 |
with open("custom.css", "r", encoding="utf-8") as f:
|
|
@@ -728,9 +731,15 @@ with gr.Blocks(css=custom_css(), theme=themeAlex) as demo:
|
|
| 728 |
gr.Markdown(description_top)
|
| 729 |
with gr.Tab("KKG Chatbot"):
|
| 730 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 731 |
#gr.HTML("LI Chatot")
|
| 732 |
status_display = gr.Markdown("Antwort der KI ...", visible = True) #, elem_id="status_display")
|
| 733 |
-
with gr.Row():
|
| 734 |
with gr.Column(scale=5):
|
| 735 |
with gr.Row():
|
| 736 |
chatbot = gr.Chatbot(elem_id="li-chat",show_copy_button=True)
|
|
@@ -818,11 +827,11 @@ with gr.Blocks(css=custom_css(), theme=themeAlex) as demo:
|
|
| 818 |
# Tab zum Zeichnen mit Stable Diffusion
|
| 819 |
################################################
|
| 820 |
with gr.Tab("LI Zeichnen"):
|
| 821 |
-
with gr.Row():
|
| 822 |
gr.HTML("Lass den KI-Bot deine Ideen zeichnen...")
|
| 823 |
status_display2 = gr.Markdown("Success", visible = False, elem_id="status_display")
|
| 824 |
#gr.Markdown(description2)
|
| 825 |
-
with gr.Row():
|
| 826 |
with gr.Column(scale=5):
|
| 827 |
with gr.Row():
|
| 828 |
chatbot_bild = gr.Chatbot(elem_id="li-zeichnen",show_copy_button=True, show_share_button=True)
|
|
@@ -920,6 +929,12 @@ with gr.Blocks(css=custom_css(), theme=themeAlex) as demo:
|
|
| 920 |
fn=add_text, inputs=[chatbot, history, user_input, attached_file, attached_file_history], outputs=[chatbot, history, user_question, attached_file, attached_file_history, image_display , user_input], show_progress=True
|
| 921 |
)
|
| 922 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 923 |
predict_event1 = user_input.submit(**transfer_input_args, queue=False,).then(**predict_args)
|
| 924 |
predict_event2 = submitBtn.click(**transfer_input_args, queue=False,).then(**predict_args)
|
| 925 |
predict_event3 = upload.upload(file_anzeigen, [upload], [image_display, image_display, attached_file] ) #.then(**predict_args)
|
|
|
|
| 664 |
########################################
|
| 665 |
# Bot- test gegen schädliche Bots die die Anwendung testen...
|
| 666 |
# Funktion zur Überprüfung der Benutzereingabe
|
| 667 |
+
# Funktion zur Überprüfung der Eingabe und Aktivierung der Hauptanwendung
|
| 668 |
+
def validate_input(user_input, state):
|
| 669 |
user_input_hashed = hash_input(user_input.lower())
|
| 670 |
if user_input_hashed == correct_hash:
|
| 671 |
+
state.update(visible=True) # Hauptanwendung sichtbar machen
|
| 672 |
+
return "Richtig! Weiter gehts... ", ""
|
| 673 |
else:
|
| 674 |
+
return "Falsche Antwort!", None
|
| 675 |
|
| 676 |
def launch_main_app(_):
|
| 677 |
# Schließt das Validierungs-Interface und startet die Hauptanwendung
|
|
|
|
| 682 |
# Start Gui Vorabfrage
|
| 683 |
# Validierungs-Interface - Bots weghalten...
|
| 684 |
print ("Start GUI Vorabfrage")
|
| 685 |
+
"""
|
| 686 |
validation_interface = gr.Interface(
|
| 687 |
fn=validate_input,
|
| 688 |
inputs=gr.Textbox(label="Bitte tippen Sie das oben im Moodle Kurs angegebene Wort ein, um zu beweisen, dass Sie kein Bot sind."),
|
| 689 |
outputs=[gr.Text(label="Überprüfungsergebnis")],
|
| 690 |
live=True # Aktiviert die Live-Aktualisierung ohne Submit-Button
|
| 691 |
)
|
| 692 |
+
"""
|
| 693 |
#################################################################################################
|
| 694 |
print ("Start GUI Hauptanwendung")
|
| 695 |
with open("custom.css", "r", encoding="utf-8") as f:
|
|
|
|
| 731 |
gr.Markdown(description_top)
|
| 732 |
with gr.Tab("KKG Chatbot"):
|
| 733 |
with gr.Row():
|
| 734 |
+
user_input = gr.Textbox(label="Bitte tippen Sie das oben im Moodle Kurs angegebene Wort ein, um zu beweisen, dass Sie kein Bot sind.")
|
| 735 |
+
validate_btn = gr.Button("Überprüfen")
|
| 736 |
+
validation_result = gr.Text(label="Validierungsergebnis")
|
| 737 |
+
state = gr.State(visible=False) # Zustand zur Steuerung der Sichtbarkeit der Hauptanwendung
|
| 738 |
+
|
| 739 |
+
with gr.Row(visible=state):
|
| 740 |
#gr.HTML("LI Chatot")
|
| 741 |
status_display = gr.Markdown("Antwort der KI ...", visible = True) #, elem_id="status_display")
|
| 742 |
+
with gr.Row(visible=state):
|
| 743 |
with gr.Column(scale=5):
|
| 744 |
with gr.Row():
|
| 745 |
chatbot = gr.Chatbot(elem_id="li-chat",show_copy_button=True)
|
|
|
|
| 827 |
# Tab zum Zeichnen mit Stable Diffusion
|
| 828 |
################################################
|
| 829 |
with gr.Tab("LI Zeichnen"):
|
| 830 |
+
with gr.Row(visible=state):
|
| 831 |
gr.HTML("Lass den KI-Bot deine Ideen zeichnen...")
|
| 832 |
status_display2 = gr.Markdown("Success", visible = False, elem_id="status_display")
|
| 833 |
#gr.Markdown(description2)
|
| 834 |
+
with gr.Row(visible=state):
|
| 835 |
with gr.Column(scale=5):
|
| 836 |
with gr.Row():
|
| 837 |
chatbot_bild = gr.Chatbot(elem_id="li-zeichnen",show_copy_button=True, show_share_button=True)
|
|
|
|
| 929 |
fn=add_text, inputs=[chatbot, history, user_input, attached_file, attached_file_history], outputs=[chatbot, history, user_question, attached_file, attached_file_history, image_display , user_input], show_progress=True
|
| 930 |
)
|
| 931 |
|
| 932 |
+
##############################################
|
| 933 |
+
# Button Events....
|
| 934 |
+
#Validation Button
|
| 935 |
+
# Event-Handler für die Validierung
|
| 936 |
+
validate_btn.click(validate_input, inputs=[user_input, state], outputs=[validation_result, state])
|
| 937 |
+
|
| 938 |
predict_event1 = user_input.submit(**transfer_input_args, queue=False,).then(**predict_args)
|
| 939 |
predict_event2 = submitBtn.click(**transfer_input_args, queue=False,).then(**predict_args)
|
| 940 |
predict_event3 = upload.upload(file_anzeigen, [upload], [image_display, image_display, attached_file] ) #.then(**predict_args)
|