Update app.py
Browse files
app.py
CHANGED
|
@@ -22,13 +22,10 @@ import torch
|
|
| 22 |
import json
|
| 23 |
from langdetect import detect
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
(
|
| 29 |
-
("Girinath", "password"),
|
| 30 |
-
("Jowins", "password")
|
| 31 |
-
])
|
| 32 |
|
| 33 |
# Load model and processor
|
| 34 |
processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
|
|
@@ -324,7 +321,29 @@ def create_chatbot():
|
|
| 324 |
border-radius: 8px;
|
| 325 |
}
|
| 326 |
""") as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
with gr.Tab("Chatbot"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
chatbot = gr.Chatbot(type='messages', elem_id="chatbot-box")
|
| 329 |
audio_output = gr.Audio(type="filepath", visible=False, autoplay=True)
|
| 330 |
state = gr.State([])
|
|
@@ -752,4 +771,4 @@ window.addEventListener("beforeunload", async function (e) {
|
|
| 752 |
|
| 753 |
return demo
|
| 754 |
|
| 755 |
-
create_chatbot().launch(
|
|
|
|
| 22 |
import json
|
| 23 |
from langdetect import detect
|
| 24 |
|
| 25 |
+
VALID_USERS = {"user1": "pass123", "admin": "supersecure"} # You can add more
|
| 26 |
+
|
| 27 |
+
def authenticate(username, password):
|
| 28 |
+
return VALID_USERS.get(username) == password
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
# Load model and processor
|
| 31 |
processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
|
|
|
|
| 321 |
border-radius: 8px;
|
| 322 |
}
|
| 323 |
""") as demo:
|
| 324 |
+
|
| 325 |
+
with gr.Tab("Login"):
|
| 326 |
+
gr.Markdown("## 🔐 Login to PR1ME")
|
| 327 |
+
user = gr.Textbox(label="Username")
|
| 328 |
+
pwd = gr.Textbox(label="Password", type="password")
|
| 329 |
+
login_btn = gr.Button("Login")
|
| 330 |
+
login_output = gr.Textbox(visible=False)
|
| 331 |
+
|
| 332 |
+
login_status = gr.State(False)
|
| 333 |
+
|
| 334 |
+
def check_login(u, p):
|
| 335 |
+
if authenticate(u, p):
|
| 336 |
+
return True, gr.update(visible=True), ""
|
| 337 |
+
return False, gr.update(visible=False), "❌ Invalid credentials."
|
| 338 |
+
|
| 339 |
+
login_btn.click(fn=check_login, inputs=[user, pwd], outputs=[login_status, login_output, login_output])
|
| 340 |
+
|
| 341 |
with gr.Tab("Chatbot"):
|
| 342 |
+
def show_if_logged_in(is_logged_in):
|
| 343 |
+
return gr.update(visible=is_logged_in)
|
| 344 |
+
|
| 345 |
+
chatbot = gr.Chatbot(visible=False)
|
| 346 |
+
login_status.change(fn=show_if_logged_in, inputs=[login_status], outputs=[chatbot])
|
| 347 |
chatbot = gr.Chatbot(type='messages', elem_id="chatbot-box")
|
| 348 |
audio_output = gr.Audio(type="filepath", visible=False, autoplay=True)
|
| 349 |
state = gr.State([])
|
|
|
|
| 771 |
|
| 772 |
return demo
|
| 773 |
|
| 774 |
+
create_chatbot().launch()
|