FABLESLIP commited on
Commit
86b3d9f
·
verified ·
1 Parent(s): afd2a57

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -9
app.py CHANGED
@@ -905,39 +905,53 @@ if (warmupStartBtn){
905
 
906
 
907
 
908
-
909
- // Saisie optionnelle ; vide => on lance avec DEFAULT_MODELS définis plus haut (P4.1)
910
  const txt = prompt(
911
- 'Modèles (optionnel, séparés par des virgules).\n' +
912
  'Laisse vide pour utiliser la liste par défaut.',
913
  ''
914
  );
915
 
916
- let body;
917
  if (txt && txt.trim()){
918
- const mods = txt.split(',').map(s=>s.trim()).filter(Boolean);
919
- body = { models: mods.length ? mods : DEFAULT_MODELS };
 
 
920
  } else {
921
- body = { models: DEFAULT_MODELS };
 
 
 
 
 
 
 
 
 
922
  }
923
 
 
 
 
924
  try{
925
  const r = await fetch('/warmup/start', {
926
  method:'POST',
927
  headers:{ 'Content-Type':'application/json' },
928
- body: JSON.stringify(body)
929
  });
930
  if(!r.ok){
931
  const t = await r.text();
932
  alert('Échec démarrage: ' + r.status + ' ' + t);
933
  return;
934
  }
935
- openWarmupPopup();
936
  await refreshWarmupUI();
937
  if (!warmupTimer) warmupTimer = setInterval(refreshWarmupUI, 1000);
938
  }catch(e){
939
  alert('Erreur réseau');
940
  }
 
941
  });
942
  }
943
 
 
905
 
906
 
907
 
908
+ // Saisie optionnelle — accepte virgules, espaces, retours à la ligne, points-virgules
 
909
  const txt = prompt(
910
+ 'Modèles (optionnel). Tu peux séparer par virgule, espace ou retour à la ligne.\n' +
911
  'Laisse vide pour utiliser la liste par défaut.',
912
  ''
913
  );
914
 
915
+ let models;
916
  if (txt && txt.trim()){
917
+ // Découpe souple + nettoyage + dédoublonnage
918
+ const mods = txt.split(/[\s,;]+/).map(s=>s.trim()).filter(Boolean);
919
+ if (!mods.length){ alert('Aucun modèle détecté.'); return; }
920
+ models = Array.from(new Set(mods));
921
  } else {
922
+ // Liste par défaut définie plus haut (P4.1)
923
+ models = DEFAULT_MODELS;
924
+ }
925
+
926
+ // Ouvre la popup et affiche immédiatement la liste demandée
927
+ openWarmupPopup();
928
+ if (warmupPopupStatus) warmupPopupStatus.textContent = 'Préparation en cours…';
929
+ if (warmupLogs) {
930
+ warmupLogs.textContent = 'Warm-up demandé pour :\n' + models.map(m=>' • '+m).join('\n');
931
+ warmupLogs.scrollTop = warmupLogs.scrollHeight; // auto-scroll vers le bas
932
  }
933
 
934
+ // Sécurité : évite 2 timers concurrents
935
+ if (warmupTimer) { clearInterval(warmupTimer); warmupTimer = null; }
936
+
937
  try{
938
  const r = await fetch('/warmup/start', {
939
  method:'POST',
940
  headers:{ 'Content-Type':'application/json' },
941
+ body: JSON.stringify({ models })
942
  });
943
  if(!r.ok){
944
  const t = await r.text();
945
  alert('Échec démarrage: ' + r.status + ' ' + t);
946
  return;
947
  }
948
+ // Rafraîchit l’UI et démarre le polling
949
  await refreshWarmupUI();
950
  if (!warmupTimer) warmupTimer = setInterval(refreshWarmupUI, 1000);
951
  }catch(e){
952
  alert('Erreur réseau');
953
  }
954
+
955
  });
956
  }
957