import logging from sqlalchemy.ext.asyncio import AsyncSession from app.credit.exceptions import InsufficientCreditError from app.credit.models import CreditTransactionType from app.credit.services.credit_service import deduct_credit logger = logging.getLogger(__name__) async def consume_credit(user_uuid: str, session: AsyncSession, *, reason: str = "video generation") -> bool: """크레딧 1 차감. 기존 호출처와 시그니처 호환 유지.""" try: await deduct_credit( session=session, user_uuid=user_uuid, amount=1, type=CreditTransactionType.CONSUME, reason=reason, ) return True except InsufficientCreditError: return False