Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -57,11 +57,63 @@ def same_auth(username, password):
|
|
| 57 |
username = username + security
|
| 58 |
return username == password
|
| 59 |
|
|
|
|
|
|
|
|
|
|
| 60 |
#GUI
|
| 61 |
theme = gr.themes.Default()
|
| 62 |
|
| 63 |
-
with gr.Blocks(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
-
|
|
|
|
| 66 |
|
| 67 |
-
demo.launch(show_api=False
|
|
|
|
| 57 |
username = username + security
|
| 58 |
return username == password
|
| 59 |
|
| 60 |
+
def get_user_summary(name):
|
| 61 |
+
return "Welcome, " + name + ". Please proceed to the '" + coach_name_long + "' tab (above) to chat."
|
| 62 |
+
|
| 63 |
#GUI
|
| 64 |
theme = gr.themes.Default()
|
| 65 |
|
| 66 |
+
with gr.Blocks() as demo:
|
| 67 |
+
output_choice = gr.State('Text') # Set 'Text' as the default state value
|
| 68 |
+
|
| 69 |
+
with gr.Tabs() as tabs:
|
| 70 |
+
with gr.TabItem("Log In"):
|
| 71 |
+
username_input = gr.Textbox(label="Username (REQUIRED):", placeholder="Enter your USERNAME", type="text")
|
| 72 |
+
password_input = gr.Textbox(label="Emailed Code (REQUIRED):", placeholder="Enter CODE from your email", type="password")
|
| 73 |
+
|
| 74 |
+
# The submit_name function will expect two inputs
|
| 75 |
+
def submit_name(name, password):
|
| 76 |
+
name = name + "7777"
|
| 77 |
+
name_upper = name.upper()
|
| 78 |
+
pwd = password.upper()
|
| 79 |
+
if name_upper != pwd:
|
| 80 |
+
name = "NOTLOGGEDIN"
|
| 81 |
+
raise gr.Error(f"You must be LOGGED IN to Chat. Refresh the page, log in, and try again.")
|
| 82 |
+
if name_upper == "":
|
| 83 |
+
name = "NOTLOGGEDIN"
|
| 84 |
+
raise gr.Error(f"You must be LOGGED IN to Chat. Refresh the page, log in, and try again.")
|
| 85 |
+
else:
|
| 86 |
+
name_upper = name_upper[:-4]
|
| 87 |
+
name = name[:-4]
|
| 88 |
+
return get_user_summary(name)
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
submit_name_button = gr.Button("Log in")
|
| 92 |
+
# status_text = gr.Label(label="", container=False)
|
| 93 |
+
status_text = gr.Label()
|
| 94 |
+
# status_text = gr.Textbox(value="", lines=2, label='', visible=True, interactive=False, autoscroll=False)
|
| 95 |
+
|
| 96 |
+
submit_name_button.click(
|
| 97 |
+
fn=submit_name,
|
| 98 |
+
inputs=[username_input, password_input],
|
| 99 |
+
outputs=[status_text]
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
+
# Attach submit event to both the username and password fields
|
| 103 |
+
username_input.submit(
|
| 104 |
+
fn=submit_name,
|
| 105 |
+
inputs=[username_input, password_input],
|
| 106 |
+
outputs=[status_text]
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
# Make sure this is done for the password field as well
|
| 110 |
+
password_input.submit(
|
| 111 |
+
fn=submit_name,
|
| 112 |
+
inputs=[username_input, password_input],
|
| 113 |
+
outputs=[status_text]
|
| 114 |
+
)
|
| 115 |
|
| 116 |
+
with gr.TabItem(coach_name_long):
|
| 117 |
+
gr.ChatInterface(predict, submit_btn="Chat with "+ coach_name_short, retry_btn=None, undo_btn=None, clear_btn=None)
|
| 118 |
|
| 119 |
+
demo.launch(show_api=False)
|