Spaces:
Running
Running
Update index.html
Browse files- index.html +22 -3
index.html
CHANGED
|
@@ -521,6 +521,15 @@
|
|
| 521 |
#ap-chat-panel { height:calc(100% - 86px); display:flex; flex-direction:column; }
|
| 522 |
#ap-chat-panel .chat-body { flex:1; height:auto; min-height:80px; }
|
| 523 |
#ap-supervision-panel { height:calc(100% - 86px); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 524 |
.ap-tabs { display:flex; border-bottom:1px solid #344361; }.ap-tabs button { flex:1; background:#17213a; color:#e0e6ed; border:0; padding:10px; cursor:pointer; }
|
| 525 |
[hidden] { display:none !important; }
|
| 526 |
#ap-supervision-panel { padding:12px; overflow:auto; user-select:text; }
|
|
@@ -769,7 +778,12 @@
|
|
| 769 |
</div>
|
| 770 |
<div class="ap-tabs"><button id="ap-tab-chat">Chat</button><button id="ap-tab-supervision">Supervisión <span id="ap-pending">0</span></button></div>
|
| 771 |
<div id="ap-chat-panel">
|
| 772 |
-
<div class="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 773 |
<div class="chat-footer">
|
| 774 |
<button id="ap-websearch" class="ap-mic" type="button" aria-pressed="false">🔎</button>
|
| 775 |
<input type="text" placeholder="Escribe un mensaje..." id="chatInput" aria-label="Mensaje para ALPHA" autocomplete="off">
|
|
@@ -982,8 +996,7 @@ const APFormat={
|
|
| 982 |
render(el,value){const text=String(value??'').slice(0,20000).replace(/\r\n?/g,'\n');let list=null,code=null;for(const line of text.split('\n')){if(/^\s*`{3}/.test(line)){if(code){el.append(code);code=null}else{list=null;code=document.createElement('pre')}continue}if(code){const span=document.createElement('code');span.textContent=line+'\n';code.append(span);continue}const bullet=line.match(/^\s*[-*]\s+(.+)$/);if(bullet){if(!list){list=document.createElement('ul');el.append(list)}const li=document.createElement('li');this.inline(li,bullet[1]);list.append(li);continue}list=null;if(!line.trim())continue;const p=document.createElement('p');this.inline(p,line.replace(/^#{1,4}\s+/,''));el.append(p)}if(code)el.append(code);if(!el.childNodes.length)el.textContent=text}
|
| 983 |
};
|
| 984 |
const AP = {
|
| 985 |
-
model: '
|
| 986 |
-
endpoints: ['https://api.fivetechsoft.com/zen/v1','https://api.fivetechsupport.com/zen/v1'],
|
| 987 |
models: null,
|
| 988 |
db: null, busy: false, store: null, cycleBusy:false, cycleTimer:null, cycleIntervalMs:30000, lastModelCycleAt:0, mode: localStorage.getItem('adaptapro-mode')==='autonomo'?'autonomo':'supervisado', agentsOn: localStorage.getItem('adaptapro-agents')!=='off',
|
| 989 |
money: n => 'USD '+new Intl.NumberFormat('en-US',{minimumFractionDigits:2,maximumFractionDigits:2}).format(n/100),
|
|
@@ -1053,6 +1066,8 @@ const AP = {
|
|
| 1053 |
closeChat(){const e=document.getElementById('chatWindow');e.hidden=true;e.style.display='none';localStorage.setItem('adaptapro-chat-open','false');},
|
| 1054 |
tab(which){const e=document.getElementById('chatWindow');e.hidden=false;e.style.display='block';localStorage.setItem('adaptapro-chat-open','true');document.getElementById('ap-chat-panel').hidden=which!=='chat';document.getElementById('ap-supervision-panel').hidden=which!=='supervision';},
|
| 1055 |
append(text,who){const el=document.createElement('div');el.className='chat-msg '+who;if(who==='ai')APFormat.render(el,text);else el.textContent=String(text);const body=document.querySelector('.chat-body');body.append(el);body.scrollTop=body.scrollHeight;},
|
|
|
|
|
|
|
| 1056 |
setAgentState(agent,label,working){const el=document.getElementById('ap-agent-'+agent);if(el){el.textContent=label;el.classList.toggle('ap-working',working);}},
|
| 1057 |
startCycle(...a){return APCommands.startCycle(...a);},
|
| 1058 |
cycle(...a){return APCommands.cycle(...a);},
|
|
@@ -1061,6 +1076,10 @@ const AP = {
|
|
| 1061 |
window.AP=AP;
|
| 1062 |
const APMic={button:document.getElementById('ap-mic'),recognition:null,active:false,start(){const Speech=window.SpeechRecognition||window.webkitSpeechRecognition;if(!Speech){this.button.disabled=true;this.button.title='Dictado no disponible en este navegador. Prueba Chrome.';this.button.setAttribute('aria-label',this.button.title);document.getElementById('chatInput').placeholder='Dictado no disponible aquí; escribe o prueba Chrome';return}if(this.active){this.recognition.stop();return}const input=document.getElementById('chatInput'),recognition=new Speech();this.recognition=recognition;recognition.lang='es-ES';recognition.continuous=false;recognition.interimResults=true;const prefix=input.value.trim();recognition.onstart=()=>{this.active=true;this.button.classList.add('is-listening');this.button.textContent='⏹';this.button.title='Detener dictado';this.button.setAttribute('aria-label','Detener dictado');this.button.setAttribute('aria-pressed','true')};recognition.onresult=e=>{let words='';for(let i=0;i<e.results.length;i++)words+=e.results[i][0].transcript;input.value=(prefix?prefix+' ':'')+words;input.focus()};recognition.onerror=e=>{if(e.error==='not-allowed'||e.error==='service-not-allowed')input.placeholder='Permite el micrófono en el navegador para dictar';else if(e.error!=='no-speech'&&e.error!=='aborted')input.placeholder='No se pudo dictar; puedes escribir el mensaje'};recognition.onend=()=>{this.active=false;this.button.classList.remove('is-listening');this.button.textContent='🎙️';this.button.title='Dictar mensaje';this.button.setAttribute('aria-label','Dictar mensaje');this.button.setAttribute('aria-pressed','false')};try{recognition.start()}catch(e){recognition.onend();input.placeholder='No se pudo iniciar el dictado; escribe el mensaje'}}};document.getElementById('ap-mic').addEventListener('click',()=>APMic.start());
|
| 1063 |
const apWebBtn=document.getElementById('ap-websearch');function updateWebBtn(){const on=localStorage.getItem('adaptapro-web-search')==='true';apWebBtn.setAttribute('aria-pressed',String(on));apWebBtn.classList.toggle('is-listening',on);apWebBtn.style.opacity=on?'1':'0.5';apWebBtn.title=on?'Búsqueda web ACTIVADA: el texto que escribas se envía también a Tavily y Wikipedia (gratuito, con límites); no se añade automáticamente inventario ni auditoría. No incluyas información confidencial. Pulsa para desactivar.':'Búsqueda web desactivada. Si la activas, el texto que escribas se envía también a Tavily y Wikipedia para buscar contexto; no se añade automáticamente inventario ni auditoría. No incluyas información confidencial.';}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1064 |
apWebBtn.addEventListener('click',()=>{const on=localStorage.getItem('adaptapro-web-search')!=='true';localStorage.setItem('adaptapro-web-search',String(on));updateWebBtn();AP.append(on?'🔎 Búsqueda web ACTIVADA. A partir de ahora, el texto que escribas se enviará también a Tavily y Wikipedia para buscar contexto (servicios externos, uso gratuito con límites). Las fuentes se citan tras cada respuesta. Se envía el texto que escribas; no se añade automáticamente inventario ni auditoría. No incluyas información confidencial.':'🔎 Búsqueda web desactivada. Tus mensajes ya no se envían a servicios de búsqueda.','ai');});updateWebBtn();
|
| 1065 |
function sendMessage(){const input=document.getElementById('chatInput');const text=input.value.trim();if(!text)return;input.value='';AP.ask(text);}
|
| 1066 |
document.getElementById('chatInput').addEventListener('keydown',e=>{if(e.key==='Enter')sendMessage();});
|
|
|
|
| 521 |
#ap-chat-panel { height:calc(100% - 86px); display:flex; flex-direction:column; }
|
| 522 |
#ap-chat-panel .chat-body { flex:1; height:auto; min-height:80px; }
|
| 523 |
#ap-supervision-panel { height:calc(100% - 86px); }
|
| 524 |
+
.ap-model-bar { display:flex; align-items:center; gap:8px; padding:6px 10px; background:#17213a; border-bottom:1px solid #344361; font-size:.8em; }
|
| 525 |
+
.ap-model-bar button { background:#2b7fff; color:#fff; border:0; border-radius:6px; padding:5px 10px; cursor:pointer; font-size:.92em; }
|
| 526 |
+
.ap-model-bar button:disabled { opacity:.5; cursor:default; }
|
| 527 |
+
.ap-model-bar span { color:#9fb3d1; }
|
| 528 |
+
.ap-model-progress { height:6px; background:#0e1526; }
|
| 529 |
+
.ap-model-progress div { height:100%; width:0%; background:#2b7fff; transition:width .3s; }
|
| 530 |
+
body[data-theme="light"] .ap-model-bar { background:#eef3fb; border-color:#c9d6e8; }
|
| 531 |
+
body[data-theme="light"] .ap-model-bar span { color:#4a5f7d; }
|
| 532 |
+
body[data-theme="light"] .ap-model-progress { background:#dbe4f0; }
|
| 533 |
.ap-tabs { display:flex; border-bottom:1px solid #344361; }.ap-tabs button { flex:1; background:#17213a; color:#e0e6ed; border:0; padding:10px; cursor:pointer; }
|
| 534 |
[hidden] { display:none !important; }
|
| 535 |
#ap-supervision-panel { padding:12px; overflow:auto; user-select:text; }
|
|
|
|
| 778 |
</div>
|
| 779 |
<div class="ap-tabs"><button id="ap-tab-chat">Chat</button><button id="ap-tab-supervision">Supervisión <span id="ap-pending">0</span></button></div>
|
| 780 |
<div id="ap-chat-panel">
|
| 781 |
+
<div class="ap-model-bar">
|
| 782 |
+
<button id="ap-model-load" type="button">⬇️ Descargar MiMo 9B (~5,8 GB)</button>
|
| 783 |
+
<span id="ap-model-state">Comprobando módulo del modelo…</span>
|
| 784 |
+
</div>
|
| 785 |
+
<div class="ap-model-progress" id="ap-model-progress" hidden><div></div></div>
|
| 786 |
+
<div class="chat-body" role="log" aria-label="Conversación con ALPHA" aria-live="polite" aria-relevant="additions"><div class="chat-msg ai">Consulta el inventario con ALPHA. El asistente usa un modelo MiMo 9B que se ejecuta en tu navegador: descárgalo con el botón de arriba la primera vez. Las propuestas requieren tu aprobación.</div></div>
|
| 787 |
<div class="chat-footer">
|
| 788 |
<button id="ap-websearch" class="ap-mic" type="button" aria-pressed="false">🔎</button>
|
| 789 |
<input type="text" placeholder="Escribe un mensaje..." id="chatInput" aria-label="Mensaje para ALPHA" autocomplete="off">
|
|
|
|
| 996 |
render(el,value){const text=String(value??'').slice(0,20000).replace(/\r\n?/g,'\n');let list=null,code=null;for(const line of text.split('\n')){if(/^\s*`{3}/.test(line)){if(code){el.append(code);code=null}else{list=null;code=document.createElement('pre')}continue}if(code){const span=document.createElement('code');span.textContent=line+'\n';code.append(span);continue}const bullet=line.match(/^\s*[-*]\s+(.+)$/);if(bullet){if(!list){list=document.createElement('ul');el.append(list)}const li=document.createElement('li');this.inline(li,bullet[1]);list.append(li);continue}list=null;if(!line.trim())continue;const p=document.createElement('p');this.inline(p,line.replace(/^#{1,4}\s+/,''));el.append(p)}if(code)el.append(code);if(!el.childNodes.length)el.textContent=text}
|
| 997 |
};
|
| 998 |
const AP = {
|
| 999 |
+
model: 'MiMo-V2.6-Distill-Qwen-9B (local en este navegador)',
|
|
|
|
| 1000 |
models: null,
|
| 1001 |
db: null, busy: false, store: null, cycleBusy:false, cycleTimer:null, cycleIntervalMs:30000, lastModelCycleAt:0, mode: localStorage.getItem('adaptapro-mode')==='autonomo'?'autonomo':'supervisado', agentsOn: localStorage.getItem('adaptapro-agents')!=='off',
|
| 1002 |
money: n => 'USD '+new Intl.NumberFormat('en-US',{minimumFractionDigits:2,maximumFractionDigits:2}).format(n/100),
|
|
|
|
| 1066 |
closeChat(){const e=document.getElementById('chatWindow');e.hidden=true;e.style.display='none';localStorage.setItem('adaptapro-chat-open','false');},
|
| 1067 |
tab(which){const e=document.getElementById('chatWindow');e.hidden=false;e.style.display='block';localStorage.setItem('adaptapro-chat-open','true');document.getElementById('ap-chat-panel').hidden=which!=='chat';document.getElementById('ap-supervision-panel').hidden=which!=='supervision';},
|
| 1068 |
append(text,who){const el=document.createElement('div');el.className='chat-msg '+who;if(who==='ai')APFormat.render(el,text);else el.textContent=String(text);const body=document.querySelector('.chat-body');body.append(el);body.scrollTop=body.scrollHeight;},
|
| 1069 |
+
appendStream(text){if(!text)return;const body=document.querySelector('.chat-body');if(!this._streamEl){const el=document.createElement('div');el.className='chat-msg ai';body.append(el);this._streamEl=el;}this._streamEl.textContent=text;body.scrollTop=body.scrollHeight;},
|
| 1070 |
+
appendFinal(text){const el=this._streamEl;this._streamEl=null;if(!el)return;if(text&&String(text).trim())APFormat.render(el,text);else el.remove();},
|
| 1071 |
setAgentState(agent,label,working){const el=document.getElementById('ap-agent-'+agent);if(el){el.textContent=label;el.classList.toggle('ap-working',working);}},
|
| 1072 |
startCycle(...a){return APCommands.startCycle(...a);},
|
| 1073 |
cycle(...a){return APCommands.cycle(...a);},
|
|
|
|
| 1076 |
window.AP=AP;
|
| 1077 |
const APMic={button:document.getElementById('ap-mic'),recognition:null,active:false,start(){const Speech=window.SpeechRecognition||window.webkitSpeechRecognition;if(!Speech){this.button.disabled=true;this.button.title='Dictado no disponible en este navegador. Prueba Chrome.';this.button.setAttribute('aria-label',this.button.title);document.getElementById('chatInput').placeholder='Dictado no disponible aquí; escribe o prueba Chrome';return}if(this.active){this.recognition.stop();return}const input=document.getElementById('chatInput'),recognition=new Speech();this.recognition=recognition;recognition.lang='es-ES';recognition.continuous=false;recognition.interimResults=true;const prefix=input.value.trim();recognition.onstart=()=>{this.active=true;this.button.classList.add('is-listening');this.button.textContent='⏹';this.button.title='Detener dictado';this.button.setAttribute('aria-label','Detener dictado');this.button.setAttribute('aria-pressed','true')};recognition.onresult=e=>{let words='';for(let i=0;i<e.results.length;i++)words+=e.results[i][0].transcript;input.value=(prefix?prefix+' ':'')+words;input.focus()};recognition.onerror=e=>{if(e.error==='not-allowed'||e.error==='service-not-allowed')input.placeholder='Permite el micrófono en el navegador para dictar';else if(e.error!=='no-speech'&&e.error!=='aborted')input.placeholder='No se pudo dictar; puedes escribir el mensaje'};recognition.onend=()=>{this.active=false;this.button.classList.remove('is-listening');this.button.textContent='🎙️';this.button.title='Dictar mensaje';this.button.setAttribute('aria-label','Dictar mensaje');this.button.setAttribute('aria-pressed','false')};try{recognition.start()}catch(e){recognition.onend();input.placeholder='No se pudo iniciar el dictado; escribe el mensaje'}}};document.getElementById('ap-mic').addEventListener('click',()=>APMic.start());
|
| 1078 |
const apWebBtn=document.getElementById('ap-websearch');function updateWebBtn(){const on=localStorage.getItem('adaptapro-web-search')==='true';apWebBtn.setAttribute('aria-pressed',String(on));apWebBtn.classList.toggle('is-listening',on);apWebBtn.style.opacity=on?'1':'0.5';apWebBtn.title=on?'Búsqueda web ACTIVADA: el texto que escribas se envía también a Tavily y Wikipedia (gratuito, con límites); no se añade automáticamente inventario ni auditoría. No incluyas información confidencial. Pulsa para desactivar.':'Búsqueda web desactivada. Si la activas, el texto que escribas se envía también a Tavily y Wikipedia para buscar contexto; no se añade automáticamente inventario ni auditoría. No incluyas información confidencial.';}
|
| 1079 |
+
const apModelBtn=document.getElementById('ap-model-load'),apModelState=document.getElementById('ap-model-state'),apModelProg=document.getElementById('ap-model-progress'),apModelBar=apModelProg.querySelector('div');
|
| 1080 |
+
function apModelUI(){if(!globalThis.APLocalModel){apModelState.textContent='Cargando módulo del modelo…';apModelBtn.disabled=true;return;}const st=APLocalModel.state;apModelBtn.disabled=st==='downloading';apModelBtn.hidden=st==='ready';if(st==='ready'){apModelState.textContent='MiMo 9B listo: se ejecuta en este navegador (WASM/CPU).';apModelProg.hidden=true;}else if(st==='downloading'){apModelProg.hidden=false;}else{apModelProg.hidden=true;apModelState.textContent=st==='error'?'Error al cargar: '+APLocalModel.error+'. Pulsa el botón para reintentar.':'Modelo local (WASM/CPU, sin aceleración garantizada). Descarga inicial aprox. 5,8 GB; se reutiliza mientras se conserve la caché de este navegador. Necesita memoria libre suficiente: en equipos justos puede ir lento o no cargar.';}}
|
| 1081 |
+
apModelBtn.addEventListener('click',async()=>{apModelBtn.disabled=true;apModelProg.hidden=false;apModelState.textContent='Preparando descarga…';try{await APLocalModel.load((loaded,total)=>{const pct=Math.min(100,Math.round(loaded/total*100));apModelBar.style.width=pct+'%';apModelState.textContent='Descargando MiMo 9B… '+pct+'% ('+Math.round(loaded/1048576)+' MB de '+Math.round(total/1048576)+' MB)';});}catch(e){}apModelUI();});
|
| 1082 |
+
if(globalThis.APLocalModel)apModelUI();else addEventListener('ap-core-ready',apModelUI,{once:true});
|
| 1083 |
apWebBtn.addEventListener('click',()=>{const on=localStorage.getItem('adaptapro-web-search')!=='true';localStorage.setItem('adaptapro-web-search',String(on));updateWebBtn();AP.append(on?'🔎 Búsqueda web ACTIVADA. A partir de ahora, el texto que escribas se enviará también a Tavily y Wikipedia para buscar contexto (servicios externos, uso gratuito con límites). Las fuentes se citan tras cada respuesta. Se envía el texto que escribas; no se añade automáticamente inventario ni auditoría. No incluyas información confidencial.':'🔎 Búsqueda web desactivada. Tus mensajes ya no se envían a servicios de búsqueda.','ai');});updateWebBtn();
|
| 1084 |
function sendMessage(){const input=document.getElementById('chatInput');const text=input.value.trim();if(!text)return;input.value='';AP.ask(text);}
|
| 1085 |
document.getElementById('chatInput').addEventListener('keydown',e=>{if(e.key==='Enter')sendMessage();});
|