Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,6 +9,7 @@ from email_processor import (
|
|
| 9 |
)
|
| 10 |
|
| 11 |
# Initialize global variables
|
|
|
|
| 12 |
PASSWORD = os.getenv("PASSWD")
|
| 13 |
EMAIL_EXAMPLES = load_examples()
|
| 14 |
CLIENTS = setup_clients()
|
|
@@ -39,7 +40,7 @@ def process_email_wrapper(
|
|
| 39 |
max_tokens,
|
| 40 |
temperature,
|
| 41 |
top_p,
|
| 42 |
-
PASSWORD,
|
| 43 |
CLIENTS,
|
| 44 |
custom_guidelines,
|
| 45 |
identity
|
|
@@ -48,10 +49,11 @@ def process_email_wrapper(
|
|
| 48 |
def check_password(input_password):
|
| 49 |
"""
|
| 50 |
Validates the password and, if valid, shows the interface.
|
|
|
|
| 51 |
|
| 52 |
Returns updates to UI components based on password validation.
|
| 53 |
"""
|
| 54 |
-
if input_password == PASSWORD:
|
| 55 |
return gr.update(visible=False), gr.update(visible=True), input_password, gr.update(visible=False)
|
| 56 |
else:
|
| 57 |
return gr.update(value="", interactive=True), gr.update(visible=False), "", gr.update(value="Invalid password. Please try again.", visible=True)
|
|
@@ -85,8 +87,8 @@ with gr.Blocks(title="Email Assistant") as demo:
|
|
| 85 |
# Session password state
|
| 86 |
session_password = gr.State("")
|
| 87 |
|
| 88 |
-
# Password interface
|
| 89 |
-
with gr.Column() as password_interface:
|
| 90 |
gr.Markdown("# Email Assistant")
|
| 91 |
gr.Markdown("Please enter the password to access the application.")
|
| 92 |
password_input = gr.Textbox(
|
|
@@ -97,8 +99,8 @@ with gr.Blocks(title="Email Assistant") as demo:
|
|
| 97 |
label="Error", visible=False, interactive=False
|
| 98 |
)
|
| 99 |
|
| 100 |
-
# Main application interface
|
| 101 |
-
with gr.Column(visible=
|
| 102 |
gr.Markdown("# Email Assistant")
|
| 103 |
gr.Markdown("This tool helps you improve your email responses using AI.")
|
| 104 |
|
|
|
|
| 9 |
)
|
| 10 |
|
| 11 |
# Initialize global variables
|
| 12 |
+
PASSWORD_PROTECTION_ENABLED = False
|
| 13 |
PASSWORD = os.getenv("PASSWD")
|
| 14 |
EMAIL_EXAMPLES = load_examples()
|
| 15 |
CLIENTS = setup_clients()
|
|
|
|
| 40 |
max_tokens,
|
| 41 |
temperature,
|
| 42 |
top_p,
|
| 43 |
+
PASSWORD if PASSWORD_PROTECTION_ENABLED else None, # Pass None if protection disabled
|
| 44 |
CLIENTS,
|
| 45 |
custom_guidelines,
|
| 46 |
identity
|
|
|
|
| 49 |
def check_password(input_password):
|
| 50 |
"""
|
| 51 |
Validates the password and, if valid, shows the interface.
|
| 52 |
+
If password protection is disabled, always grants access.
|
| 53 |
|
| 54 |
Returns updates to UI components based on password validation.
|
| 55 |
"""
|
| 56 |
+
if not PASSWORD_PROTECTION_ENABLED or input_password == PASSWORD:
|
| 57 |
return gr.update(visible=False), gr.update(visible=True), input_password, gr.update(visible=False)
|
| 58 |
else:
|
| 59 |
return gr.update(value="", interactive=True), gr.update(visible=False), "", gr.update(value="Invalid password. Please try again.", visible=True)
|
|
|
|
| 87 |
# Session password state
|
| 88 |
session_password = gr.State("")
|
| 89 |
|
| 90 |
+
# Password interface - initially hidden if password protection is disabled
|
| 91 |
+
with gr.Column(visible=PASSWORD_PROTECTION_ENABLED) as password_interface:
|
| 92 |
gr.Markdown("# Email Assistant")
|
| 93 |
gr.Markdown("Please enter the password to access the application.")
|
| 94 |
password_input = gr.Textbox(
|
|
|
|
| 99 |
label="Error", visible=False, interactive=False
|
| 100 |
)
|
| 101 |
|
| 102 |
+
# Main application interface - initially visible if password protection is disabled
|
| 103 |
+
with gr.Column(visible=not PASSWORD_PROTECTION_ENABLED) as app_interface:
|
| 104 |
gr.Markdown("# Email Assistant")
|
| 105 |
gr.Markdown("This tool helps you improve your email responses using AI.")
|
| 106 |
|