Update app.py
Browse files
app.py
CHANGED
|
@@ -113,12 +113,6 @@ agent_with_chat_history = RunnableWithMessageHistory(
|
|
| 113 |
history_messages_key="chat_history",
|
| 114 |
)
|
| 115 |
|
| 116 |
-
username = ""
|
| 117 |
-
|
| 118 |
-
def set_username(name, login_box, chatbot_box):
|
| 119 |
-
global username
|
| 120 |
-
username = name
|
| 121 |
-
return gr.update(visible=False), gr.update(visible=True)
|
| 122 |
|
| 123 |
# Gradio chat response function
|
| 124 |
|
|
@@ -208,6 +202,14 @@ def respond(message, history: list[dict]):
|
|
| 208 |
|
| 209 |
# launch ChatInterface
|
| 210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
with gr.Blocks(
|
| 212 |
css="""
|
| 213 |
.centered-login {
|
|
@@ -227,7 +229,7 @@ with gr.Blocks(
|
|
| 227 |
with gr.Row():
|
| 228 |
|
| 229 |
# Login UI (centered, small)
|
| 230 |
-
login_box = gr.Column(
|
| 231 |
with login_box:
|
| 232 |
gr.Markdown("### Choose a username to begin:")
|
| 233 |
with gr.Row():
|
|
@@ -249,8 +251,8 @@ with gr.Blocks(
|
|
| 249 |
hidden_guest = gr.Textbox(value="Guest", visible=False)
|
| 250 |
|
| 251 |
# Button clicks
|
| 252 |
-
btn_lina.click(set_username, inputs=[hidden_lina
|
| 253 |
-
btn_guest.click(set_username, inputs=[hidden_guest
|
| 254 |
|
| 255 |
|
| 256 |
'''
|
|
|
|
| 113 |
history_messages_key="chat_history",
|
| 114 |
)
|
| 115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
# Gradio chat response function
|
| 118 |
|
|
|
|
| 202 |
|
| 203 |
# launch ChatInterface
|
| 204 |
|
| 205 |
+
|
| 206 |
+
username = ""
|
| 207 |
+
|
| 208 |
+
def set_username(name):
|
| 209 |
+
global username
|
| 210 |
+
username = name
|
| 211 |
+
return gr.update(render=False), gr.update(visible=True)
|
| 212 |
+
|
| 213 |
with gr.Blocks(
|
| 214 |
css="""
|
| 215 |
.centered-login {
|
|
|
|
| 229 |
with gr.Row():
|
| 230 |
|
| 231 |
# Login UI (centered, small)
|
| 232 |
+
login_box = gr.Column(render=True, elem_classes="centered-login")
|
| 233 |
with login_box:
|
| 234 |
gr.Markdown("### Choose a username to begin:")
|
| 235 |
with gr.Row():
|
|
|
|
| 251 |
hidden_guest = gr.Textbox(value="Guest", visible=False)
|
| 252 |
|
| 253 |
# Button clicks
|
| 254 |
+
btn_lina.click(set_username, inputs=[hidden_lina], outputs=[login_box, chatbot_box])
|
| 255 |
+
btn_guest.click(set_username, inputs=[hidden_guest], outputs=[login_box, chatbot_box])
|
| 256 |
|
| 257 |
|
| 258 |
'''
|