Update app.py
Browse files185 unmodified lines18618718818919019119219319419519619719819920020120220320420520620720820921096 unmodified lines307308309310311312313314185 unmodified linesreturn codigo_actual, ultima, False# ─── SISTEMA DE LÍMITES ───def decrement_usage():global _USAGES_USAGES["count"] += 1return DEMO_LIMIT - _USAGES["count"]def check_usage(token):"""Retorna (ok, restante, footer_extra)"""if token:return True, -1, "" # -1 = ilimitado (usa su propia key)if _USAGES["blocked"]:return False, 0, "\n\n⛔ **Demo agotado.** Usa tu propia API key de Groq para continuar."restante = decrement_usage()if restante <= 0:_USAGES["blocked"] = Truereturn True, 0, "\n\n⛔ **Límite de 100 demos alcanzado.** Obtén tu key en [console.groq.com/keys](https://console.groq.com/keys) para uso ilimitado."return True, restante, None@spaces.GPU96 unmodified lines# ─── UI ───with gr.Blocks(title="Aura Programadora") as demo:gr.Markdown("# 💻 Aura Programadora (Groq)")with gr.Row():with gr.Column(scale=3):chatbot = gr.Chatbot(label="Chat", height=500)185 unmodified lines18618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621796 unmodified lines314315316317318319320321185 unmodified linesreturn codigo_actual, ultima, False# limite de apidef decrement_usage():global _USAGES# En lugar de sumar infinitamente y restar,# podemos llevar un contador de cuántas le quedan directamenteif "restantes" not in _USAGES:_USAGES["restantes"] = 100 # Tu límite inicial de demosif _USAGES["restantes"] > 0:_USAGES["restantes"] -= 1return _USAGES["restantes"]def check_usage(token):# 1. Si el usuario trae su propio token, se pasa sin límitesif token:return True, -1, ""# 2. Verificamos si ya está bloqueado por completoif _USAGES.get("blocked", False):return False, 0, "\n\n🔴 **Demo agotado.** Usa tu propia API Key para continuar."# 3. Restamos una consultarestante = decrement_usage()@spaces.GPU96 unmodified lines# ─── UI ───with gr.Blocks(title="Aura Code") as demo:gr.Markdown("# 💻 Aura Code")with gr.Row():with gr.Column(scale=3):chatbot = gr.Chatbot(label="Chat", height=500)
app.py+21-14