Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,10 +47,13 @@ class ConversationalAI:
|
|
| 47 |
return "Invalid username or password. Please try again."
|
| 48 |
|
| 49 |
def create_chat_interface(self):
|
| 50 |
-
def on_login_click(username, password, login_output):
|
| 51 |
result_msg = self.login(username, password)
|
| 52 |
login_output.update(result_msg)
|
| 53 |
if self.logged_in:
|
|
|
|
|
|
|
|
|
|
| 54 |
demo.replace(gr.ChatInterface(self.chat_groq, clear_btn=None, undo_btn=None, retry_btn=None))
|
| 55 |
|
| 56 |
with gr.Blocks(theme=gr.themes.Monochrome(), fill_height=True) as demo:
|
|
@@ -58,14 +61,17 @@ class ConversationalAI:
|
|
| 58 |
gr.ChatInterface(self.chat_groq, clear_btn=None, undo_btn=None, retry_btn=None)
|
| 59 |
else:
|
| 60 |
with gr.Column():
|
| 61 |
-
|
| 62 |
-
|
| 63 |
login_btn = gr.Button("Login")
|
| 64 |
login_output = gr.Textbox(label="Login Status:", placeholder="Login status will appear here",
|
| 65 |
disabled=True) # Use disabled=True instead of readonly=True
|
| 66 |
|
| 67 |
-
login_btn.click(on_login_click, [
|
| 68 |
|
|
|
|
|
|
|
|
|
|
| 69 |
demo.append(login_output)
|
| 70 |
|
| 71 |
return demo
|
|
|
|
| 47 |
return "Invalid username or password. Please try again."
|
| 48 |
|
| 49 |
def create_chat_interface(self):
|
| 50 |
+
def on_login_click(username, password, login_output, username_field, password_field):
|
| 51 |
result_msg = self.login(username, password)
|
| 52 |
login_output.update(result_msg)
|
| 53 |
if self.logged_in:
|
| 54 |
+
# Disable username and password fields after successful login
|
| 55 |
+
username_field.disabled = True
|
| 56 |
+
password_field.disabled = True
|
| 57 |
demo.replace(gr.ChatInterface(self.chat_groq, clear_btn=None, undo_btn=None, retry_btn=None))
|
| 58 |
|
| 59 |
with gr.Blocks(theme=gr.themes.Monochrome(), fill_height=True) as demo:
|
|
|
|
| 61 |
gr.ChatInterface(self.chat_groq, clear_btn=None, undo_btn=None, retry_btn=None)
|
| 62 |
else:
|
| 63 |
with gr.Column():
|
| 64 |
+
username_field = gr.Textbox(label="Username")
|
| 65 |
+
password_field = gr.Textbox(label="Password", type="password")
|
| 66 |
login_btn = gr.Button("Login")
|
| 67 |
login_output = gr.Textbox(label="Login Status:", placeholder="Login status will appear here",
|
| 68 |
disabled=True) # Use disabled=True instead of readonly=True
|
| 69 |
|
| 70 |
+
login_btn.click(on_login_click, [username_field.value, password_field.value, login_output, username_field, password_field])
|
| 71 |
|
| 72 |
+
demo.append(username_field)
|
| 73 |
+
demo.append(password_field)
|
| 74 |
+
demo.append(login_btn)
|
| 75 |
demo.append(login_output)
|
| 76 |
|
| 77 |
return demo
|