Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,6 @@ from openai import OpenAI
|
|
| 4 |
import gradio as gr
|
| 5 |
from auth import register_user, login_user, logout_user, save_chats, delete_account
|
| 6 |
from response_modes import chat_stream # β Make sure this file exists
|
| 7 |
-
from phone_verification import send_otp
|
| 8 |
|
| 9 |
# ================== SETTINGS ==================
|
| 10 |
API_KEY = os.environ.get("API_KEY")
|
|
@@ -78,10 +77,9 @@ with gr.Blocks(title="NVIDIA AI Chat") as demo:
|
|
| 78 |
|
| 79 |
with gr.Accordion("π How to Use", open=True):
|
| 80 |
gr.Markdown("""
|
| 81 |
-
**1.** Enter
|
| 82 |
-
**2.**
|
| 83 |
-
**3.**
|
| 84 |
-
**4.** Load Model β Chat
|
| 85 |
""")
|
| 86 |
|
| 87 |
current_model = gr.State(None)
|
|
@@ -123,11 +121,8 @@ with gr.Blocks(title="NVIDIA AI Chat") as demo:
|
|
| 123 |
with gr.Row():
|
| 124 |
username_input = gr.Textbox(label="Username", scale=2)
|
| 125 |
password_input = gr.Textbox(label="Password", type="password", scale=2)
|
| 126 |
-
phone_input = gr.Textbox(label="Phone Number (+639...)", scale=2, placeholder="+639171234567")
|
| 127 |
|
| 128 |
with gr.Row():
|
| 129 |
-
otp_input = gr.Textbox(label="Enter 6-digit OTP from SMS", type="password", scale=2)
|
| 130 |
-
send_otp_btn = gr.Button("Send OTP", variant="secondary")
|
| 131 |
register_btn = gr.Button("Register", variant="secondary")
|
| 132 |
login_btn = gr.Button("Login", variant="primary")
|
| 133 |
logout_btn = gr.Button("Logout", visible=False, variant="stop")
|
|
@@ -139,22 +134,13 @@ with gr.Blocks(title="NVIDIA AI Chat") as demo:
|
|
| 139 |
confirm_delete_btn = gr.Button("YES, DELETE FOREVER", variant="stop")
|
| 140 |
|
| 141 |
# ================== EVENTS ==================
|
| 142 |
-
send_otp_btn.click(
|
| 143 |
-
lambda phone, auth_globals: send_otp(phone, auth_globals),
|
| 144 |
-
[phone_input, auth_globals_state],
|
| 145 |
-
status_label
|
| 146 |
-
).then(
|
| 147 |
-
lambda msg: gr.Info(msg) if "β
" in msg else gr.Warning(msg),
|
| 148 |
-
status_label,
|
| 149 |
-
None
|
| 150 |
-
)
|
| 151 |
|
| 152 |
register_btn.click(
|
| 153 |
register_user,
|
| 154 |
-
[username_input, password_input, phone_input,
|
| 155 |
[user_chats_state, current_chat_title, chatbot, chat_dropdown, logged_in_username, status_label, logout_btn, delete_acc_btn, confirm_row]
|
| 156 |
).then(lambda: gr.Info("β
Registration successful!", duration=4), None, None)\
|
| 157 |
-
.then(lambda: ("","","",""), None, [username_input, password_input, phone_input
|
| 158 |
|
| 159 |
login_btn.click(
|
| 160 |
login_user,
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
from auth import register_user, login_user, logout_user, save_chats, delete_account
|
| 6 |
from response_modes import chat_stream # β Make sure this file exists
|
|
|
|
| 7 |
|
| 8 |
# ================== SETTINGS ==================
|
| 9 |
API_KEY = os.environ.get("API_KEY")
|
|
|
|
| 77 |
|
| 78 |
with gr.Accordion("π How to Use", open=True):
|
| 79 |
gr.Markdown("""
|
| 80 |
+
**1.** Enter Username & Password β Click **Register**
|
| 81 |
+
**2.** Login β Load Model
|
| 82 |
+
**3.** Create/Select Chat β Start Prompt
|
|
|
|
| 83 |
""")
|
| 84 |
|
| 85 |
current_model = gr.State(None)
|
|
|
|
| 121 |
with gr.Row():
|
| 122 |
username_input = gr.Textbox(label="Username", scale=2)
|
| 123 |
password_input = gr.Textbox(label="Password", type="password", scale=2)
|
|
|
|
| 124 |
|
| 125 |
with gr.Row():
|
|
|
|
|
|
|
| 126 |
register_btn = gr.Button("Register", variant="secondary")
|
| 127 |
login_btn = gr.Button("Login", variant="primary")
|
| 128 |
logout_btn = gr.Button("Logout", visible=False, variant="stop")
|
|
|
|
| 134 |
confirm_delete_btn = gr.Button("YES, DELETE FOREVER", variant="stop")
|
| 135 |
|
| 136 |
# ================== EVENTS ==================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
|
| 138 |
register_btn.click(
|
| 139 |
register_user,
|
| 140 |
+
[username_input, password_input, phone_input, logged_in_username, auth_globals_state],
|
| 141 |
[user_chats_state, current_chat_title, chatbot, chat_dropdown, logged_in_username, status_label, logout_btn, delete_acc_btn, confirm_row]
|
| 142 |
).then(lambda: gr.Info("β
Registration successful!", duration=4), None, None)\
|
| 143 |
+
.then(lambda: ("","","",""), None, [username_input, password_input, phone_input])
|
| 144 |
|
| 145 |
login_btn.click(
|
| 146 |
login_user,
|