Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -20,6 +20,7 @@ DATA_DIR.mkdir(exist_ok=True)
|
|
20 |
DB_PATH = DATA_DIR / "usage_limits.db"
|
21 |
|
22 |
DAILY_LIMIT = 50
|
|
|
23 |
db_lock = Lock()
|
24 |
|
25 |
def init_db():
|
@@ -46,6 +47,11 @@ def check_and_update_usage(username: str) -> bool:
|
|
46 |
Check if user has reached daily limit and update usage.
|
47 |
Returns True if user can generate, False if limit reached.
|
48 |
"""
|
|
|
|
|
|
|
|
|
|
|
49 |
with db_lock:
|
50 |
try:
|
51 |
with sqlite3.connect(DB_PATH) as conn:
|
@@ -96,6 +102,10 @@ def check_and_update_usage(username: str) -> bool:
|
|
96 |
|
97 |
def get_remaining_generations(username: str) -> int:
|
98 |
"""Get the number of remaining generations for today."""
|
|
|
|
|
|
|
|
|
99 |
with db_lock:
|
100 |
try:
|
101 |
with sqlite3.connect(DB_PATH) as conn:
|
|
|
20 |
DB_PATH = DATA_DIR / "usage_limits.db"
|
21 |
|
22 |
DAILY_LIMIT = 50
|
23 |
+
EXEMPTED_USERS = ["multimodalart"]
|
24 |
db_lock = Lock()
|
25 |
|
26 |
def init_db():
|
|
|
47 |
Check if user has reached daily limit and update usage.
|
48 |
Returns True if user can generate, False if limit reached.
|
49 |
"""
|
50 |
+
# Exempted users bypass all checks
|
51 |
+
if username in EXEMPTED_USERS:
|
52 |
+
print(f"User {username} is exempted from rate limits")
|
53 |
+
return True
|
54 |
+
|
55 |
with db_lock:
|
56 |
try:
|
57 |
with sqlite3.connect(DB_PATH) as conn:
|
|
|
102 |
|
103 |
def get_remaining_generations(username: str) -> int:
|
104 |
"""Get the number of remaining generations for today."""
|
105 |
+
# Exempted users have unlimited generations
|
106 |
+
if username in EXEMPTED_USERS:
|
107 |
+
return 999999 # Return a large number to indicate unlimited
|
108 |
+
|
109 |
with db_lock:
|
110 |
try:
|
111 |
with sqlite3.connect(DB_PATH) as conn:
|