Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -93,12 +93,12 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as app:
|
|
| 93 |
# ======================
|
| 94 |
# Tabs: Login / Signup
|
| 95 |
# ======================
|
| 96 |
-
with gr.Tabs():
|
| 97 |
|
| 98 |
# -------------------
|
| 99 |
# LOGIN TAB
|
| 100 |
# -------------------
|
| 101 |
-
with gr.Tab("Login"):
|
| 102 |
log_user = gr.Textbox(label="Username")
|
| 103 |
log_pw = gr.Textbox(label="Password", type="password")
|
| 104 |
log_status = gr.Textbox(label="Status", interactive=False)
|
|
@@ -123,7 +123,7 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as app:
|
|
| 123 |
chatbot = gr.Chatbot(type="messages")
|
| 124 |
msg = gr.Textbox(placeholder="Таны асуулт...", lines=1)
|
| 125 |
clear = gr.Button("🗑️ Clear History")
|
| 126 |
-
msg.submit(chat_fn,
|
| 127 |
clear.click(lambda: [], None, chatbot)
|
| 128 |
|
| 129 |
# ======================
|
|
@@ -141,13 +141,14 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as app:
|
|
| 141 |
def login_action(username, password):
|
| 142 |
res = login(username, password)
|
| 143 |
if res == "SUCCESS":
|
| 144 |
-
|
| 145 |
-
|
|
|
|
| 146 |
|
| 147 |
log_btn.click(
|
| 148 |
login_action,
|
| 149 |
inputs=[log_user, log_pw],
|
| 150 |
-
outputs=[log_status, chat_ui]
|
| 151 |
)
|
| 152 |
|
| 153 |
# ======================
|
|
|
|
| 93 |
# ======================
|
| 94 |
# Tabs: Login / Signup
|
| 95 |
# ======================
|
| 96 |
+
with gr.Tabs() as tabs:
|
| 97 |
|
| 98 |
# -------------------
|
| 99 |
# LOGIN TAB
|
| 100 |
# -------------------
|
| 101 |
+
with gr.Tab("Login") as login_tab:
|
| 102 |
log_user = gr.Textbox(label="Username")
|
| 103 |
log_pw = gr.Textbox(label="Password", type="password")
|
| 104 |
log_status = gr.Textbox(label="Status", interactive=False)
|
|
|
|
| 123 |
chatbot = gr.Chatbot(type="messages")
|
| 124 |
msg = gr.Textbox(placeholder="Таны асуулт...", lines=1)
|
| 125 |
clear = gr.Button("🗑️ Clear History")
|
| 126 |
+
msg.submit(chat_fn, [msg, chatbot], [chatbot, chatbot])
|
| 127 |
clear.click(lambda: [], None, chatbot)
|
| 128 |
|
| 129 |
# ======================
|
|
|
|
| 141 |
def login_action(username, password):
|
| 142 |
res = login(username, password)
|
| 143 |
if res == "SUCCESS":
|
| 144 |
+
# Hide login/signup tabs & show chat UI
|
| 145 |
+
return "✅ Амжилттай нэвтэрлээ!", gr.update(visible=False), gr.update(visible=True)
|
| 146 |
+
return res, gr.update(visible=True), gr.update(visible=False)
|
| 147 |
|
| 148 |
log_btn.click(
|
| 149 |
login_action,
|
| 150 |
inputs=[log_user, log_pw],
|
| 151 |
+
outputs=[log_status, tabs, chat_ui]
|
| 152 |
)
|
| 153 |
|
| 154 |
# ======================
|