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)
|
effective_limit = get_effective_limit(clean_model, original_api_base)
|
||||||
|
|
||||||
should_restore = False
|
should_restore = False
|
||||||
if not effective_limit:
|
if effective_limit is None:
|
||||||
should_restore = True
|
should_restore = True
|
||||||
else:
|
else:
|
||||||
usage_key = get_usage_key(clean_model, original_api_base)
|
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
|
# We use effective limit logic which checks both static and dynamic
|
||||||
effective_limit = get_effective_limit(clean_model, api_base)
|
effective_limit = get_effective_limit(clean_model, api_base)
|
||||||
|
|
||||||
if not effective_limit:
|
if effective_limit is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
usage_key = get_usage_key(clean_model, api_base)
|
usage_key = get_usage_key(clean_model, api_base)
|
||||||
@@ -714,14 +714,14 @@ class DailyLimitHandler(CustomLogger):
|
|||||||
key_display = key.split(":", 2)[-1]
|
key_display = key.split(":", 2)[-1]
|
||||||
# Display Limit clearly
|
# Display Limit clearly
|
||||||
limit_str = (
|
limit_str = (
|
||||||
f" | Limit: {int(effective_limit):,}" if effective_limit else ""
|
f" | Limit: {int(effective_limit):,}" if effective_limit is not None else ""
|
||||||
)
|
)
|
||||||
log(
|
log(
|
||||||
f"📊 [Usage] {key_display}: +{total_tokens} (Today: {current_total:,}{rem_display}{limit_str})",
|
f"📊 [Usage] {key_display}: +{total_tokens} (Today: {current_total:,}{rem_display}{limit_str})",
|
||||||
level="INFO",
|
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(
|
log(
|
||||||
f"🚫 [BLOCK] {clean_model} Limit Hit: {current_total}/{effective_limit}",
|
f"🚫 [BLOCK] {clean_model} Limit Hit: {current_total}/{effective_limit}",
|
||||||
level="WARNING",
|
level="WARNING",
|
||||||
|
|||||||
Reference in New Issue
Block a user