Julia Ostheimer commited on
Commit ·
7c1936b
1
Parent(s): 4afc1e8
Test implement authentication idea
Browse files
app.py
CHANGED
|
@@ -124,28 +124,55 @@ def bot(message, history, source_history, request: gr.Request) -> list[Any]:
|
|
| 124 |
|
| 125 |
return [response["messages"][-1].content], source_history
|
| 126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
with gr.Blocks() as demo:
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
flagging_mode="manual",
|
| 137 |
-
editable=True,
|
| 138 |
-
flagging_options=["Like", "Dislike", "Spam", "Inappropriate", "Other"],
|
| 139 |
-
multimodal=True,
|
| 140 |
-
textbox=gr.MultimodalTextbox(file_count="multiple"),
|
| 141 |
-
title="DEval Prototype 1",
|
| 142 |
-
additional_inputs=[source_history],
|
| 143 |
-
additional_outputs=[source_history],
|
| 144 |
)
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
if __name__ == "__main__":
|
| 151 |
demo.launch(share=False, server_name="0.0.0.0")
|
|
|
|
| 124 |
|
| 125 |
return [response["messages"][-1].content], source_history
|
| 126 |
|
| 127 |
+
|
| 128 |
+
import os
|
| 129 |
+
|
| 130 |
+
USERNAME = os.getenv("TEST_USER_NAME")
|
| 131 |
+
PASSWORD = os.getenv("TEST_USER_PASSWORD")
|
| 132 |
+
|
| 133 |
+
def login(user, pw, logged_in_state):
|
| 134 |
+
if user == USERNAME and pw == PASSWORD:
|
| 135 |
+
logged_in_state = True
|
| 136 |
+
return "Login successful", logged_in_state
|
| 137 |
+
else:
|
| 138 |
+
logged_in_state = False
|
| 139 |
+
return "Login failed", logged_in_state
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
|
| 144 |
with gr.Blocks() as demo:
|
| 145 |
+
logged_in = gr.State(False)
|
| 146 |
+
|
| 147 |
+
with gr.Row():
|
| 148 |
+
login_interface = gr.Interface(
|
| 149 |
+
fn=login,
|
| 150 |
+
inputs=[gr.Textbox(type="text", label="User:"), gr.Textbox(type="password", label="Password:"), logged_in],
|
| 151 |
+
outputs=[gr.Markdown(), logged_in],
|
| 152 |
+
allow_flagging="never",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
)
|
| 154 |
+
|
| 155 |
+
# # Initialize source history as session state variable
|
| 156 |
+
# source_history = gr.State([])
|
| 157 |
+
|
| 158 |
+
# gr.Markdown("### Dies ist der aktuelle Prototyp der DEval AI4Kontextanalysen, mit dem Fokus auf dem Testen der Zitationsfunktion und der grundlegenden Konfiguration.")
|
| 159 |
+
# with gr.Tab("Chat"):
|
| 160 |
+
# gr.ChatInterface(
|
| 161 |
+
# bot,
|
| 162 |
+
# type="messages",
|
| 163 |
+
# flagging_mode="manual",
|
| 164 |
+
# editable=True,
|
| 165 |
+
# flagging_options=["Like", "Dislike", "Spam", "Inappropriate", "Other"],
|
| 166 |
+
# multimodal=True,
|
| 167 |
+
# textbox=gr.MultimodalTextbox(file_count="multiple"),
|
| 168 |
+
# title="DEval Prototype 1",
|
| 169 |
+
# additional_inputs=[source_history],
|
| 170 |
+
# additional_outputs=[source_history],
|
| 171 |
+
# )
|
| 172 |
+
# with gr.Tab("Quellen"):
|
| 173 |
+
# prettified_source_history_md = gr.Markdown()
|
| 174 |
+
# # Update the source history UI immediately when the source_history value changes
|
| 175 |
+
# source_history.change(prettify_source_history, source_history, prettified_source_history_md)
|
| 176 |
|
| 177 |
if __name__ == "__main__":
|
| 178 |
demo.launch(share=False, server_name="0.0.0.0")
|