Chris Addis commited on
Commit ·
2f9cb8d
1
Parent(s): 4ee4753
authentication
Browse files
app.py
CHANGED
|
@@ -20,16 +20,6 @@ from library.utils_prompt import *
|
|
| 20 |
authorized_users_str = os.environ.get("AUTHORIZED_USER_IDS", "")
|
| 21 |
AUTHORIZED_USER_IDS = set(authorized_users_str.split(',') if authorized_users_str and authorized_users_str.strip() else [])
|
| 22 |
|
| 23 |
-
# New function to check if current user is authorized
|
| 24 |
-
def check_authorization(profile: gr.OAuthProfile | None):
|
| 25 |
-
if profile is None:
|
| 26 |
-
return False #"Not logged in. Please Login for full access."
|
| 27 |
-
|
| 28 |
-
if profile.username in AUTHORIZED_USER_IDS:
|
| 29 |
-
return True
|
| 30 |
-
else:
|
| 31 |
-
return False
|
| 32 |
-
|
| 33 |
#Api sdk
|
| 34 |
OR = OpenRouterAPI()
|
| 35 |
|
|
@@ -421,6 +411,15 @@ def create_demo():
|
|
| 421 |
|
| 422 |
return demo
|
| 423 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 424 |
|
| 425 |
def hello(profile: gr.OAuthProfile | None) -> str:
|
| 426 |
if profile is None:
|
|
@@ -439,7 +438,8 @@ def create_demo_free():
|
|
| 439 |
|
| 440 |
# Launch the app
|
| 441 |
if __name__ == "__main__":
|
| 442 |
-
|
|
|
|
| 443 |
app = create_demo()
|
| 444 |
else:
|
| 445 |
app = create_demo_free()
|
|
|
|
| 20 |
authorized_users_str = os.environ.get("AUTHORIZED_USER_IDS", "")
|
| 21 |
AUTHORIZED_USER_IDS = set(authorized_users_str.split(',') if authorized_users_str and authorized_users_str.strip() else [])
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
#Api sdk
|
| 24 |
OR = OpenRouterAPI()
|
| 25 |
|
|
|
|
| 411 |
|
| 412 |
return demo
|
| 413 |
|
| 414 |
+
# New function to check if current user is authorized
|
| 415 |
+
def check_authorization(profile: gr.OAuthProfile | None):
|
| 416 |
+
if profile is None:
|
| 417 |
+
return False #"Not logged in. Please Login for full access."
|
| 418 |
+
|
| 419 |
+
if profile.username in AUTHORIZED_USER_IDS:
|
| 420 |
+
return True
|
| 421 |
+
else:
|
| 422 |
+
return False
|
| 423 |
|
| 424 |
def hello(profile: gr.OAuthProfile | None) -> str:
|
| 425 |
if profile is None:
|
|
|
|
| 438 |
|
| 439 |
# Launch the app
|
| 440 |
if __name__ == "__main__":
|
| 441 |
+
profile = gr.OAuthProfile()
|
| 442 |
+
if check_authorization(profile):
|
| 443 |
app = create_demo()
|
| 444 |
else:
|
| 445 |
app = create_demo_free()
|