L'IA génère du code candy adapté à ta demande en direct. Ou explore les 30+ exemples classés par domaine.
from candy import cfg, Tutor cfg.eleve.lang = "FR" cfg.eleve.style = "detailed" cfg.eleve.expertise = "beginner" cfg.eleve.tone = "encouraging" session = Tutor.chat(profile="eleve") print("🧮 Tuteur maths — 'quitter' pour arrêter\n") while True: q = input("Toi : ") if q.lower() == "quitter": break print(f"\nTuteur : {session.say(q)}\n") session.save("session_math.json")
from candy import cfg, Education cfg.p.lang = "FR" cfg.p.style = "detailed" cfg.p.output_format = "markdown" cfg.p.max_tokens = 2000 cours = open("cours.txt", encoding="utf-8").read() fiche = Education.use("p").ask( "Fiche de révision complète. Points clés, définitions, 5 Q&R.\n\n" + cours ) open("fiche.md", "w", encoding="utf-8").write(fiche) print("✅ fiche.md généré")
from candy import cfg, Education import json cfg.q.lang = "FR"; cfg.q.max_tokens = 1500 raw = Education.use("q").ask( "5 QCM sur la Révolution française. JSON : liste d'objets " "avec question, options A-D, reponse_correcte, explication." ) quiz = json.loads(raw); score = 0 for i, q in enumerate(quiz, 1): print(f"\nQ{i}. {q['question']}") [print(f" {o}") for o in q['options']] r = input("Réponse A/B/C/D : ").upper() if r == q['reponse_correcte']: print("✅ Correct !"); score += 1 else: print(f"❌ {q['explication']}") print(f"\nScore : {score}/5")
from candy import cfg, Language cfg.lang.lang = "FR" cfg.lang.tone = "encouraging" cfg.lang.expertise = "beginner" cfg.lang.max_tokens = 800 session = Language.chat(profile="lang") init = session.say( "Tu es mon prof d'espagnol. Je suis débutant absolu. " "Leçon 1 : les salutations. Explique, donne des exemples, fais-moi pratiquer." ) print(f"👨🏫 Cours d'espagnol\n{init}\n") while True: r = input("Moi : ") if r.lower() == "exit": break print(f"\nProf : {session.say(r)}\n")
from candy import cfg, Medicine cfg.sante.lang = "FR" cfg.sante.tone = "empathetic" cfg.sante.max_tokens = 1200 cfg.sante.context = ( "Informations médicales générales uniquement. " "Toujours terminer par : consulte un médecin pour un diagnostic." ) session = Medicine.chat(profile="sante") print("🏥 Assistant santé\n") while True: q = input("Question : ") if q.lower() == "exit": break print(f"\n{session.say(q)}\n{'─'*50}")
from candy import cfg, Medicine cfg.med.lang = "FR" cfg.med.expertise = "beginner" cfg.med.max_tokens = 1000 notice = open("notice.txt", encoding="utf-8").read() resume = Medicine.use("med").ask( "Simplifie pour un patient non médecin.\n" "1) À quoi ça sert 2) Comment le prendre\n" "3) Effets indésirables 4) Quand appeler un médecin\n\n" + notice ) print(resume) open("notice_simple.txt", "w").write(resume)
from candy import cfg, Psychology cfg.psy.lang = "FR" cfg.psy.tone = "empathetic" cfg.psy.max_tokens = 1000 cfg.psy.context = ( "Écoute active, questions ouvertes, bienveillance. " "Situation sérieuse → oriente vers un professionnel. Jamais de diagnostic." ) session = Psychology.chat(profile="psy") print("💙 Espace de soutien\n") while True: m = input("Toi : ") if m.lower() == "exit": break print(f"\n💙 {session.say(m)}\n")
from candy import cfg, Full cfg.bot.lang = "FR" cfg.bot.style = "professional" cfg.bot.tone = "friendly" cfg.bot.context = ( "Tu es l'assistant de CandyShop (vêtements sport). " "Livraison 3-5j, retours gratuits 30j, SAV : sav@candyshop.fr" ) session = Full.chat(profile="bot") print("🛍️ Assistant CandyShop\n") while True: m = input("Client : ") if m.lower() == "exit": break print(f"\nAssistant : {session.say(m)}\n")
from flask import Flask, request, jsonify, Response from candy import cfg, Full app = Flask(__name__) cfg.web.lang = "FR"; cfg.web.style = "detailed" sessions = {} @app.route("/chat", methods=["POST"]) def chat(): d = request.get_json() sid = d.get("session_id", "default") if sid not in sessions: sessions[sid] = Full.chat(profile="web") return jsonify({"reply": sessions[sid].say(d["message"])}) @app.route("/stream", methods=["POST"]) def stream(): msg = request.get_json()["message"] return Response( (f"data: {t}\n\n" for t in Full.use("web").stream(msg)), mimetype="text/event-stream") if __name__ == "__main__": app.run(debug=True)
from telegram.ext import ApplicationBuilder, CommandHandler, MessageHandler, filters from candy import cfg, Full cfg.tg.lang = "FR"; cfg.tg.style = "casual" sessions = {} async def start(u, c): sessions[u.effective_user.id] = Full.chat(profile="tg") await u.message.reply_text("👋 Pose-moi n'importe quelle question !") async def reply(u, c): uid = u.effective_user.id if uid not in sessions: sessions[uid] = Full.chat(profile="tg") await u.message.reply_text(sessions[uid].say(u.message.text)) app = ApplicationBuilder().token("TON_TOKEN").build() app.add_handler(CommandHandler("start", start)) app.add_handler(MessageHandler(filters.TEXT, reply)) app.run_polling()
from candy import cfg, Finance cfg.fin.lang = "FR"; cfg.fin.style = "detailed" cfg.fin.max_tokens = 1800 donnees = open("releves.csv").read() rapport = Finance.use("fin").ask( "Analyse ces relevés bancaires CSV.\n" "- Catégories et montants\n- Tendances et postes excessifs\n" "- 3 conseils concrets pour économiser\n\n" + donnees ) print(rapport) open("rapport_finances.md", "w").write(rapport)
from candy import cfg, Entrepreneur, Finance, Marketing cfg.bp.lang = "FR"; cfg.bp.max_tokens = 3000 projet = "App livraison repas sains, France, 25-40 ans" sections = [ (Entrepreneur, "Résumé exécutif, modèle éco, avantage compétitif"), (Marketing, "Analyse marché, cibles, go-to-market"), (Finance, "Projections 3 ans, coûts, revenus estimés"), ] bp = "# Business Plan\n\n" for mod, sujet in sections: bp += mod.use("bp").ask(f"Projet : {projet}\n{sujet}") + "\n\n---\n\n" open("business_plan.md", "w").write(bp) print("✅ business_plan.md")
from candy import cfg, Planner cfg.plan.lang = "FR"; cfg.plan.style = "detailed" cfg.plan.max_tokens = 2000 taches = [ "Rapport Q1 (3h, urgent)", "Réunion mardi 10h (1h)", "Réviser présentation (2h)", "Formation Python (4h)", ] planning = Planner.use("plan").ask( "Contraintes : 9h-18h, pause 12h-13h30, sport lundi/jeudi.\n" f"Tâches : {chr(10).join(taches)}\n\n" "Planning semaine heure par heure avec tips de focus." ) print(planning)
from candy import cfg, Writing cfg.mail.lang = "FR"; cfg.mail.style = "professional" cfg.mail.max_tokens = 400 demandes = [ "Relance facture impayée 30 jours", "Confirmation rdv partenaire jeudi 14h", "Remerciement après entretien", "Demande de devis prestataire logistique", "Excuses retard livraison + compensation", ] emails = Writing.use("mail").batch( [f"Email pro : {d}. Objet + corps." for d in demandes] ) for dem, email in zip(demandes, emails): print(f"\n📧 {dem}\n{email}\n{'─'*40}")
from candy import cfg, Summarizer from datetime import date cfg.veille.lang = "FR"; cfg.veille.style = "concise" cfg.veille.max_tokens = 500 articles = [ ("IA & Médecine", "contenu article 1..."), ("Cybersécurité 2026", "contenu article 2..."), ("Startup funding", "contenu article 3..."), ] rapport = f"# Veille — {date.today()}\n\n" for titre, contenu in articles: resume = Summarizer.use("veille").ask( f"Sujet: {titre}\n3 bullet points clés:\n{contenu}" ) rapport += f"## {titre}\n{resume}\n\n" open(f"veille_{date.today()}.md", "w").write(rapport) print("📰 Rapport généré ✓")
from candy import cfg, Reviewer, Debugger import sys cfg.rev.lang = "FR"; cfg.rev.expertise = "expert" cfg.rev.max_tokens = 2000 code = open(sys.argv[1]).read() review = Reviewer.use("rev").ask( "Review ce code. Chaque problème : localisation, explication, correction.\n\n" f"```python\n{code}\n```" ) print(review) refacto = Debugger.use("rev").ask( f"Version refactorisée :\n```python\n{code}\n```" ) open(f"refacto_{sys.argv[1]}", "w").write(refacto)
from candy import cfg, Security cfg.sec.lang = "FR"; cfg.sec.expertise = "expert" cfg.sec.max_tokens = 2500 code = open("app.py").read() audit = Security.use("sec").ask( "Audit sécurité complet. Injections SQL/XSS, secrets hardcodés, auth faible.\n" "Chaque problème : sévérité CRITIQUE/ÉLEVÉ/MOYEN/FAIBLE, ligne, correction.\n\n" f"```python\n{code}\n```" ) print(audit) open("audit.md", "w").write(audit)
from candy import cfg, Coding import os cfg.doc.lang = "FR"; cfg.doc.style = "technical" cfg.doc.max_tokens = 3000 for f in os.listdir("."): if not f.endswith(".py"): continue print(f"📝 {f}...") code = open(f).read() doc = Coding.use("doc").ask( "Génère la doc complète : docstrings Google-style, README, " f"exemples d'utilisation.\n\n```python\n{code}\n```" ) open(f"docs_{f}.md", "w").write(doc) print(f" → docs_{f}.md ✓")
from candy import cfg, Coding import json cfg.fix.lang = "FR"; cfg.fix.max_tokens = 2000 schema = { "table": "utilisateurs", "champs": ["id", "nom", "email", "age", "ville", "role"], "nb_lignes": 20 } raw = Coding.use("fix").ask( f"Génère {schema['nb_lignes']} lignes de données réalistes pour : {schema}. " "JSON valide uniquement, aucun commentaire." ) donnees = json.loads(raw) open("fixtures.json", "w").write(json.dumps(donnees, ensure_ascii=False, indent=2)) print(f"✅ {len(donnees)} fixtures générées")
from candy import cfg, Writing, Planner cfg.livre.lang = "FR"; cfg.livre.max_tokens = 4096 cfg.livre.style = "detailed" sujet = "L'intelligence artificielle dans la médecine" plan = Planner.use("livre").ask(f"Plan 10 chapitres pour : {sujet}. Liste numérotée.") chapitres = [l.strip() for l in plan.split("\n") if l.strip() and l.strip()[0].isdigit()] texte = f"# {sujet}\n\n" for i, t in enumerate(chapitres[:10], 1): print(f"✍️ Ch.{i}...") texte += f"## Ch.{i} — {t}\n\n" texte += Writing.use("livre").ask(f"Chapitre {i} : {t}. 500 mots, style fluide.") texte += "\n\n---\n\n" open("livre.md", "w").write(texte); print("📚 livre.md")
from candy import cfg, Translator cfg.tr.max_tokens = 300 texte = "Bienvenue sur notre plateforme. Nous sommes ravis de vous accueillir." langues = ["EN", "ES", "DE", "IT", "PT", "JA", "ZH", "AR"] traductions = Translator.use("tr").batch([ f"Traduis en {l}, renvoie UNIQUEMENT la traduction : {texte}" for l in langues ]) for l, t in zip(langues, traductions): print(f"[{l}] {t}")
from candy import cfg, Marketing cfg.mkt.lang = "FR"; cfg.mkt.tone = "enthusiastic" cfg.mkt.max_tokens = 400 produit = "Montre connectée sportive waterproof, autonomie 14j, 149€" plateformes = { "Instagram": "Post accrocheur, emojis, 150 mots, 5 hashtags", "LinkedIn": "Post professionnel B2B, 200 mots, ton sérieux", "Twitter/X": "Tweet max 280 caractères avec call-to-action", } for plateforme, style in plateformes.items(): post = Marketing.use("mkt").ask(f"Produit : {produit}\nPost {plateforme} : {style}") print(f"\n📱 {plateforme}\n{'='*40}\n{post}")
from candy import cfg, Analytic import pandas as pd cfg.data.lang = "FR"; cfg.data.expertise = "expert" cfg.data.max_tokens = 2000 df = pd.read_csv("donnees.csv") analyse = Analytic.use("data").ask( f"Colonnes : {list(df.columns)} | {len(df)} lignes\n" f"Aperçu :\n{df.head(5).to_string()}\n" f"Stats :\n{df.describe().to_string()}\n\n" "Tendances, anomalies, corrélations. 3 visualisations matplotlib." ) print(analyse)
from candy import cfg, Summarizer import os cfg.sum.lang = "FR"; cfg.sum.style = "concise" cfg.sum.max_tokens = 500 for doc in [f for f in os.listdir("docs/") if f.endswith(".txt")]: contenu = open(f"docs/{doc}", encoding="utf-8").read()[:6000] resume = Summarizer.use("sum").ask( "Résume : 1) Idée principale 2) Points clés (5 max) 3) Conclusion\n\n" + contenu ) print(f"\n📄 {doc}\n{resume}\n{'─'*40}")
from candy import cfg, Writing cfg.A.lang = "FR"; cfg.A.style = "casual" # Méthode 1 — stream_print() affiche directement Writing.use("A").stream_print("Raconte une courte histoire de pirate") # Méthode 2 — itérer token par token print("\n--- Méthode 2 ---\n") for token in Writing.use("A").stream("Décris un coucher de soleil"): print(token, end="", flush=True)
from candy import cfg, Law cfg.jur.lang = "FR"; cfg.jur.expertise = "expert" cfg.jur.max_tokens = 2500 contrat = open("contrat.txt", encoding="utf-8").read() session = Law.chat(profile="jur") analyse = session.say( "Analyse : clauses abusives, obligations de chaque partie, " f"risques, points de négociation.\n\n{contrat}" ) print("⚖️\n" + analyse) while True: q = input("\nQuestion ('exit') : ") if q.lower() == "exit": break print("\n" + session.say(q))
from candy import cfg, Entrepreneur cfg.pitch.lang = "FR"; cfg.pitch.max_tokens = 2500 startup = "GreenRoute — covoiturage éco longue distance, cherche 500k€ seed" slides = ["Problème & Solution", "Marché & Opportunité", "Produit & Demo", "Modèle économique", "Traction & Métriques", "Équipe", "Roadmap", "Financement & Use of funds"] deck = "# Pitch Deck\n\n" for s in slides: deck += Entrepreneur.use("pitch").ask( f"Startup : {startup}\nSlide '{s}' : contenu percutant, concis." ) + "\n\n" open("pitch.md", "w").write(deck); print("🚀 pitch.md")
from candy import cfg, Business cfg.rpt.lang = "FR"; cfg.rpt.max_tokens = 2500 cfg.rpt.output_format = "markdown" metriques = { "mois": "Mars 2026", "MRR": "42 500€ (+8%)", "nouveaux_clients": 87, "churn": "3.2%", "NPS": 68, "tickets_support": 234, } rapport = Business.use("rpt").ask( "Rapport mensuel structuré : résumé exécutif, points positifs, " "points d'attention, recommandations, KPIs en tableau ASCII.\n\n" f"Données : {metriques}" ) open("rapport.md", "w").write(rapport); print(rapport)
from candy import cfg, Storyteller cfg.rpg.lang = "FR"; cfg.rpg.tone = "dramatic" cfg.rpg.max_tokens = 600 cfg.rpg.context = ( "Tu es maître du jeu. Scènes vivantes, " "propose toujours 3 choix numérotés à la fin." ) session = Storyteller.chat(profile="rpg") intro = session.say("Aventure fantasy, mon perso : voleur elfe. Plante le décor.") print(f"🎭\n{intro}\n") while True: a = input("👤 Choix : ") if a.lower() == "exit": break print(f"\n{session.say(a)}\n")
from candy import cfg, Music cfg.music.lang = "FR"; cfg.music.style = "creative" cfg.music.max_tokens = 800 themes = [ ("pop mélancolique", "nostalgie de l'adolescence"), ("rap engagé", "l'injustice sociale"), ("chanson française", "un amour à Paris"), ] for style, theme in themes: paroles = Music.use("music").ask( f"Chanson {style} sur : {theme}. " "2 couplets, refrain ×2, pont. Rimes naturelles, images fortes." ) print(f"\n🎵 {style}\n{'='*40}\n{paroles}") open(f"{style.replace(' ','_')}.txt", "w").write(paroles)