315315 height : auto;
316316 }
317317
318+ .back-button {
319+ position : fixed;
320+ bottom : 20px ;
321+ left : 20px ;
322+ }
323+
318324 .back-button__link {
319325 color : # 9c9c9c ;
320326 text-decoration : none;
328334 transition : all 0.3s ease-in-out;
329335 }
330336
337+ .model-select-container {
338+ display : flex;
339+ justify-content : flex-end;
340+ align-items : center;
341+ margin-bottom : 20px ;
342+ }
343+
344+ .model-select {
345+ position : fixed;
346+ top : 20px ;
347+ right : 20px ;
348+ padding : 10px ;
349+ border : none;
350+ border-radius : 15px ;
351+ background-color : var (--input-background );
352+ color : var (--text-color );
353+ font-size : 1rem ;
354+ z-index : 1 ;
355+ }
356+
357+ .model-select : focus {
358+ outline : none;
359+ }
360+
361+ .model-select option {
362+ background-color : var (--input-background );
363+ color : var (--text-color );
364+ }
365+
331366 @media (max-width : 768px ) {
332367 .back-button {
333- bottom : 10px ;
334- left : 10px ;
368+ display : none;
369+ }
370+
371+ .model-select {
372+ position : static;
373+ margin : 0 auto;
335374 }
336375 }
337376 </ style >
@@ -342,6 +381,11 @@ <h1>ChatGPT 100% local con WebGPU</h1>
342381 < div class ="creditos ">
343382 Por < a href ="https://mikeldev.com " target ="_blank " rel ="noopener noreferrer "> Mikel Echeverria</ a >
344383 </ div >
384+ < div class ="model-select-container ">
385+ < select id ="model-select " class ="model-select ">
386+ < option selected disabled value ="unselected "> Seleccionar modelo</ option >
387+ </ select >
388+ </ div >
345389 < main >
346390 < ul id ="chat-messages ">
347391 < li class ="message bot ">
@@ -413,10 +457,11 @@ <h1>ChatGPT 100% local con WebGPU</h1>
413457 alert ( 'Tu navegador no soporta WebGPU. Por favor, utiliza un navegador compatible como Chrome o Firefox. O tu dispositivo no soporta WebGPU.' ) ;
414458 }
415459
416- import { CreateMLCEngine } from "https://esm.run/@mlc-ai/web-llm" ; // Comentar esta línea si quieres desactivar el modelo
417-
418460 // https://github.com/mlc-ai/web-llm/blob/main/src/config.ts#L293 para ver los modelos disponibles
419- const SELECTED_MODEL = 'Phi-3.5-mini-instruct-q4f16_1-MLC' ; // Cambiar por el modelo que quieras usar usando el model_id
461+ const MODELS = {
462+ 'Phi3.5 mini - Rápido' : 'Phi-3.5-mini-instruct-q4f16_1-MLC' ,
463+ 'LLama3.1 - Inteligente' : 'Llama-3.1-8B-Instruct-q4f32_1-MLC-1k' ,
464+ } ;
420465
421466 const $ = el => document . querySelector ( el ) ;
422467
@@ -427,14 +472,31 @@ <h1>ChatGPT 100% local con WebGPU</h1>
427472 const $container = $ ( 'main' ) ;
428473 const $button = $ ( 'button' ) ;
429474 const $loadingMessage = $ ( 'small' ) ;
475+ const $modelSelect = document . getElementById ( 'model-select' ) ;
476+
477+ // Llenar el select con los modelos disponibles
478+ for ( const [ key , value ] of Object . entries ( MODELS ) ) {
479+ const option = document . createElement ( 'option' ) ;
480+ option . value = value ;
481+ option . textContent = key ;
482+ $modelSelect . appendChild ( option ) ;
483+ }
484+
485+ let SELECTED_MODEL = await new Promise ( ( resolve ) => {
486+ $modelSelect . addEventListener ( 'change' , ( ) => {
487+ resolve ( $modelSelect . value ) ;
488+ } ) ;
489+ } ) ;
490+
491+ import { CreateMLCEngine } from "https://esm.run/@mlc-ai/web-llm" ; // Comentar esta línea si quieres desactivar el modelo
430492
431493 // Cargar el modelo
432494 const engine = await CreateMLCEngine (
433495 SELECTED_MODEL ,
434496 {
435497 initProgressCallback : ( info ) => {
436498 console . log ( info ) ;
437- $loadingMessage . textContent = `Cargando modelo: ${ ( info . progress * 100 ) . toFixed ( 0 ) } %` ;
499+ $button . textContent = `Cargando modelo: ${ ( info . progress * 100 ) . toFixed ( 0 ) } %` ;
438500 if ( info . progress === 1 ) {
439501 $button . removeAttribute ( 'disabled' ) ;
440502 }
0 commit comments