From 477c67ebebe69184a3c93fa83cefacc75a6adc62 Mon Sep 17 00:00:00 2001 From: 9qeklajc <9qeklajc> Date: Thu, 7 Aug 2025 00:10:45 +0200 Subject: [PATCH] remove redundant changes --- router/payment/x_cashu.py | 16 +++++++--------- router/proxy.py | 10 ++++------ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/router/payment/x_cashu.py b/router/payment/x_cashu.py index a553d155..591ae837 100644 --- a/router/payment/x_cashu.py +++ b/router/payment/x_cashu.py @@ -8,10 +8,14 @@ from fastapi.responses import Response, StreamingResponse from ..core import get_logger from ..wallet import CurrencyUnit, recieve_token, send_token -from .cost_caculation import CostData, CostDataError, MaxCostData, calculate_cost +from .cost_caculation import ( + CostData, + CostDataError, + MaxCostData, + calculate_cost, +) from .helpers import ( UPSTREAM_BASE_URL, - check_token_balance, create_error_response, get_max_cost_for_model, prepare_upstream_headers, @@ -21,12 +25,7 @@ logger = get_logger(__name__) async def x_cashu_handler( - headers: dict, - request: Request, - x_cashu_token: str, - path: str, - max_cost_for_model: int, - request_body_dict: dict, + request: Request, x_cashu_token: str, path: str ) -> Response | StreamingResponse: """Handle X-Cashu token payment requests.""" logger.info( @@ -41,7 +40,6 @@ async def x_cashu_handler( ) try: - check_token_balance(headers, request_body_dict, max_cost_for_model) headers = dict(request.headers) amount, unit, mint = await recieve_token(x_cashu_token) headers = prepare_upstream_headers(dict(request.headers)) diff --git a/router/proxy.py b/router/proxy.py index 14c1f31c..0e772b1b 100644 --- a/router/proxy.py +++ b/router/proxy.py @@ -494,6 +494,8 @@ async def proxy( max_cost_for_model = get_cost_per_request( model=request_body_dict.get("model", None) ) + check_token_balance(headers, request_body_dict, max_cost_for_model) + # Handle authentication if x_cashu := headers.get("x-cashu", None): logger.info( @@ -503,13 +505,9 @@ async def proxy( "token_preview": x_cashu[:20] + "..." if len(x_cashu) > 20 else x_cashu, }, ) - return await x_cashu_handler( - headers, request, x_cashu, path, max_cost_for_model, request_body_dict - ) + return await x_cashu_handler(request, x_cashu, path) - check_token_balance(headers, request_body_dict, max_cost_for_model) - - if auth := headers.get("authorization", None): + elif auth := headers.get("authorization", None): logger.debug( "Processing bearer token authentication", extra={