Spaces:
Running
Running
| <html lang="fr"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Prenma - Générateur de noms (modèle)</title> | |
| <style> | |
| body { | |
| font-family: Arial, sans-serif; | |
| background-color: #000; | |
| color: #ff1493; /* Rose */ | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| min-height: 100vh; | |
| margin: 0; | |
| } | |
| .container { | |
| background-color: #1a1a1a; | |
| padding: 30px; | |
| border-radius: 10px; | |
| box-shadow: 0 0 20px rgba(255, 20, 147, 0.5); | |
| text-align: center; | |
| width: 90%; | |
| max-width: 500px; | |
| } | |
| h1 { | |
| color: #fff; | |
| margin-bottom: 20px; | |
| } | |
| .input-group { | |
| margin-bottom: 20px; | |
| text-align: left; | |
| } | |
| .input-group label { | |
| display: block; | |
| margin-bottom: 5px; | |
| color: #fff; | |
| } | |
| .input-group input[type="number"], | |
| .input-group select { | |
| width: 100%; | |
| padding: 10px; | |
| border: 2px solid #ff1493; | |
| background-color: #2c2c2c; | |
| color: #ff1493; | |
| border-radius: 5px; | |
| box-sizing: border-box; | |
| font-size: 16px; | |
| } | |
| .checkbox-group { | |
| display: flex; | |
| align-items: center; | |
| margin-bottom: 20px; | |
| } | |
| .checkbox-group input[type="checkbox"] { | |
| margin-right: 10px; | |
| } | |
| .checkbox-group label { | |
| color: #fff; | |
| } | |
| button { | |
| background-color: #ff1493; | |
| color: #fff; | |
| border: none; | |
| padding: 12px 25px; | |
| border-radius: 5px; | |
| cursor: pointer; | |
| font-size: 18px; | |
| transition: background-color 0.3s ease; | |
| } | |
| button:hover { | |
| background-color: #e00e7a; | |
| } | |
| #result { | |
| margin-top: 30px; | |
| padding: 15px; | |
| background-color: #2c2c2c; | |
| border: 2px solid #ff1493; | |
| border-radius: 5px; | |
| font-size: 24px; | |
| color: #fff; | |
| word-wrap: break-word; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <h1>Prenma</h1> | |
| <p>Ton partenaire de noms et pseudos uniques</p> | |
| <div class="input-group"> | |
| <label for="nameLength">Longueur du nom (3-15) :</label> | |
| <input type="number" id="nameLength" min="3" max="15" value="8"> | |
| </div> | |
| <div class="input-group"> | |
| <label for="nameStyle">Style de nom :</label> | |
| <select id="nameStyle"> | |
| <option value="fantasy">Fantasy</option> | |
| <option value="real">Nom réel</option> | |
| </select> | |
| </div> | |
| <div class="checkbox-group"> | |
| <input type="checkbox" id="includeNumbers"> | |
| <label for="includeNumbers">Inclure des chiffres</label> | |
| </div> | |
| <button id="generateBtn">Générer</button> | |
| <div id="result"> | |
| Nom généré : | |
| </div> | |
| </div> | |
| <script type="module"> | |
| const modelName = 'Clemylia/Prenma-model'; | |
| let prenmaModel = null; | |
| let isModelReady = false; | |
| // Récupération des éléments HTML | |
| const resultDiv = document.getElementById('result'); | |
| const nameLengthInput = document.getElementById('nameLength'); | |
| const nameStyleSelect = document.getElementById('nameStyle'); | |
| const includeNumbersCheckbox = document.getElementById('includeNumbers'); | |
| const generateBtn = document.getElementById('generateBtn'); | |
| // Fonction pour charger le modèle | |
| async function initializeModel() { | |
| resultDiv.textContent = 'Chargement du modèle...'; | |
| try { | |
| const response = await fetch(`https://huggingface.co/${modelName}/raw/main/prenma.js`); | |
| if (!response.ok) { | |
| throw new Error(`Erreur de téléchargement : ${response.statusText}`); | |
| } | |
| const scriptText = await response.text(); | |
| const scriptBlob = new Blob([scriptText], { type: 'application/javascript' }); | |
| const scriptUrl = URL.createObjectURL(scriptBlob); | |
| const module = await import(scriptUrl); | |
| prenmaModel = new module.default(); | |
| isModelReady = true; | |
| resultDiv.textContent = 'Modèle Prenma prêt !'; | |
| } catch (error) { | |
| resultDiv.textContent = `Erreur de chargement : ${error.message}`; | |
| console.error(error); | |
| } | |
| } | |
| // Fonction pour obtenir les options de l'interface et appeler le modèle | |
| async function getModelResponse() { | |
| if (!isModelReady) { | |
| resultDiv.textContent = "Le modèle n'est pas encore prêt. Veuillez patienter."; | |
| return; | |
| } | |
| resultDiv.textContent = 'Génération en cours...'; | |
| // Création de l'objet d'options | |
| const options = { | |
| length: parseInt(nameLengthInput.value), | |
| style: nameStyleSelect.value, | |
| includeNumbers: includeNumbersCheckbox.checked, | |
| }; | |
| try { | |
| const result = await prenmaModel.generate(options); | |
| resultDiv.textContent = 'Nom généré : ' + result[0].generated_text; | |
| } catch (error) { | |
| resultDiv.textContent = `Erreur de génération : ${error.message}`; | |
| console.error(error); | |
| } | |
| } | |
| // Attacher l'écouteur d'événement au bouton | |
| generateBtn.addEventListener('click', getModelResponse); | |
| // Lancer le chargement du modèle au début | |
| initializeModel(); | |
| </script> | |
| </body> | |
| </html> |