Clemylia commited on
Commit
83bfd3e
·
verified ·
1 Parent(s): ccd752e

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +211 -19
index.html CHANGED
@@ -1,19 +1,211 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="fr">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Alphabet-bot - Récitation d'enfant</title>
7
+ <style>
8
+ /* Styles CSS inchangés pour un look cohérent */
9
+ body {
10
+ font-family: Arial, sans-serif;
11
+ background-color: #000;
12
+ color: #ff1493; /* Rose */
13
+ display: flex;
14
+ justify-content: center;
15
+ align-items: center;
16
+ min-height: 100vh;
17
+ margin: 0;
18
+ }
19
+
20
+ .container {
21
+ background-color: #1a1a1a;
22
+ padding: 30px;
23
+ border-radius: 10px;
24
+ box-shadow: 0 0 20px rgba(255, 20, 147, 0.5);
25
+ text-align: center;
26
+ width: 90%;
27
+ max-width: 500px;
28
+ }
29
+
30
+ h1 {
31
+ color: #fff;
32
+ margin-bottom: 5px;
33
+ }
34
+
35
+ p {
36
+ margin-bottom: 25px;
37
+ color: #ccc;
38
+ }
39
+
40
+ .input-group {
41
+ margin-bottom: 25px;
42
+ text-align: left;
43
+ }
44
+
45
+ .input-group label {
46
+ display: block;
47
+ margin-bottom: 8px;
48
+ color: #fff;
49
+ font-size: 16px;
50
+ }
51
+
52
+ .input-group input[type="range"] {
53
+ width: 100%;
54
+ -webkit-appearance: none;
55
+ height: 8px;
56
+ background: #444;
57
+ border-radius: 5px;
58
+ outline: none;
59
+ opacity: 0.7;
60
+ transition: opacity .2s;
61
+ }
62
+
63
+ .input-group input[type="range"]::-webkit-slider-thumb {
64
+ -webkit-appearance: none;
65
+ appearance: none;
66
+ width: 20px;
67
+ height: 20px;
68
+ border-radius: 50%;
69
+ background: #ff1493;
70
+ cursor: pointer;
71
+ }
72
+
73
+ #distractionValue {
74
+ color: #ff1493;
75
+ font-weight: bold;
76
+ margin-left: 10px;
77
+ }
78
+
79
+ button {
80
+ background-color: #ff1493;
81
+ color: #fff;
82
+ border: none;
83
+ padding: 12px 25px;
84
+ border-radius: 5px;
85
+ cursor: pointer;
86
+ font-size: 18px;
87
+ transition: background-color 0.3s ease;
88
+ }
89
+
90
+ button:hover {
91
+ background-color: #e00e7a;
92
+ }
93
+
94
+ #result {
95
+ margin-top: 30px;
96
+ padding: 15px;
97
+ background-color: #2c2c2c;
98
+ border: 2px solid #ff1493;
99
+ border-radius: 5px;
100
+ font-size: 18px;
101
+ text-align: left;
102
+ min-height: 50px;
103
+ color: #fff;
104
+ word-wrap: break-word;
105
+ }
106
+ </style>
107
+ </head>
108
+ <body>
109
+
110
+ <div class="container">
111
+ <h1>Alphabet-bot</h1>
112
+ <p>Simule la récitation de l'alphabet par un enfant de 5 ans.</p>
113
+
114
+ <div class="input-group">
115
+ <label for="distractionLevel">Niveau de Distraction : <span id="distractionValue">0.5</span></label>
116
+ <input type="range" id="distractionLevel" min="0" max="1" step="0.05" value="0.5">
117
+ <small style="color:#aaa;">0.0 = Récitation Parfaite | 1.0 = Très Distrait</small>
118
+ </div>
119
+
120
+ <button id="generateBtn">Réciter l'alphabet !</button>
121
+
122
+ <div id="result">
123
+ Récitation générée :
124
+ </div>
125
+ </div>
126
+
127
+ <script type="module">
128
+ // *** PARAMÈTRES DE CHARGEMENT DU MODÈLE DISTANT ***
129
+ // L'ID du dépôt modèle (ton espace et le nom du modèle)
130
+ const modelRepoId = 'prototypes-cl/Alphabet-bot';
131
+ // Le nom du fichier JS dans le dépôt
132
+ const modelFileName = 'Alphabet.js';
133
+
134
+ let alphabetBotModel = null;
135
+ let isModelReady = false;
136
+
137
+ // Récupération des éléments HTML
138
+ const resultDiv = document.getElementById('result');
139
+ const distractionLevelInput = document.getElementById('distractionLevel');
140
+ const distractionValueSpan = document.getElementById('distractionValue');
141
+ const generateBtn = document.getElementById('generateBtn');
142
+
143
+ // Mettre à jour la valeur affichée du curseur
144
+ distractionLevelInput.addEventListener('input', () => {
145
+ distractionValueSpan.textContent = distractionLevelInput.value;
146
+ });
147
+
148
+ // Fonction pour charger le modèle (Basée sur ta structure de référence)
149
+ async function initializeModel() {
150
+ resultDiv.textContent = 'Chargement du modèle...';
151
+ try {
152
+ // 1. Construit l'URL pour récupérer le fichier JS brut depuis le dépôt HF
153
+ const modelUrl = `https://huggingface.co/${modelRepoId}/raw/main/${modelFileName}`;
154
+
155
+ // 2. Récupère le contenu du fichier
156
+ const response = await fetch(modelUrl);
157
+ if (!response.ok) {
158
+ throw new Error(`Erreur de téléchargement : ${response.statusText} depuis ${modelUrl}`);
159
+ }
160
+ const scriptText = await response.text();
161
+
162
+ // 3. Crée un Blob et une URL pour l'importer dynamiquement comme module
163
+ const scriptBlob = new Blob([scriptText], { type: 'application/javascript' });
164
+ const scriptUrl = URL.createObjectURL(scriptBlob);
165
+
166
+ const module = await import(scriptUrl);
167
+
168
+ // 4. Instancie le modèle en appelant la méthode getInstance requise
169
+ alphabetBotModel = await module.default.getInstance();
170
+ isModelReady = true;
171
+ resultDiv.textContent = 'Modèle Alphabet-bot prêt !';
172
+ } catch (error) {
173
+ resultDiv.textContent = `Erreur de chargement. Vérifiez les droits et le chemin du fichier ${modelFileName}.`;
174
+ console.error(error);
175
+ }
176
+ }
177
+
178
+ // Fonction pour obtenir les options de l'interface et appeler le modèle
179
+ async function getModelResponse() {
180
+ if (!isModelReady) {
181
+ resultDiv.textContent = "Le modèle n'est pas prêt.";
182
+ return;
183
+ }
184
+
185
+ generateBtn.disabled = true;
186
+ resultDiv.textContent = 'Récitation en cours...';
187
+
188
+ const options = {
189
+ distractionLevel: parseFloat(distractionLevelInput.value),
190
+ };
191
+
192
+ try {
193
+ const result = await alphabetBotModel.generate(options);
194
+ resultDiv.textContent = result[0].generated_text;
195
+ } catch (error) {
196
+ resultDiv.textContent = `Erreur de génération : ${error.message}`;
197
+ console.error(error);
198
+ } finally {
199
+ generateBtn.disabled = false;
200
+ }
201
+ }
202
+
203
+ // Événements
204
+ generateBtn.addEventListener('click', getModelResponse);
205
+
206
+ // Initialisation
207
+ initializeModel();
208
+ </script>
209
+
210
+ </body>
211
+ </html>