fix: resolve falsy effective_limit bug preventing model block on negative quota
This commit is contained in:
+4
-4
@@ -534,7 +534,7 @@ def restore_blocked_models():
|
||||
effective_limit = get_effective_limit(clean_model, original_api_base)
|
||||
|
||||
should_restore = False
|
||||
if not effective_limit:
|
||||
if effective_limit is None:
|
||||
should_restore = True
|
||||
else:
|
||||
usage_key = get_usage_key(clean_model, original_api_base)
|
||||
@@ -598,7 +598,7 @@ def startup_audit():
|
||||
# We use effective limit logic which checks both static and dynamic
|
||||
effective_limit = get_effective_limit(clean_model, api_base)
|
||||
|
||||
if not effective_limit:
|
||||
if effective_limit is None:
|
||||
continue
|
||||
|
||||
usage_key = get_usage_key(clean_model, api_base)
|
||||
@@ -714,14 +714,14 @@ class DailyLimitHandler(CustomLogger):
|
||||
key_display = key.split(":", 2)[-1]
|
||||
# Display Limit clearly
|
||||
limit_str = (
|
||||
f" | Limit: {int(effective_limit):,}" if effective_limit else ""
|
||||
f" | Limit: {int(effective_limit):,}" if effective_limit is not None else ""
|
||||
)
|
||||
log(
|
||||
f"📊 [Usage] {key_display}: +{total_tokens} (Today: {current_total:,}{rem_display}{limit_str})",
|
||||
level="INFO",
|
||||
)
|
||||
|
||||
if effective_limit and float(current_total) >= float(effective_limit):
|
||||
if effective_limit is not None and float(current_total) >= float(effective_limit):
|
||||
log(
|
||||
f"🚫 [BLOCK] {clean_model} Limit Hit: {current_total}/{effective_limit}",
|
||||
level="WARNING",
|
||||
|
||||
Reference in New Issue
Block a user