File size: 7,993 Bytes
5c22e4f ec12744 5c22e4f ec12744 5c22e4f ec12744 5c22e4f ec12744 8180890 ec12744 5c22e4f ec12744 5c22e4f ec12744 5c22e4f 8180890 ec12744 5c22e4f ec12744 5c22e4f ec12744 5c22e4f ec12744 5c22e4f ec12744 5c22e4f ec12744 5c22e4f ec12744 5c22e4f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | import gradio as gr
from huggingface_hub import InferenceClient
import os
import json
import requests
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from fastapi.staticfiles import StaticFiles
# ====================== CONFIGURATION ======================
client = InferenceClient("meta-llama/Meta-Llama-3-8B-Instruct", token=os.getenv("HF_TOKEN"))
SPECIAL_USERS = {"nastlach", "spikelatour"}
paid_users = {}
user_usage = {}
LIMIT_FREE = 3
PRICE_PRO = "29.00"
CURRENCY = "EUR"
# ====================== FASTAPI + PWA ======================
app = FastAPI()
# Dossier static pour PWA
try:
os.makedirs("static", exist_ok=True)
except:
pass
# Manifest PWA
@app.get("/manifest.json")
async def get_manifest():
return {
"name": "AI Money Machine PRO",
"short_name": "AI Money",
"description": "IA Business - Dropshipping, OnlyFans, Crypto, Dubaï",
"start_url": "/",
"display": "standalone",
"background_color": "#1a1a2e",
"theme_color": "#00ff9d",
"icons": [
{"src": "/static/icon-192.png", "sizes": "192x192", "type": "image/png"},
{"src": "/static/icon-512.png", "sizes": "512x512", "type": "image/png"}
]
}
app.mount("/static", StaticFiles(directory="static"), name="static")
# ====================== PAYPAL WEBHOOK (minimal) ======================
@app.post("/webhook")
async def paypal_webhook(request: Request):
try:
body = await request.json()
event_type = body.get("event_type")
if event_type in ["CHECKOUT.ORDER.APPROVED", "PAYMENT.CAPTURE.COMPLETED"]:
resource = body.get("resource", {})
custom_id = resource.get("purchase_units", [{}])[0].get("custom_id")
if custom_id:
user_key = str(custom_id).strip().lower()
paid_users[user_key] = True
# Sauvegarde persistante
with open("paid_users.json", "w", encoding="utf-8") as f:
json.dump(paid_users, f)
except:
pass
return JSONResponse({"status": "success"})
# ====================== FONCTIONS ======================
def ask_ai(prompt, stream=False):
try:
messages = [
{"role": "system", "content": "Tu es une IA experte en business en ligne. Réponds en Français de manière structurée et motivante."},
{"role": "user", "content": prompt}
]
output = client.chat_completion(
messages=messages,
max_tokens=1300,
temperature=0.75,
stream=stream
)
if stream:
for chunk in output:
if chunk.choices and chunk.choices[0].delta and chunk.choices[0].delta.content:
yield chunk.choices[0].delta.content
return
return output.choices[0].message.content
except Exception as e:
return f"Erreur technique : {str(e)}"
def valider_session(p):
if not p or len(p.strip()) < 2:
return gr.update(), gr.update(), gr.update(visible=False), "⚠️ Pseudo trop court (min. 2 caractères)."
return gr.update(interactive=False), gr.update(visible=False), gr.update(visible=True), f"✅ Pseudo '{p}' enregistré."
def generate_business_plan(service, details, user_id):
if not user_id or user_id.strip() == "":
yield "❌ Valide ton pseudo d’abord."
return
original_id = user_id.strip()
user_key = original_id.lower()
is_vip = user_key in SPECIAL_USERS
is_pro = user_key in paid_users
unlimited = is_vip or is_pro
count = user_usage.get(user_key, 0)
PREMIUM_SERVICES = {"💰 Conseils Bitcoin", "🪙 Management de Coins créés en d’autres",
"📱 Management OnlyFans", "🐦 Management X (Twitter)",
"🏙️ Stratégies Dubaï High-Ticket"}
if service in PREMIUM_SERVICES and not unlimited:
yield "❌ Ce service premium est réservé aux PRO ou VIP (nastlach / spikelatour)."
return
if not unlimited and count >= LIMIT_FREE:
yield """❌ **LIMITE ATTEINTE !**\n\n**PASSE À LA VERSION PRO POUR UN ACCÈS ILLIMITÉ**"""
return
# Message de réflexion
if is_vip:
thinking = "🤖 **L'IA réfléchit...**\n\n✅ **ACCÈS VIP TOTAL** → Tout est gratuit et illimité"
elif is_pro:
thinking = "🤖 **L'IA réfléchit...**\n\n✅ **PRO ACTIVÉ** → Accès illimité"
else:
thinking = f"🤖 **L'IA réfléchit...**\n\n**PASSE À LA VERSION PRO POUR PLUS DE RAPIDITÉ**\n📊 Essais restants : {LIMIT_FREE - count}"
yield thinking
# Prompts
base_prompts = {
"💡 Produit gagnant": "Trouve un produit dropshipping gagnant avec analyse.",
"🔥 Script TikTok": "Ecris un script TikTok viral avec accroche.",
"🛒 Boutique": "Donne 3 étapes clés pour lancer une boutique.",
"📈 Scaling": "Explique comment passer de 100€ à 1000€ de profit.",
"✍️ Question Libre": "Réponds à cette question business :",
"💰 Conseils Bitcoin": "Expert crypto. Conseils complets sur Bitcoin.",
"🪙 Management de Coins créés en d’autres": "Expert en management de coins et cryptos.",
"📱 Management OnlyFans": "Expert OnlyFans : croissance, contenu et monétisation.",
"🐦 Management X (Twitter)": "Expert Twitter/X : croissance et monétisation.",
"🏙️ Stratégies Dubaï High-Ticket": "Expert ventes high-ticket style Dubaï."
}
prompt_final = base_prompts.get(service, "") + f" Détails : {details}"
ai_response = ""
for chunk in ask_ai(prompt_final, stream=True):
ai_response += chunk
yield f"{thinking}\n\n{ai_response}"
if not unlimited:
user_usage[user_key] = count + 1
remaining = "✅ **ACCÈS ILLIMITÉ TOTAL** 🎉" if unlimited else f"📊 Essais restants : {LIMIT_FREE - user_usage[user_key]}"
yield f"{ai_response}\n\n---\n{remaining}"
# ====================== INTERFACE ======================
with gr.Blocks(
theme=gr.themes.Soft(),
title="AI Money Machine PRO",
head="""
<link rel="manifest" href="/manifest.json">
<meta name="theme-color" content="#00ff9d">
"""
) as demo:
gr.Markdown("# 💸 AI MONEY MACHINE PRO")
gr.Markdown("ℹ️ Rafraîchis la page (F5) pour changer de pseudo")
with gr.Row():
pseudo = gr.Textbox(label="👤 Ton Pseudo", placeholder="Ex: nastlach ou spikelatour", scale=3)
btn_valider = gr.Button("✅ Valider", variant="primary", scale=1)
with gr.Column(visible=False) as business_section:
gr.Markdown("---")
btn_pay = gr.Button("💎 Payer 29€ PayPal → PRO Illimité", variant="stop", size="large")
payment_status = gr.Markdown("")
choix = gr.Dropdown(
choices=["💡 Produit gagnant", "🔥 Script TikTok", "🛒 Boutique", "📈 Scaling", "✍️ Question Libre",
"💰 Conseils Bitcoin", "🪙 Management de Coins créés en d’autres",
"📱 Management OnlyFans", "🐦 Management X (Twitter)",
"🏙️ Stratégies Dubaï High-Ticket"],
label="Service",
value="💡 Produit gagnant"
)
details = gr.Textbox(label="🎯 Détails spécifiques", placeholder="Niche, budget, objectifs...", lines=3)
btn_go = gr.Button("🚀 GÉNÉRER MON PLAN", variant="primary")
output_text = gr.Markdown(label="📋 Résultat")
# Logique
btn_valider.click(valider_session, inputs=[pseudo], outputs=[pseudo, btn_valider, business_section, output_text])
btn_go.click(generate_business_plan, inputs=[choix, details, pseudo], outputs=output_text)
# btn_pay.click(...) → à ajouter si tu veux le paiement dynamique
# ====================== LANCEMENT ======================
app = gr.mount_gradio_app(app, demo, path="/") |