-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
330 lines (292 loc) · 13 KB
/
app.py
File metadata and controls
330 lines (292 loc) · 13 KB
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
import streamlit as st
import re
from clemscript_analyzer import ClemScriptAnalyzer
from code_generator import CodeGenerator
from tutorial_page import show_tutorial_page
def main():
st.set_page_config(
page_title="CléfistAI - Générateur ClemScript",
page_icon="🐱",
layout="wide",
initial_sidebar_state="expanded"
)
# Style CSS personnalisé pour un look kawaii
st.markdown("""
<style>
.main {
background: linear-gradient(135deg, #ffeef8 0%, #e8f5ff 100%);
}
.stButton > button {
background: linear-gradient(45deg, #ff9db4, #ffc1dc);
color: white;
border: none;
border-radius: 20px;
font-weight: bold;
transition: all 0.3s ease;
}
.stButton > button:hover {
transform: scale(1.05);
box-shadow: 0 5px 15px rgba(255, 157, 180, 0.4);
}
.css-1d391kg {
background: rgba(255, 255, 255, 0.8);
border-radius: 15px;
padding: 20px;
backdrop-filter: blur(10px);
}
.stTextArea > div > div > textarea {
border-radius: 15px;
border: 2px solid #ffc1dc;
}
.stSelectbox > div > div > select {
border-radius: 15px;
border: 2px solid #ffc1dc;
}
</style>
""", unsafe_allow_html=True)
# Navigation entre les pages
st.sidebar.title("🐱 Navigation CléfistAI")
page = st.sidebar.selectbox(
"🌟 Choisissez votre destination magique :",
["🪄 Générateur", "📚 Tutoriel", "ℹ️ À propos"],
help="Naviguez entre les différentes sections de CléfistAI !"
)
if page == "📚 Tutoriel":
show_tutorial_page()
return
elif page == "ℹ️ À propos":
show_about_page()
return
# Page principale - Générateur
st.title("🐱✨ CléfistAI - Générateur ClemScript ✨🐱")
st.markdown("*🌸 Votre adorable IA générative pour créer du code ClemScript ! 🌸*")
st.markdown("---")
# Sidebar avec informations kawaii
with st.sidebar:
st.markdown("<div style='text-align: center;'>🐾✨ Guide Neko ✨🐾</div>", unsafe_allow_html=True)
st.markdown("")
st.markdown("**🌟 Exemples de prompts magiques :**")
st.markdown("""
🐱 "Créer une variable nom avec la valeur Clem"
🌈 "Affiche bonjour le monde en vert"
🔄 "Fais une boucle de 1 à 10"
🧮 "Calcule le carré de 8"
🏰 "Crée une interaction avec château et forêt"
🎲 "Génère un nombre aléatoire entre 1 et 100"
💬 "Demande l'âge à l'utilisateur"
📝 "Ajoute un commentaire explicatif"
❓ "Si x est plus grand que 20 alors affiche grand"
""")
st.markdown("")
st.markdown("**🎨 Pouvoirs magiques disponibles :**")
st.markdown("""
🏷️ **Variables** : créer, stocker, initialiser
💬 **Affichage** : console, messages colorés
🔀 **Conditions** : si/alors, comparaisons
🔄 **Boucles** : répétitions magiques
🏰 **Aventures** : interactions et choix
🧮 **Maths** : carré, racine, valeur absolue
🌈 **Couleurs** : rouge, vert, bleu, rose...
❓ **Quiz** : questions intelligentes
🎲 **Hasard** : nombres et textes aléatoires
📝 **Notes** : commentaires mignons
⚡ **Fonctions** : sous-programmes kawaii
""")
st.markdown("")
st.markdown("<div style='text-align: center;'>🐾 Fait avec ❤️ par Clemylia 🐾</div>", unsafe_allow_html=True)
# Interface principale
col1, col2 = st.columns([1, 1])
with col1:
st.markdown("<h3 style='text-align: center; color: #ff69b4;'>✨ Zone Magique de Création ✨</h3>", unsafe_allow_html=True)
st.markdown("")
prompt = st.text_area(
"🐱 Décrivez votre idée magique en français :",
placeholder="Exemple magique : Je veux créer une variable chat avec la valeur 'Neko' et l'afficher en rose ! 🌸",
height=180,
help="✨ Parlez naturellement à CléfistAI, elle comprend le français comme un vrai chat magique ! 🐾"
)
if st.button("🪄✨ Créer la Magie ! ✨🪄", type="primary", use_container_width=True):
if prompt.strip():
# Initialiser l'analyseur et le générateur
analyzer = ClemScriptAnalyzer()
generator = CodeGenerator()
with st.spinner("🐱✨ Analyse de votre magie en cours... ✨🐱"):
# Analyser le prompt
analysis = analyzer.analyze(prompt)
# Générer le code
generated_code = generator.generate_code(analysis, prompt)
# Stocker dans la session pour affichage
st.session_state.generated_code = generated_code
st.session_state.analysis = analysis
st.rerun()
else:
st.warning("🐾 Veuillez entrer votre idée magique avant de créer le code ! 🐾")
with col2:
st.markdown("<h3 style='text-align: center; color: #ff69b4;'>🐾 Code Magique Généré 🐾</h3>", unsafe_allow_html=True)
if hasattr(st.session_state, 'generated_code') and st.session_state.generated_code:
# Afficher l'analyse détectée avec style kawaii
if hasattr(st.session_state, 'analysis'):
analysis = st.session_state.analysis
if analysis['concepts']:
st.markdown("**🎯 Magie détectée :**")
concepts_emojis = {
'variable': '🏷️', 'console': '💬', 'condition': '🔀', 'boucle': '🔄',
'input': '📝', 'math': '🧮', 'color': '🌈', 'quiz': '❓',
'interaction': '🎮', 'random': '🎲', 'comment': '📝', 'function': '⚡'
}
concept_display = []
for concept in analysis['concepts']:
emoji = concepts_emojis.get(concept, '✨')
concept_display.append(f"{emoji} {concept}")
st.success(f"**Concepts magiques :** {', '.join(concept_display)}")
if analysis['values']:
st.markdown("**📊 Valeurs extraites par la magie :**")
for key, value in analysis['values'].items():
st.info(f"**🔮 {key} :** {value}")
# Afficher le code généré avec style kawaii
st.markdown("**💻✨ Votre code magique ClemScript :**")
st.code(st.session_state.generated_code, language='text')
# Boutons kawaii
col_btn1, col_btn2 = st.columns(2)
with col_btn1:
if st.button("📋🐱 Copier la magie", use_container_width=True):
st.balloons()
st.success("🎉 Code copié ! Votre magie est prête ! 🐾")
with col_btn2:
if st.button("🔄✨ Nouvelle magie", use_container_width=True):
if 'generated_code' in st.session_state:
del st.session_state.generated_code
if 'analysis' in st.session_state:
del st.session_state.analysis
st.rerun()
else:
st.markdown("""
<div style='text-align: center; padding: 30px; background: linear-gradient(45deg, #ffeef8, #e8f5ff); border-radius: 15px; border: 2px dashed #ffc1dc;'>
<h4>🐱✨ Prête pour la magie ! ✨🐱</h4>
<p>Tapez votre idée magique et je créerai du code ClemScript pour vous ! 🌸</p>
<p>🐾 Clemylia attend vos instructions... 🐾</p>
</div>
""", unsafe_allow_html=True)
# Section exemples kawaii
st.markdown("")
st.markdown("<h2 style='text-align: center; color: #ff69b4;'>🌟✨ Exemples Magiques ✨🌟</h2>", unsafe_allow_html=True)
st.markdown("<p style='text-align: center; color: #ff69b4;'>🐾 Découvrez la magie de CléfistAI avec ces exemples adorables ! 🐾</p>", unsafe_allow_html=True)
examples = [
{
"prompt": "Créer une variable nom avec la valeur Clemylia",
"code": 'Clem var Script nom = "Clemylia";'
},
{
"prompt": "Affiche bienvenue en couleur verte",
"code": 'Clem color Script "green" "Bienvenue dans ClemScript!";'
},
{
"prompt": "Fais une boucle de 1 à 5",
"code": '''Clem for Script i Clem from Script 1 Clem to Script 5 Clem do Script {
Clem console Script -> "Index : " + i;
}'''
},
{
"prompt": "Calcule le carré de 7",
"code": '''Clem var Script resultat;
resultat = Clem math Script square 7;
Clem console Script -> "Résultat: " + resultat;'''
},
{
"prompt": "Crée une interaction avec forêt, montagne et océan",
"code": '''Clem var Script choix;
Clem input Script choix "Choisissez votre destination: ";
Clem interact Script choix "forêt", "montagne", "océan" Clem then Script {
Clem console Script -> "Vous explorez la mystérieuse forêt!";
} Clem else Script {
Clem console Script -> "Choix non reconnu";
}'''
},
{
"prompt": "Génère un nombre aléatoire entre 1 et 100",
"code": "Clem random valeur Script 1 100;"
},
{
"prompt": "Ajouter un commentaire explicatif",
"code": "# Ceci est un commentaire explicatif"
}
]
for i, example in enumerate(examples):
emoji_list = ["🐱", "🌸", "✨", "🎀", "🌟", "🐾", "💖"]
emoji = emoji_list[i % len(emoji_list)]
with st.expander(f"{emoji} Exemple {i+1}: {example['prompt']} {emoji}"):
st.markdown(f"**🪄 Prompt magique :** `{example['prompt']}`")
st.markdown("**💻 Code ClemScript généré :**")
st.code(example['code'], language='text')
def show_about_page():
"""Page à propos de CléfistAI"""
st.markdown("""
<div style='text-align: center; padding: 30px; background: linear-gradient(135deg, #ffeef8 0%, #e8f5ff 100%); border-radius: 15px;'>
<h1>🐱✨ À propos de CléfistAI ✨🐱</h1>
<p><strong>🌸 La première IA générative française pour ClemScript ! 🌸</strong></p>
</div>
""", unsafe_allow_html=True)
st.markdown("## 🎯 Mission")
st.markdown("""
CléfistAI a été créée avec amour par **Clemylia** pour démocratiser la programmation en français.
Notre mission est de rendre la création de code accessible à tous, en particulier aux francophones
qui veulent apprendre la programmation dans leur langue maternelle.
""")
st.markdown("## 🚀 Fonctionnalités Principales")
col1, col2, col3 = st.columns(3)
with col1:
st.markdown("""
**🧠 IA Intelligente**
- 550+ mots-clés français
- Analyse contextuelle avancée
- Détection d'intention
- Scoring de confiance
""")
with col2:
st.markdown("""
**💻 Génération ClemScript**
- Variables et affichage
- Conditions et boucles
- Interactions et quiz
- Math et couleurs
""")
with col3:
st.markdown("""
**🎨 Interface Kawaii**
- Design adorable et coloré
- Navigation intuitive
- Messages encourageants
- Expérience utilisateur magique
""")
st.markdown("## 📊 Statistiques Impressionnantes")
col1, col2, col3, col4 = st.columns(4)
with col1:
st.metric("🗣️ Mots-clés supportés", "550+")
with col2:
st.metric("🎯 Concepts détectés", "12")
with col3:
st.metric("🌍 Langues", "Français")
with col4:
st.metric("💖 Niveau de kawaii", "∞")
st.markdown("## 🛠️ Technologies Utilisées")
st.markdown("""
- **Python** : Langage de programmation principal
- **Streamlit** : Interface web interactive
- **Regex** : Analyse et extraction de patterns
- **CSS** : Stylisation kawaii personnalisée
- **Love & Magic** : L'ingrédient secret ! ✨
""")
st.markdown("## 🌟 Remerciements")
st.markdown("""
Un grand merci à tous les utilisateurs qui font vivre CléfistAI !
Votre enthousiasme et vos retours nous motivent à continuer d'améliorer cette IA magique.
""")
st.markdown("---")
st.markdown("""
<div style='text-align: center; padding: 20px; background: rgba(255, 255, 255, 0.7); border-radius: 10px;'>
<p><strong>🐾 Fait avec ❤️ par Clemylia 🐾</strong></p>
<p><em>« La magie de la programmation à portée de tous ! »</em></p>
</div>
""", unsafe_allow_html=True)
if __name__ == "__main__":
main()