mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-10-05 20:28:23 +00:00
add max cost tolerance
This commit is contained in:
@@ -87,7 +87,7 @@ def check_token_balance(headers: dict, body: dict, max_cost_for_model: int) -> N
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_max_cost_for_model(model: str) -> int:
|
def get_max_cost_for_model(model: str, tolerance_percentage: int = 1) -> int:
|
||||||
"""Get the maximum cost for a specific model."""
|
"""Get the maximum cost for a specific model."""
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Getting max cost for model",
|
"Getting max cost for model",
|
||||||
@@ -118,7 +118,7 @@ def get_max_cost_for_model(model: str) -> int:
|
|||||||
|
|
||||||
for m in MODELS:
|
for m in MODELS:
|
||||||
if m.id == model:
|
if m.id == model:
|
||||||
max_cost = m.sats_pricing.max_cost * 1000 # type: ignore
|
max_cost = m.sats_pricing.max_cost * 1000 * (1 - tolerance_percentage / 100) # type: ignore
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Found model-specific max cost",
|
"Found model-specific max cost",
|
||||||
extra={"model": model, "max_cost_msats": max_cost},
|
extra={"model": model, "max_cost_msats": max_cost},
|
||||||
|
|||||||
Reference in New Issue
Block a user