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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="es">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Harbour & FiveWin Experts</title>
|
| 7 |
+
<style>
|
| 8 |
+
:root{
|
| 9 |
+
--bg:#0b141a; --surface:#111b21; --surface2:#202c33; --border:#2a3942;
|
| 10 |
+
--text:#e9edef; --muted:#8696a0; --accent:#00a884;
|
| 11 |
+
--header:#202c33; --header-text:#e9edef; --header-sub:#8696a0;
|
| 12 |
+
--bubble-in:#202c33; --bubble-out:#005c4b; --sys:#2a3942; --sys-text:#ffd279;
|
| 13 |
+
--input:#2a3942; --track:rgba(255,255,255,.12); --disabled:#374248;
|
| 14 |
+
}
|
| 15 |
+
body.light{
|
| 16 |
+
--bg:#efeae2; --surface:#ffffff; --surface2:#f0f2f5; --border:#d1d7db;
|
| 17 |
+
--text:#111b21; --muted:#667781;
|
| 18 |
+
--header:#008069; --header-text:#ffffff; --header-sub:rgba(255,255,255,.75);
|
| 19 |
+
--bubble-in:#ffffff; --bubble-out:#d9fdd3; --sys:#fdf3c6; --sys-text:#54656f;
|
| 20 |
+
--input:#ffffff; --track:rgba(11,20,26,.08); --disabled:#aebac1;
|
| 21 |
+
}
|
| 22 |
+
*{box-sizing:border-box}
|
| 23 |
+
html,body{margin:0;padding:0;background:var(--bg);color:var(--text);
|
| 24 |
+
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;font-size:15px}
|
| 25 |
+
#app{max-width:1200px;margin:0 auto;display:flex;height:100vh;height:100dvh;
|
| 26 |
+
box-shadow:0 0 14px rgba(0,0,0,.4);background:var(--bg)}
|
| 27 |
+
|
| 28 |
+
/* --- Lista de contactos (agentes) --- */
|
| 29 |
+
#sidebar{width:300px;flex:none;display:flex;flex-direction:column;min-height:0;
|
| 30 |
+
background:var(--surface);border-right:1px solid var(--border)}
|
| 31 |
+
.side-header{display:flex;align-items:center;gap:10px;padding:10px 16px;
|
| 32 |
+
background:var(--header);color:var(--header-text)}
|
| 33 |
+
.side-logo{width:38px;height:38px;border-radius:50%;flex:none;font-size:19px;
|
| 34 |
+
background:linear-gradient(135deg,#00c49a,#025c4b);display:flex;align-items:center;justify-content:center;
|
| 35 |
+
box-shadow:0 0 10px rgba(0,168,132,.45)}
|
| 36 |
+
.side-title{font-weight:600;font-size:16px;letter-spacing:.1px}
|
| 37 |
+
.side-count{font-weight:400;color:var(--muted);font-size:12.5px;margin-left:4px}
|
| 38 |
+
#contacts{flex:1;overflow-y:auto;padding:6px 0}
|
| 39 |
+
.contact{display:flex;align-items:center;gap:12px;padding:9px 14px;transition:background .15s}
|
| 40 |
+
.contact:hover{background:var(--surface2)}
|
| 41 |
+
.contact.active{background:var(--surface2)}
|
| 42 |
+
.c-avatar{width:46px;height:46px;border-radius:50%;display:flex;align-items:center;justify-content:center;
|
| 43 |
+
font-size:22px;color:#fff;flex:none}
|
| 44 |
+
.c-info{flex:1;min-width:0;display:flex;flex-direction:column}
|
| 45 |
+
.c-name{font-size:15px;font-weight:600;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
| 46 |
+
.c-role{font-size:12.5px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
| 47 |
+
.contact.active .c-role{color:var(--accent);font-style:italic}
|
| 48 |
+
.c-dot{width:9px;height:9px;border-radius:50%;background:var(--accent);flex:none;box-shadow:0 0 6px var(--accent)}
|
| 49 |
+
|
| 50 |
+
/* --- Columna principal --- */
|
| 51 |
+
#main{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column}
|
| 52 |
+
|
| 53 |
+
header{display:flex;align-items:center;gap:10px;padding:8px 16px;background:var(--header);color:var(--header-text);
|
| 54 |
+
border-bottom:none;box-shadow:0 1px 3px rgba(0,0,0,.3);z-index:2}
|
| 55 |
+
header .logo{width:40px;height:40px;border-radius:50%;background:linear-gradient(135deg,#00c49a,#025c4b);
|
| 56 |
+
display:flex;align-items:center;justify-content:center;font-size:19px;color:#fff;flex:none;
|
| 57 |
+
box-shadow:0 0 10px rgba(0,168,132,.45)}
|
| 58 |
+
header .title{font-weight:600;font-size:16px;letter-spacing:.1px;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
| 59 |
+
header .subtitle{font-size:12px;color:var(--header-sub);font-weight:400}
|
| 60 |
+
#settings-btn{background:none;border:none;color:var(--header-text);border-radius:50%;
|
| 61 |
+
width:38px;height:38px;cursor:pointer;font-size:18px;display:flex;align-items:center;justify-content:center;transition:.15s}
|
| 62 |
+
#settings-btn:hover{background:rgba(255,255,255,.12)}
|
| 63 |
+
|
| 64 |
+
#chat{flex:1;overflow-y:auto;padding:20px 8%;display:flex;flex-direction:column;gap:8px;
|
| 65 |
+
background-color:var(--bg);
|
| 66 |
+
background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%232a3942' stroke-width='1.4' opacity='0.55'%3E%3Ccircle cx='20' cy='20' r='6'/%3E%3Cpath d='M50 15h16a6 6 0 0 1 6 6v8a6 6 0 0 1-6 6h-9l-5 5v-5h-2a6 6 0 0 1-6-6v-8a6 6 0 0 1 6-6z'/%3E%3Cpath d='M15 60l4 4 8-8'/%3E%3Ccircle cx='95' cy='70' r='8'/%3E%3Cpath d='M40 95c4-6 12-6 16 0'/%3E%3Cpath d='M85 25l2.5 5 5 2.5-5 2.5-2.5 5-2.5-5-5-2.5 5-2.5z'/%3E%3Crect x='60' y='55' width='12' height='12' rx='3'/%3E%3Cpath d='M20 100q6-8 12 0'/%3E%3C/g%3E%3C/svg%3E")}
|
| 67 |
+
body.light #chat{
|
| 68 |
+
background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23d8d1c6' stroke-width='1.4' opacity='0.5'%3E%3Ccircle cx='20' cy='20' r='6'/%3E%3Cpath d='M50 15h16a6 6 0 0 1 6 6v8a6 6 0 0 1-6 6h-9l-5 5v-5h-2a6 6 0 0 1-6-6v-8a6 6 0 0 1 6-6z'/%3E%3Cpath d='M15 60l4 4 8-8'/%3E%3Ccircle cx='95' cy='70' r='8'/%3E%3Cpath d='M40 95c4-6 12-6 16 0'/%3E%3Cpath d='M85 25l2.5 5 5 2.5-5 2.5-2.5 5-2.5-5-5-2.5 5-2.5z'/%3E%3Crect x='60' y='55' width='12' height='12' rx='3'/%3E%3Cpath d='M20 100q6-8 12 0'/%3E%3C/g%3E%3C/svg%3E")}
|
| 69 |
+
#chat::-webkit-scrollbar,#contacts::-webkit-scrollbar{width:6px;height:6px}
|
| 70 |
+
#chat::-webkit-scrollbar-thumb,#contacts::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}
|
| 71 |
+
.msg{display:flex;gap:8px;animation:fadein .2s ease;max-width:100%}
|
| 72 |
+
.msg .avatar{width:36px;height:36px;border-radius:50%;display:flex;align-items:center;justify-content:center;
|
| 73 |
+
font-size:17px;color:#fff;flex:none;margin-top:0}
|
| 74 |
+
.msg .content{flex:1;min-width:0;max-width:75%;background:var(--bubble-in);border-radius:8px;padding:6px 9px 8px;
|
| 75 |
+
box-shadow:0 1px 1px rgba(0,0,0,.3)}
|
| 76 |
+
.msg .who{font-size:13px;font-weight:600;margin-bottom:2px}
|
| 77 |
+
.msg .who .round{font-weight:400;color:var(--muted);margin-left:6px;font-size:11px}
|
| 78 |
+
.msg .body{line-height:1.42;word-wrap:break-word;color:var(--text);font-size:14.5px}
|
| 79 |
+
.msg .body p{margin:.35em 0}
|
| 80 |
+
.msg.user{justify-content:flex-end}
|
| 81 |
+
.msg.user .content{flex:none;background:var(--bubble-out);border:none;
|
| 82 |
+
border-radius:8px;padding:7px 10px}
|
| 83 |
+
.msg.user .who{display:none}
|
| 84 |
+
.msg.err{align-self:center;max-width:92%;background:var(--sys);color:var(--sys-text);font-size:12.5px;
|
| 85 |
+
border-radius:8px;padding:6px 12px;text-align:center;box-shadow:0 1px 1px rgba(0,0,0,.3)}
|
| 86 |
+
@keyframes fadein{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
|
| 87 |
+
@keyframes pulse{0%,100%{opacity:.3}50%{opacity:1}}
|
| 88 |
+
.msg.streaming .body::after{content:"";display:inline-block;width:7px;height:7px;border-radius:50%;
|
| 89 |
+
background:var(--accent);margin-left:5px;animation:pulse 1s infinite}
|
| 90 |
+
details.think{margin:2px 0 6px;font-size:12.5px;color:var(--muted)}
|
| 91 |
+
details.think summary{cursor:pointer;font-size:12px;font-style:italic}
|
| 92 |
+
details.think .t{white-space:pre-wrap;border-left:3px solid var(--border);padding-left:10px;margin-top:5px;font-size:12.5px}
|
| 93 |
+
|
| 94 |
+
#controls{padding:8px 12px;background:var(--surface);display:flex;gap:8px;align-items:center;border-top:none}
|
| 95 |
+
#topic-sugg{flex:none;max-width:170px;background:var(--input);color:var(--muted);border:none;
|
| 96 |
+
border-radius:8px;padding:11px 8px;font-size:13px;cursor:pointer;outline:none}
|
| 97 |
+
#topic{flex:1;min-width:0;background:var(--input);border:none;color:var(--text);
|
| 98 |
+
border-radius:8px;padding:11px 14px;font-size:15px;outline:none}
|
| 99 |
+
#topic::placeholder{color:var(--muted)}
|
| 100 |
+
#start-btn{flex:none;background:var(--accent);color:#fff;border:none;border-radius:999px;padding:11px 18px;
|
| 101 |
+
cursor:pointer;font-weight:600;font-size:14px;transition:background .15s;white-space:nowrap;box-shadow:0 1px 2px rgba(0,0,0,.3)}
|
| 102 |
+
#start-btn:hover{background:#02b08a}
|
| 103 |
+
#start-btn:disabled{background:var(--disabled);color:var(--muted);cursor:default;box-shadow:none}
|
| 104 |
+
#stop-btn{flex:none;background:transparent;border:1px solid #ea0038;color:#ea0038;border-radius:999px;
|
| 105 |
+
padding:10px 16px;cursor:pointer;font-weight:600;font-size:14px;display:none}
|
| 106 |
+
|
| 107 |
+
#settings{display:none;margin:8px 12px 10px;padding:16px;border:1px solid var(--border);
|
| 108 |
+
border-radius:12px;background:var(--surface);box-shadow:0 2px 6px rgba(0,0,0,.3)}
|
| 109 |
+
#settings.open{display:block}
|
| 110 |
+
#settings label{display:block;font-size:12px;color:var(--muted);margin:10px 0 4px}
|
| 111 |
+
#settings input,#settings textarea,#settings select{width:100%;background:var(--input);color:var(--text);
|
| 112 |
+
border:1px solid var(--border);border-radius:8px;padding:9px 12px;font-size:14px;font-family:inherit;outline:none}
|
| 113 |
+
#settings input:focus,#settings textarea:focus,#settings select:focus{border-color:var(--accent)}
|
| 114 |
+
#settings textarea{min-height:150px;font-family:ui-monospace,"SF Mono",Menlo,monospace;font-size:12px}
|
| 115 |
+
#settings .row{display:flex;gap:10px;flex-wrap:wrap}
|
| 116 |
+
#settings .row>div{flex:1;min-width:120px}
|
| 117 |
+
#apply-settings{margin-top:12px;background:var(--accent);border:none;color:#fff;border-radius:999px;
|
| 118 |
+
padding:10px 18px;cursor:pointer;font-weight:600}
|
| 119 |
+
|
| 120 |
+
#status{padding:6px 16px;font-size:12px;color:var(--muted);background:var(--bg)}
|
| 121 |
+
#progress{height:3px;background:var(--track)}
|
| 122 |
+
#progress>div{height:100%;width:0;background:var(--accent);transition:width .25s}
|
| 123 |
+
footer{padding:10px 16px;font-size:11px;color:var(--muted);border-top:1px solid var(--border);background:var(--surface);
|
| 124 |
+
display:flex;gap:8px 16px;flex-wrap:wrap;justify-content:center;text-align:center}
|
| 125 |
+
footer a{color:var(--accent);text-decoration:none}
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
/* --- Editor interactivo de agente --- */
|
| 129 |
+
.contact{cursor:pointer}
|
| 130 |
+
#agent-modal{display:none;position:fixed;inset:0;background:rgba(0,0,0,.55);z-index:10;
|
| 131 |
+
align-items:center;justify-content:center;padding:16px}
|
| 132 |
+
#agent-modal.open{display:flex}
|
| 133 |
+
#agent-modal .card{width:100%;max-width:420px;max-height:90vh;overflow-y:auto;background:var(--surface);
|
| 134 |
+
border:1px solid var(--border);border-radius:12px;padding:16px;box-shadow:0 8px 24px rgba(0,0,0,.4)}
|
| 135 |
+
#agent-modal h3{margin:0 0 4px;font-size:16px;color:var(--text)}
|
| 136 |
+
#agent-modal .hint{font-size:12px;color:var(--muted);margin-bottom:4px}
|
| 137 |
+
#agent-modal label{display:block;font-size:12px;color:var(--muted);margin:10px 0 4px}
|
| 138 |
+
#agent-modal input,#agent-modal textarea{width:100%;background:var(--input);color:var(--text);
|
| 139 |
+
border:1px solid var(--border);border-radius:8px;padding:9px 12px;font-size:14px;font-family:inherit;outline:none}
|
| 140 |
+
#agent-modal input:focus,#agent-modal textarea:focus{border-color:var(--accent)}
|
| 141 |
+
#agent-modal textarea{min-height:110px;resize:vertical}
|
| 142 |
+
#agent-modal .row{display:flex;gap:10px}
|
| 143 |
+
#agent-modal .row>div{flex:1;min-width:0}
|
| 144 |
+
#agent-emoji{text-align:center}
|
| 145 |
+
#agent-color{padding:4px;height:41px;cursor:pointer}
|
| 146 |
+
#agent-modal .btns{display:flex;gap:10px;margin-top:14px;justify-content:flex-end}
|
| 147 |
+
#agent-save{background:var(--accent);border:none;color:#fff;border-radius:999px;padding:10px 18px;cursor:pointer;font-weight:600}
|
| 148 |
+
#agent-cancel{background:transparent;border:1px solid var(--border);color:var(--muted);border-radius:999px;
|
| 149 |
+
padding:10px 18px;cursor:pointer;font-weight:600}
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
.add-av{background:transparent !important;border:2px dashed var(--border);color:var(--muted);
|
| 153 |
+
font-size:22px;font-weight:400;box-shadow:none !important}
|
| 154 |
+
.add-contact:hover .add-av{border-color:var(--accent);color:var(--accent)}
|
| 155 |
+
.add-contact:hover .c-name{color:var(--accent)}
|
| 156 |
+
#agent-delete{background:transparent;border:1px solid #ea0038;color:#ea0038;border-radius:999px;
|
| 157 |
+
padding:10px 18px;cursor:pointer;font-weight:600;margin-right:auto}
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
/* --- Historial de temas --- */
|
| 161 |
+
#history{flex:none;max-height:34%;display:flex;flex-direction:column;border-top:1px solid var(--border)}
|
| 162 |
+
.hist-header{display:flex;align-items:center;justify-content:space-between;padding:8px 16px 4px;
|
| 163 |
+
font-size:12.5px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.4px}
|
| 164 |
+
#hist-clear{background:none;border:none;color:var(--muted);cursor:pointer;font-size:14px;padding:2px 4px;border-radius:6px}
|
| 165 |
+
#hist-clear:hover{color:var(--text);background:var(--surface2)}
|
| 166 |
+
#hist-list{overflow-y:auto;padding:0 8px 8px}
|
| 167 |
+
.hist-item{padding:7px 10px;border-radius:8px;cursor:pointer}
|
| 168 |
+
.hist-item:hover{background:var(--surface2)}
|
| 169 |
+
.hist-topic{font-size:13.5px;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
| 170 |
+
.hist-meta{font-size:11.5px;color:var(--muted);margin-top:1px}
|
| 171 |
+
.hist-empty{font-size:12px;color:var(--muted);font-style:italic;padding:6px 10px}
|
| 172 |
+
|
| 173 |
+
@media (max-width:760px){
|
| 174 |
+
#app{flex-direction:column;max-width:none}
|
| 175 |
+
#sidebar{width:100%;flex:none;border-right:none;border-bottom:1px solid var(--border)}
|
| 176 |
+
.side-header{display:none}
|
| 177 |
+
#contacts{display:flex;overflow-x:auto;padding:8px 10px;gap:6px}
|
| 178 |
+
.contact{flex:none;flex-direction:column;gap:4px;padding:6px 10px;min-width:64px;justify-content:center}
|
| 179 |
+
.contact .c-info{align-items:center;text-align:center}
|
| 180 |
+
.c-role{display:none}
|
| 181 |
+
.c-dot{display:none}
|
| 182 |
+
.c-avatar{width:44px;height:44px;font-size:21px}
|
| 183 |
+
#chat{padding:12px 4%;gap:7px}
|
| 184 |
+
#controls{padding:8px 8px}
|
| 185 |
+
header{padding:8px 10px}
|
| 186 |
+
header .subtitle{display:none}
|
| 187 |
+
.msg .avatar{width:32px;height:32px;font-size:16px}
|
| 188 |
+
.msg .content{max-width:85%}
|
| 189 |
+
#settings{margin:0 8px 8px}
|
| 190 |
+
#history{display:none}
|
| 191 |
+
#topic-sugg{max-width:110px}
|
| 192 |
+
}
|
| 193 |
+
</style>
|
| 194 |
+
</head>
|
| 195 |
+
<body>
|
| 196 |
+
<div id="app">
|
| 197 |
+
<aside id="sidebar">
|
| 198 |
+
<div class="side-header">
|
| 199 |
+
<span class="side-logo">🤖</span>
|
| 200 |
+
<span class="side-title">Agentes<span class="side-count" id="side-count">(3)</span></span>
|
| 201 |
+
</div>
|
| 202 |
+
<div id="contacts"></div>
|
| 203 |
+
<div id="history">
|
| 204 |
+
<div class="hist-header"><span>Temas debatidos</span><button id="hist-clear" title="Borrar historial">🗑</button></div>
|
| 205 |
+
<div id="hist-list"></div>
|
| 206 |
+
</div>
|
| 207 |
+
</aside>
|
| 208 |
+
<div id="main">
|
| 209 |
+
<header>
|
| 210 |
+
<span class="logo">🤖</span>
|
| 211 |
+
<span class="title" id="title">Harbour & FiveWin Experts <span class="subtitle" id="subtitle"></span></span>
|
| 212 |
+
<button id="settings-btn" title="Ajustes">⚙</button>
|
| 213 |
+
</header>
|
| 214 |
+
|
| 215 |
+
<div id="settings">
|
| 216 |
+
<div class="row">
|
| 217 |
+
<div><label>Modelo predefinido</label><select id="set-preset">
|
| 218 |
+
<option value="">(personalizado)</option>
|
| 219 |
+
<option value="bartowski/Qwen2.5-Coder-1.5B-Instruct-GGUF|Qwen2.5-Coder-1.5B-Instruct-Q4_K_M.gguf">Qwen2.5-Coder 1.5B (~1,1 GB, ligero)</option>
|
| 220 |
+
<option value="bartowski/Qwen2.5-Coder-3B-Instruct-GGUF|Qwen2.5-Coder-3B-Instruct-Q4_K_M.gguf">Qwen2.5-Coder 3B (~2,1 GB)</option>
|
| 221 |
+
<option value="bartowski/MiMo-V2.6-Distill-Qwen-9B-GGUF|MiMo-V2.6-Distill-Qwen-9B-Q4_K_M.gguf">MiMo-V2.6 9B (~5,8 GB, requiere mucha cuota de almacenamiento)</option>
|
| 222 |
+
</select></div>
|
| 223 |
+
</div>
|
| 224 |
+
<div class="row">
|
| 225 |
+
<div><label>Repositorio Hugging Face</label><input id="set-repo"></div>
|
| 226 |
+
<div><label>Archivo GGUF</label><input id="set-file"></div>
|
| 227 |
+
</div>
|
| 228 |
+
<div class="row">
|
| 229 |
+
<div><label>Contexto (tokens)</label><input id="set-ctx" type="number" step="512" min="2048"></div>
|
| 230 |
+
<div><label>Máx. tokens por turno</label><input id="set-maxtokens" type="number" step="32" min="64"></div>
|
| 231 |
+
<div><label>Temperatura</label><input id="set-temp" type="number" step="0.05" min="0" max="2"></div>
|
| 232 |
+
<div><label>Rondas</label><input id="set-rounds" type="number" step="1" min="1" max="20"></div>
|
| 233 |
+
<div><label>Orden de turnos</label><select id="set-order"><option value="seq">Secuencial</option><option value="rand">Aleatorio por ronda</option></select></div>
|
| 234 |
+
</div>
|
| 235 |
+
<label>Agentes (JSON: name, emoji, color, system)</label>
|
| 236 |
+
<textarea id="set-agents" spellcheck="false"></textarea>
|
| 237 |
+
<button id="apply-settings">Aplicar</button>
|
| 238 |
+
</div>
|
| 239 |
+
|
| 240 |
+
<div id="chat"></div>
|
| 241 |
+
|
| 242 |
+
<div id="controls">
|
| 243 |
+
<select id="topic-sugg" title="Temas sugeridos"></select>
|
| 244 |
+
<input id="topic" placeholder="Pregunta sobre Harbour o FiveWin y los expertos responden…">
|
| 245 |
+
<button id="start-btn" disabled>Cargando modelo…</button>
|
| 246 |
+
<button id="stop-btn">Detener</button>
|
| 247 |
+
</div>
|
| 248 |
+
|
| 249 |
+
<div id="status">Iniciando…</div>
|
| 250 |
+
<div id="progress"><div></div></div>
|
| 251 |
+
<footer>
|
| 252 |
+
<span>La conversación se procesa en tu navegador (WebGPU si está disponible; si no, CPU/WASM). Solo se conecta a Hugging Face para descargar el modelo (1,1 GB con el modelo ligero) y a jsDelivr para las librerías.</span>
|
| 253 |
+
<span>Contexto experto: documentación pública de <a href="https://github.com/harbour/core" target="_blank" rel="noopener">harbour/core</a> y hilos públicos de los <a href="https://forums.fivetechsupport.com" target="_blank" rel="noopener">foros FiveTech</a>, incluidos en este Space.</span>
|
| 254 |
+
<span>Motor: <a href="https://github.com/ngxson/wllama" target="_blank" rel="noopener">wllama</a> (MIT) · inspirado en <a href="https://huggingface.co/spaces/fivetech/Multi-Agent-Debate-MiMo-WebGPU" target="_blank" rel="noopener">Multi-Agent Debate</a> · modelo por defecto <a href="https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B-Instruct" target="_blank" rel="noopener">Qwen2.5-Coder-1.5B</a>; MiMo-V2.6-9B disponible en Ajustes</span>
|
| 255 |
+
</footer>
|
| 256 |
+
</div>
|
| 257 |
+
</div>
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
<div id="agent-modal">
|
| 261 |
+
<div class="card">
|
| 262 |
+
<h3 id="agent-modal-title">Editar agente</h3>
|
| 263 |
+
<div class="hint">Cambia su nombre y sus cualidades; se aplica al instante en esta sesión, igual que los Ajustes.</div>
|
| 264 |
+
<div class="row">
|
| 265 |
+
<div style="flex:2"><label>Nombre</label><input id="agent-name"></div>
|
| 266 |
+
<div><label>Avatar (emoji)</label><input id="agent-emoji" maxlength="4"></div>
|
| 267 |
+
<div><label>Color</label><input id="agent-color" type="color"></div>
|
| 268 |
+
</div>
|
| 269 |
+
<label>Cualidades (personalidad e instrucciones)</label>
|
| 270 |
+
<textarea id="agent-system" spellcheck="false" placeholder="Ej.: Eres Dora, la optimista del grupo. Ves oportunidades en cada idea y animas al grupo a probar."></textarea>
|
| 271 |
+
<div class="btns">
|
| 272 |
+
<button id="agent-delete">Eliminar</button>
|
| 273 |
+
<button id="agent-cancel">Cancelar</button>
|
| 274 |
+
<button id="agent-save">Guardar</button>
|
| 275 |
+
</div>
|
| 276 |
+
</div>
|
| 277 |
+
</div>
|
| 278 |
+
|
| 279 |
+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
| 280 |
+
<script type="module">
|
| 281 |
+
import { Wllama } from 'https://cdn.jsdelivr.net/npm/@wllama/wllama@3.5.1/esm/index.js';
|
| 282 |
+
|
| 283 |
+
const params = new URLSearchParams(location.search);
|
| 284 |
+
|
| 285 |
+
const DEFAULT_AGENTS = [
|
| 286 |
+
{ name: 'Harbour', emoji: '\u{2693}', color: '#58a6ff',
|
| 287 |
+
system: 'Eres Harbour, experto en el lenguaje Harbour (sucesor libre de Clipper/xBase): compilador, hbmk2, RDDs, arrays, codeblocks, clases, multihilo y compatibilidad con xHarbour. Basas tus respuestas en la documentaci\u00f3n p\u00fablica de harbour/core incluida en tu contexto; la citas brevemente cuando la usas y admites con naturalidad cuando algo no consta.' },
|
| 288 |
+
{ name: 'FiveWin', emoji: '\u{1FA9F}', color: '#bf5af2',
|
| 289 |
+
system: 'Eres FiveWin, experta en FiveWin for Harbour (FWH), la librer\u00eda GUI comercial de FiveTech para Windows: clases TWindow, TDialog, TXBrowse, TGet, men\u00fas, impresi\u00f3n y builds 32/64 bits. Te apoyas en el conocimiento p\u00fablico de los foros de FiveTech incluido en tu contexto; citas el hilo cuando lo usas y admites cuando algo no consta.' },
|
| 290 |
+
{ name: 'Mentor', emoji: '\u{1F3AF}', color: '#3fb950',
|
| 291 |
+
system: 'Eres Mentor, el integrador del grupo. Sintetizas lo aportado por Harbour y FiveWin, propones ejemplos de c\u00f3digo concretos cuando ayudan y se\u00f1alas el siguiente paso o prueba a realizar. Cierras cada ronda con una conclusi\u00f3n breve.' },
|
| 292 |
+
];
|
| 293 |
+
|
| 294 |
+
const CONFIG = {
|
| 295 |
+
modelUrl: params.get('modelUrl') || '',
|
| 296 |
+
repo: params.get('repo') || 'bartowski/Qwen2.5-Coder-1.5B-Instruct-GGUF',
|
| 297 |
+
file: params.get('file') || 'Qwen2.5-Coder-1.5B-Instruct-Q4_K_M.gguf',
|
| 298 |
+
nCtx: parseInt(params.get('ctx')) || 8192,
|
| 299 |
+
maxTokens: parseInt(params.get('maxTokens')) || 512,
|
| 300 |
+
temperature: parseFloat(params.get('temp')) || 0.7,
|
| 301 |
+
rounds: parseInt(params.get('rounds')) || 2,
|
| 302 |
+
autoload: params.get('autoload') !== 'false',
|
| 303 |
+
order: params.get('order') === 'rand' ? 'rand' : 'seq',
|
| 304 |
+
};
|
| 305 |
+
if (params.get('theme') === 'light') document.body.classList.add('light');
|
| 306 |
+
const AGENTS_KEY = 'hfw_agents';
|
| 307 |
+
function loadStoredAgents() {
|
| 308 |
+
try {
|
| 309 |
+
const a = JSON.parse(localStorage.getItem(AGENTS_KEY));
|
| 310 |
+
return (Array.isArray(a) && a.length >= 2 && a.every(x => x && x.name && x.system)) ? a : null;
|
| 311 |
+
} catch (e) { return null; }
|
| 312 |
+
}
|
| 313 |
+
function persistAgents() {
|
| 314 |
+
try { localStorage.setItem(AGENTS_KEY, JSON.stringify(agents)); } catch (e) {}
|
| 315 |
+
}
|
| 316 |
+
let agents = loadStoredAgents() || DEFAULT_AGENTS;
|
| 317 |
+
if (params.get('agents')) {
|
| 318 |
+
try { agents = JSON.parse(params.get('agents')); } catch (e) { console.warn('agents JSON inv\u00e1lido', e); }
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
const chatEl = document.getElementById('chat');
|
| 322 |
+
const statusEl = document.getElementById('status');
|
| 323 |
+
const progressEl = document.getElementById('progress').firstElementChild;
|
| 324 |
+
const topicEl = document.getElementById('topic');
|
| 325 |
+
const startBtn = document.getElementById('start-btn');
|
| 326 |
+
const stopBtn = document.getElementById('stop-btn');
|
| 327 |
+
const contactsEl = document.getElementById('contacts');
|
| 328 |
+
const subtitleEl = document.getElementById('subtitle');
|
| 329 |
+
|
| 330 |
+
let wllama = null;
|
| 331 |
+
let running = false;
|
| 332 |
+
let stopRequested = false;
|
| 333 |
+
let transcript = []; // {name|null(user), text}
|
| 334 |
+
let topic = '';
|
| 335 |
+
|
| 336 |
+
function setStatus(t) { statusEl.textContent = t; }
|
| 337 |
+
function setProgress(p) { progressEl.style.width = Math.max(0, Math.min(100, p)) + '%'; }
|
| 338 |
+
|
| 339 |
+
function esc(s){ const d = document.createElement('div'); d.textContent = s; return d.innerHTML; }
|
| 340 |
+
|
| 341 |
+
// --- Avatares y lista de contactos ---
|
| 342 |
+
function shade(hex, amt) {
|
| 343 |
+
const n = parseInt(String(hex).replace('#','').slice(0,6), 16);
|
| 344 |
+
if (isNaN(n)) return hex;
|
| 345 |
+
const f = v => Math.max(0, Math.min(255, v + amt));
|
| 346 |
+
const r = f(n >> 16), g = f((n >> 8) & 255), b = f(n & 255);
|
| 347 |
+
return '#' + ((r << 16) | (g << 8) | b).toString(16).padStart(6, '0');
|
| 348 |
+
}
|
| 349 |
+
function avatarBg(color) {
|
| 350 |
+
return `linear-gradient(135deg, ${shade(color, 34)} 0%, ${color} 55%, ${shade(color, -38)} 100%)`;
|
| 351 |
+
}
|
| 352 |
+
function roleOf(agent) {
|
| 353 |
+
const m = /Eres\s+[^,]+,\s*([^\.]+)\./i.exec(agent.system || '');
|
| 354 |
+
let r = m ? m[1].trim() : 'Agente del debate';
|
| 355 |
+
r = r.replace(/\s+del grupo\s*$/i, '').replace(/^(el|la|los|las)\s+/i, '');
|
| 356 |
+
return r ? r.charAt(0).toUpperCase() + r.slice(1) : 'Agente del debate';
|
| 357 |
+
}
|
| 358 |
+
function renderContacts() {
|
| 359 |
+
contactsEl.innerHTML = '';
|
| 360 |
+
agents.forEach((a, i) => {
|
| 361 |
+
const c = document.createElement('div');
|
| 362 |
+
c.className = 'contact';
|
| 363 |
+
c.dataset.name = a.name;
|
| 364 |
+
c.title = 'Editar agente';
|
| 365 |
+
c.addEventListener('click', () => openAgentEditor(i));
|
| 366 |
+
const av = document.createElement('div');
|
| 367 |
+
av.className = 'c-avatar';
|
| 368 |
+
av.style.background = avatarBg(a.color);
|
| 369 |
+
av.style.boxShadow = `0 0 12px ${a.color}66`;
|
| 370 |
+
av.textContent = a.emoji;
|
| 371 |
+
const info = document.createElement('div');
|
| 372 |
+
info.className = 'c-info';
|
| 373 |
+
const nm = document.createElement('div');
|
| 374 |
+
nm.className = 'c-name'; nm.textContent = a.name;
|
| 375 |
+
const rl = document.createElement('div');
|
| 376 |
+
rl.className = 'c-role'; rl.textContent = roleOf(a);
|
| 377 |
+
info.appendChild(nm); info.appendChild(rl);
|
| 378 |
+
const dot = document.createElement('div');
|
| 379 |
+
dot.className = 'c-dot';
|
| 380 |
+
c.appendChild(av); c.appendChild(info); c.appendChild(dot);
|
| 381 |
+
contactsEl.appendChild(c);
|
| 382 |
+
});
|
| 383 |
+
const add = document.createElement('div');
|
| 384 |
+
add.className = 'contact add-contact';
|
| 385 |
+
add.title = 'A\u00f1adir agente';
|
| 386 |
+
add.innerHTML = '<div class="c-avatar add-av">+</div><div class="c-info">' +
|
| 387 |
+
'<div class="c-name">A\u00f1adir agente</div><div class="c-role">Nuevo participante</div></div>';
|
| 388 |
+
add.addEventListener('click', () => openAgentEditor(-1));
|
| 389 |
+
contactsEl.appendChild(add);
|
| 390 |
+
document.getElementById('side-count').textContent = `(${agents.length})`;
|
| 391 |
+
subtitleEl.textContent = agents.map(a => a.name).join(', ') + ', T\u00fa';
|
| 392 |
+
}
|
| 393 |
+
function markActive(name) {
|
| 394 |
+
contactsEl.querySelectorAll('.contact').forEach(c => {
|
| 395 |
+
const on = c.dataset.name === name;
|
| 396 |
+
c.classList.toggle('active', on);
|
| 397 |
+
const rl = c.querySelector('.c-role');
|
| 398 |
+
if (on) { if (!rl.dataset.orig) rl.dataset.orig = rl.textContent; rl.textContent = 'escribiendo\u2026'; }
|
| 399 |
+
else if (rl.dataset.orig) { rl.textContent = rl.dataset.orig; delete rl.dataset.orig; }
|
| 400 |
+
});
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
// --- Editor interactivo de agentes (editar, a\u00f1adir, quitar) ---
|
| 404 |
+
const agentModal = document.getElementById('agent-modal');
|
| 405 |
+
const deleteBtn = document.getElementById('agent-delete');
|
| 406 |
+
let editingAgent = -1;
|
| 407 |
+
function openAgentEditor(i) {
|
| 408 |
+
editingAgent = i;
|
| 409 |
+
const a = agents[i] || {};
|
| 410 |
+
document.getElementById('agent-modal-title').textContent = i >= 0 ? 'Editar agente' : 'A\u00f1adir agente';
|
| 411 |
+
deleteBtn.style.display = i >= 0 ? 'inline-block' : 'none';
|
| 412 |
+
document.getElementById('agent-name').value = a.name || '';
|
| 413 |
+
document.getElementById('agent-emoji').value = a.emoji || '\u{1F916}';
|
| 414 |
+
document.getElementById('agent-color').value = /^#[0-9a-fA-F]{6}$/.test(a.color || '') ? a.color : '#bf5af2';
|
| 415 |
+
document.getElementById('agent-system').value = a.system || '';
|
| 416 |
+
agentModal.classList.add('open');
|
| 417 |
+
document.getElementById('agent-name').focus();
|
| 418 |
+
}
|
| 419 |
+
document.getElementById('agent-cancel').addEventListener('click', () => agentModal.classList.remove('open'));
|
| 420 |
+
agentModal.addEventListener('click', e => { if (e.target === agentModal) agentModal.classList.remove('open'); });
|
| 421 |
+
deleteBtn.addEventListener('click', () => {
|
| 422 |
+
const a = agents[editingAgent];
|
| 423 |
+
if (!a) return;
|
| 424 |
+
if (agents.length <= 2) { alert('Se necesitan al menos 2 agentes.'); return; }
|
| 425 |
+
if (!confirm(`\u00bfEliminar a ${a.name} del debate?`)) return;
|
| 426 |
+
agents.splice(editingAgent, 1);
|
| 427 |
+
persistAgents();
|
| 428 |
+
renderContacts();
|
| 429 |
+
agentModal.classList.remove('open');
|
| 430 |
+
setStatus(`Agente eliminado: ${a.name}. Quedan ${agents.length}.`);
|
| 431 |
+
});
|
| 432 |
+
document.getElementById('agent-save').addEventListener('click', () => {
|
| 433 |
+
const name = document.getElementById('agent-name').value.trim();
|
| 434 |
+
if (!name) { alert('El nombre no puede estar vac\u00edo.'); return; }
|
| 435 |
+
const emoji = document.getElementById('agent-emoji').value.trim() || '\u{1F916}';
|
| 436 |
+
const color = document.getElementById('agent-color').value;
|
| 437 |
+
const system = document.getElementById('agent-system').value.trim();
|
| 438 |
+
if (!system) { alert('Describe las cualidades del agente.'); return; }
|
| 439 |
+
if (editingAgent >= 0) agents[editingAgent] = { name, emoji, color, system };
|
| 440 |
+
else agents.push({ name, emoji, color, system });
|
| 441 |
+
persistAgents();
|
| 442 |
+
renderContacts();
|
| 443 |
+
agentModal.classList.remove('open');
|
| 444 |
+
setStatus(editingAgent >= 0 ? `Agente actualizado: ${name}.` : `Agente a\u00f1adido: ${name}. Ya son ${agents.length}.`);
|
| 445 |
+
});
|
| 446 |
+
|
| 447 |
+
|
| 448 |
+
// --- Historial de temas (localStorage) ---
|
| 449 |
+
const HIST_KEY = 'hfw_history';
|
| 450 |
+
const histListEl = document.getElementById('hist-list');
|
| 451 |
+
function loadHistory() {
|
| 452 |
+
try { return JSON.parse(localStorage.getItem(HIST_KEY)) || []; } catch (e) { return []; }
|
| 453 |
+
}
|
| 454 |
+
function saveHistory(h) {
|
| 455 |
+
try { localStorage.setItem(HIST_KEY, JSON.stringify(h.slice(0, 30))); } catch (e) {}
|
| 456 |
+
}
|
| 457 |
+
function renderHistory() {
|
| 458 |
+
const h = loadHistory();
|
| 459 |
+
histListEl.innerHTML = '';
|
| 460 |
+
if (!h.length) {
|
| 461 |
+
const e = document.createElement('div');
|
| 462 |
+
e.className = 'hist-empty';
|
| 463 |
+
e.textContent = 'Los temas que debatas se guardar\u00e1n aqu\u00ed, en este navegador.';
|
| 464 |
+
histListEl.appendChild(e);
|
| 465 |
+
return;
|
| 466 |
+
}
|
| 467 |
+
h.forEach(item => {
|
| 468 |
+
const d = document.createElement('div');
|
| 469 |
+
d.className = 'hist-item';
|
| 470 |
+
d.title = 'Reutilizar este tema';
|
| 471 |
+
const t = document.createElement('div');
|
| 472 |
+
t.className = 'hist-topic'; t.textContent = item.topic;
|
| 473 |
+
const m = document.createElement('div');
|
| 474 |
+
m.className = 'hist-meta';
|
| 475 |
+
m.textContent = new Date(item.ts).toLocaleString('es-ES', { day: '2-digit', month: '2-digit', hour: '2-digit', minute: '2-digit' }) +
|
| 476 |
+
' \u00b7 ' + item.agents + ' agentes';
|
| 477 |
+
d.appendChild(t); d.appendChild(m);
|
| 478 |
+
d.addEventListener('click', () => { topicEl.value = item.topic; topicEl.focus(); });
|
| 479 |
+
histListEl.appendChild(d);
|
| 480 |
+
});
|
| 481 |
+
}
|
| 482 |
+
function recordTopic(topicText) {
|
| 483 |
+
const h = loadHistory();
|
| 484 |
+
if (h[0] && h[0].topic === topicText) return;
|
| 485 |
+
h.unshift({ topic: topicText, ts: Date.now(), agents: agents.length });
|
| 486 |
+
saveHistory(h);
|
| 487 |
+
renderHistory();
|
| 488 |
+
}
|
| 489 |
+
document.getElementById('hist-clear').addEventListener('click', () => {
|
| 490 |
+
if (!loadHistory().length) return;
|
| 491 |
+
if (!confirm('\u00bfBorrar el historial de temas?')) return;
|
| 492 |
+
saveHistory([]);
|
| 493 |
+
renderHistory();
|
| 494 |
+
});
|
| 495 |
+
|
| 496 |
+
renderContacts();
|
| 497 |
+
renderHistory();
|
| 498 |
+
|
| 499 |
+
function addMsg(agent, isUser = false) {
|
| 500 |
+
const d = document.createElement('div');
|
| 501 |
+
d.className = 'msg' + (isUser ? ' user' : '');
|
| 502 |
+
const content = document.createElement('div');
|
| 503 |
+
content.className = 'content';
|
| 504 |
+
const who = document.createElement('div');
|
| 505 |
+
who.className = 'who';
|
| 506 |
+
const body = document.createElement('div');
|
| 507 |
+
body.className = 'body';
|
| 508 |
+
if (isUser) { who.textContent = 'T\u00fa'; }
|
| 509 |
+
else {
|
| 510 |
+
const av = document.createElement('div');
|
| 511 |
+
av.className = 'avatar';
|
| 512 |
+
av.style.background = avatarBg(agent.color);
|
| 513 |
+
av.style.boxShadow = '0 0 8px ' + agent.color + '55';
|
| 514 |
+
av.textContent = agent.emoji;
|
| 515 |
+
d.appendChild(av);
|
| 516 |
+
who.textContent = agent.name;
|
| 517 |
+
who.style.color = agent.color;
|
| 518 |
+
}
|
| 519 |
+
content.appendChild(who); content.appendChild(body);
|
| 520 |
+
d.appendChild(content);
|
| 521 |
+
chatEl.appendChild(d);
|
| 522 |
+
chatEl.scrollTop = chatEl.scrollHeight;
|
| 523 |
+
return { el: d, body, content };
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
function addErr(text) {
|
| 527 |
+
const d = document.createElement('div');
|
| 528 |
+
d.className = 'msg err';
|
| 529 |
+
d.textContent = text;
|
| 530 |
+
chatEl.appendChild(d);
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
async function loadModel(repo, file) {
|
| 534 |
+
const url = CONFIG.modelUrl || `https://huggingface.co/${repo}/resolve/main/${file}`;
|
| 535 |
+
startBtn.disabled = true;
|
| 536 |
+
setProgress(0);
|
| 537 |
+
setStatus(`Descargando ${file} (ctx ${CONFIG.nCtx})\u2026`);
|
| 538 |
+
try {
|
| 539 |
+
if (wllama) await wllama.exit();
|
| 540 |
+
wllama = new Wllama({
|
| 541 |
+
'default': 'https://cdn.jsdelivr.net/npm/@wllama/wllama@3.5.1/esm/wasm/wllama.wasm',
|
| 542 |
+
}, { parallelDownloads: 5 });
|
| 543 |
+
await wllama.loadModelFromUrl(url, {
|
| 544 |
+
n_gpu_layers: 999,
|
| 545 |
+
n_ctx: CONFIG.nCtx,
|
| 546 |
+
n_batch: 512,
|
| 547 |
+
n_threads: Math.max(1, Math.min(8, navigator.hardwareConcurrency || 4)),
|
| 548 |
+
progressCallback: ({ loaded, total }) => {
|
| 549 |
+
if (total > 0) {
|
| 550 |
+
const pct = Math.round((loaded / total) * 100);
|
| 551 |
+
setProgress(pct);
|
| 552 |
+
setStatus(`Descargando\u2026 ${pct}% (${(loaded / 1048576).toFixed(0)} MB)`);
|
| 553 |
+
}
|
| 554 |
+
},
|
| 555 |
+
});
|
| 556 |
+
setProgress(100);
|
| 557 |
+
setStatus(`Modelo listo. ${agents.length} agentes: ${agents.map(a => a.name).join(', ')}.`);
|
| 558 |
+
startBtn.disabled = false;
|
| 559 |
+
startBtn.textContent = 'Iniciar debate';
|
| 560 |
+
topicEl.focus();
|
| 561 |
+
} catch (e) {
|
| 562 |
+
console.error(e);
|
| 563 |
+
setStatus('Error al cargar el modelo');
|
| 564 |
+
addErr('No se pudo cargar el modelo: ' + (e?.message || e));
|
| 565 |
+
const retry = document.createElement('button');
|
| 566 |
+
retry.textContent = 'Limpiar cach\u00e9 y reintentar';
|
| 567 |
+
retry.style.cssText = 'margin-top:6px;background:var(--accent);border:none;color:#fff;border-radius:999px;padding:8px 14px;cursor:pointer;font-weight:700';
|
| 568 |
+
retry.addEventListener('click', async () => {
|
| 569 |
+
retry.disabled = true; retry.textContent = 'Limpiando\u2026';
|
| 570 |
+
try {
|
| 571 |
+
if ('caches' in window) for (const k of await caches.keys()) await caches.delete(k);
|
| 572 |
+
if (indexedDB.databases) for (const db of await indexedDB.databases())
|
| 573 |
+
await new Promise(r => { const q = indexedDB.deleteDatabase(db.name); q.onsuccess = q.onerror = q.onblocked = r; });
|
| 574 |
+
if (navigator.storage?.estimate) {
|
| 575 |
+
const dir = await navigator.storage.getDirectory().catch(() => null);
|
| 576 |
+
if (dir) for await (const k of dir.keys()) await dir.removeEntry(k, { recursive: true }).catch(() => {});
|
| 577 |
+
}
|
| 578 |
+
} catch (_) {}
|
| 579 |
+
loadModel(repo, file);
|
| 580 |
+
});
|
| 581 |
+
const errBox = chatEl.lastElementChild;
|
| 582 |
+
if (errBox) { errBox.appendChild(document.createElement('br')); errBox.appendChild(retry); }
|
| 583 |
+
}
|
| 584 |
+
}
|
| 585 |
+
|
| 586 |
+
|
| 587 |
+
// --- Base de conocimiento (fuentes públicas) ---
|
| 588 |
+
let KB = [];
|
| 589 |
+
fetch('knowledge.json').then(r => r.ok ? r.json() : []).then(k => {
|
| 590 |
+
KB = k;
|
| 591 |
+
KB.forEach(e => { e._t = tok(e.title); e._x = tok(e.title + ' ' + e.text); });
|
| 592 |
+
console.log('KB entradas:', KB.length);
|
| 593 |
+
}).catch(() => {});
|
| 594 |
+
const KB_STOP = new Set(('de la el en los del se las por un una para con no su al lo como mas o pero sus le ya este esta entre cuando muy sin sobre tambien hasta hay donde quien desde todo nos durante uno les ni contra otros ese eso ante ellos esto antes algunos que unos yo otro otras otra tanto esa estos mucho quienes nada muchos cual sea poco ella estar haber estas the is are was were for with that this from have has not but what all can you your their they them his her its our who how when where which will would there been more other into could than then some any each most over such only also and use used using get set com para como una con por que los las del').split(/\s+/));
|
| 595 |
+
function tok(s) {
|
| 596 |
+
s = (s || '').toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
| 597 |
+
return s.split(/[^a-z0-9_$]+/).filter(w => w.length >= 3 && !KB_STOP.has(w));
|
| 598 |
+
}
|
| 599 |
+
function kbRetrieve(query, agentName, maxChars = 1700, k = 4) {
|
| 600 |
+
if (!KB.length) return '';
|
| 601 |
+
const qt = new Set(tok(query));
|
| 602 |
+
if (!qt.size) return '';
|
| 603 |
+
const scored = [];
|
| 604 |
+
for (const e of KB) {
|
| 605 |
+
let sc = 0;
|
| 606 |
+
for (const w of qt) {
|
| 607 |
+
if (e._t.includes(w)) sc += 3;
|
| 608 |
+
else if (e._x.includes(w)) sc += 1;
|
| 609 |
+
}
|
| 610 |
+
if (/^Harbour/i.test(agentName) && e.src.indexOf('harbour/core') === 0) sc *= 1.7;
|
| 611 |
+
if (/^FiveWin/i.test(agentName) && e.src.indexOf('Foro') === 0) sc *= 1.7;
|
| 612 |
+
if (sc > 0) scored.push([sc, e]);
|
| 613 |
+
}
|
| 614 |
+
scored.sort((a, b) => b[0] - a[0]);
|
| 615 |
+
let out = '', n = 0;
|
| 616 |
+
for (const [sc, e] of scored) {
|
| 617 |
+
if (n >= k || out.length + e.text.length > maxChars) break;
|
| 618 |
+
out += `\n[${e.title} \u2014 ${e.src}]\n${e.text}\n`;
|
| 619 |
+
n++;
|
| 620 |
+
}
|
| 621 |
+
return out.trim();
|
| 622 |
+
}
|
| 623 |
+
|
| 624 |
+
const RULES = 'Est\u00e1s en una conversaci\u00f3n entre varios agentes. ' +
|
| 625 |
+
'Responde SOLO con tu intervenci\u00f3n: 2-5 frases, directas, en el idioma de la conversaci\u00f3n. ' +
|
| 626 |
+
'No repitas lo ya dicho; reacciona a la \u00faltima intervenci\u00f3n. ' +
|
| 627 |
+
'No escribas tu nombre ni ning\u00fan prefijo como "Nombre:". No uses listas largas.';
|
| 628 |
+
|
| 629 |
+
function transcriptText(maxChars = 9000) {
|
| 630 |
+
const lines = transcript.map(m => `${m.name || 'Usuario'}: ${m.text}`);
|
| 631 |
+
let out = lines.join('\n\n');
|
| 632 |
+
while (out.length > maxChars && lines.length > 2) {
|
| 633 |
+
lines.splice(1, 1); // conserva el tema (primera l\u00ednea) y lo m\u00e1s reciente
|
| 634 |
+
out = lines.join('\n\n');
|
| 635 |
+
}
|
| 636 |
+
return out;
|
| 637 |
+
}
|
| 638 |
+
|
| 639 |
+
async function agentTurn(agent) {
|
| 640 |
+
const view = transcriptText();
|
| 641 |
+
const kb = kbRetrieve(topic + '\n' + view.slice(-900), agent.name);
|
| 642 |
+
const messages = [
|
| 643 |
+
{ role: 'system', content: agent.system + ' ' + RULES +
|
| 644 |
+
(kb ? '\n\nContexto de referencia (fuentes p\u00fablicas; \u00fasalo solo si es pertinente y c\u00edtalo brevemente):\n' + kb : '') },
|
| 645 |
+
{ role: 'user', content:
|
| 646 |
+
`Tema del debate: ${topic}\n\n` +
|
| 647 |
+
(view ? `Conversaci\u00f3n hasta ahora:\n${view}\n\n` : 'A\u00fan no hay intervenciones.\n\n') +
|
| 648 |
+
`Ahora hablas t\u00fa, ${agent.name}. Escribe tu intervenci\u00f3n.` },
|
| 649 |
+
];
|
| 650 |
+
const { el, body } = addMsg(agent);
|
| 651 |
+
el.classList.add('streaming');
|
| 652 |
+
markActive(agent.name);
|
| 653 |
+
let think = null;
|
| 654 |
+
let answer = '', reasoning = '', count = 0;
|
| 655 |
+
setStatus(`${agent.name} est\u00e1 escribiendo\u2026`);
|
| 656 |
+
try {
|
| 657 |
+
const stream = await wllama.createChatCompletion({
|
| 658 |
+
messages,
|
| 659 |
+
max_tokens: CONFIG.maxTokens,
|
| 660 |
+
temperature: CONFIG.temperature,
|
| 661 |
+
stream: true,
|
| 662 |
+
});
|
| 663 |
+
for await (const chunk of stream) {
|
| 664 |
+
if (stopRequested) break;
|
| 665 |
+
const delta = chunk.choices?.[0]?.delta || {};
|
| 666 |
+
const tk = delta.content || '';
|
| 667 |
+
const rs = delta.reasoning_content || '';
|
| 668 |
+
if (rs) {
|
| 669 |
+
reasoning += rs;
|
| 670 |
+
if (!think) {
|
| 671 |
+
think = document.createElement('details');
|
| 672 |
+
think.className = 'think';
|
| 673 |
+
think.innerHTML = '<summary>Pensamiento</summary><div class="t"></div>';
|
| 674 |
+
body.parentNode.insertBefore(think, body);
|
| 675 |
+
}
|
| 676 |
+
think.querySelector('.t').textContent = reasoning;
|
| 677 |
+
}
|
| 678 |
+
if (tk) { answer += tk; body.textContent = answer; }
|
| 679 |
+
if (tk || rs) { count++; if (count % 10 === 0) setStatus(`${agent.name}\u2026 ${count} tokens`); }
|
| 680 |
+
chatEl.scrollTop = chatEl.scrollHeight;
|
| 681 |
+
}
|
| 682 |
+
} catch (e) {
|
| 683 |
+
console.error(e);
|
| 684 |
+
el.classList.add('err');
|
| 685 |
+
body.textContent = 'Error: ' + (e?.message || e);
|
| 686 |
+
el.classList.remove('streaming');
|
| 687 |
+
markActive(null);
|
| 688 |
+
return;
|
| 689 |
+
}
|
| 690 |
+
el.classList.remove('streaming');
|
| 691 |
+
if (stopRequested) { el.remove(); markActive(null); setStatus('Detenido'); return; }
|
| 692 |
+
answer = answer.replace(/^\s*(?:\*\*)?[A-Za-z\u00c0-\u024f]+:\s*/, '').trim();
|
| 693 |
+
if (!answer) { el.remove(); markActive(null); setStatus('Listo'); return; }
|
| 694 |
+
body.innerHTML = (typeof marked !== 'undefined') ? marked.parse(answer) : esc(answer).replace(/\n/g, '<br>');
|
| 695 |
+
transcript.push({ name: agent.name, text: answer });
|
| 696 |
+
markActive(null);
|
| 697 |
+
setStatus('Listo');
|
| 698 |
+
}
|
| 699 |
+
|
| 700 |
+
let resume = { round: 1, order: null, pos: 0 };
|
| 701 |
+
|
| 702 |
+
function shuffled(n) {
|
| 703 |
+
const a = [...Array(n).keys()];
|
| 704 |
+
for (let i = a.length - 1; i > 0; i--) {
|
| 705 |
+
const j = Math.floor(Math.random() * (i + 1));
|
| 706 |
+
[a[i], a[j]] = [a[j], a[i]];
|
| 707 |
+
}
|
| 708 |
+
return a;
|
| 709 |
+
}
|
| 710 |
+
function validOrder(o, n) {
|
| 711 |
+
return Array.isArray(o) && o.length === n && new Set(o).size === n &&
|
| 712 |
+
o.every(v => Number.isInteger(v) && v >= 0 && v < n);
|
| 713 |
+
}
|
| 714 |
+
|
| 715 |
+
async function runDebate() {
|
| 716 |
+
running = true;
|
| 717 |
+
stopRequested = false;
|
| 718 |
+
startBtn.style.display = 'none';
|
| 719 |
+
stopBtn.style.display = 'inline-block';
|
| 720 |
+
topicEl.disabled = true;
|
| 721 |
+
try {
|
| 722 |
+
for (let r = resume.round; r <= CONFIG.rounds && !stopRequested; r++) {
|
| 723 |
+
setStatus(`Ronda ${r}/${CONFIG.rounds}`);
|
| 724 |
+
let order;
|
| 725 |
+
if (r === resume.round && validOrder(resume.order, agents.length)) order = resume.order;
|
| 726 |
+
else order = CONFIG.order === 'rand' ? shuffled(agents.length) : [...Array(agents.length).keys()];
|
| 727 |
+
let startPos = (r === resume.round) ? resume.pos : 0;
|
| 728 |
+
if (startPos >= order.length) startPos = 0;
|
| 729 |
+
for (let p = startPos; p < order.length; p++) {
|
| 730 |
+
if (stopRequested) { resume = { round: r, order, pos: p }; break; }
|
| 731 |
+
await agentTurn(agents[order[p]]);
|
| 732 |
+
if (stopRequested) { resume = { round: r, order, pos: p }; break; }
|
| 733 |
+
}
|
| 734 |
+
if (!stopRequested) resume = { round: r + 1, order: null, pos: 0 };
|
| 735 |
+
}
|
| 736 |
+
if (!stopRequested) resume = { round: 1, order: null, pos: 0 };
|
| 737 |
+
} finally {
|
| 738 |
+
running = false;
|
| 739 |
+
stopBtn.style.display = 'none';
|
| 740 |
+
startBtn.style.display = 'inline-block';
|
| 741 |
+
startBtn.textContent = 'Continuar debate';
|
| 742 |
+
startBtn.disabled = false;
|
| 743 |
+
topicEl.disabled = false;
|
| 744 |
+
setStatus(stopRequested ? 'Detenido. Puedes continuar o cambiar de tema.' : 'Debate terminado. Puedes continuar.');
|
| 745 |
+
}
|
| 746 |
+
}
|
| 747 |
+
|
| 748 |
+
startBtn.addEventListener('click', () => {
|
| 749 |
+
if (!wllama || running) return;
|
| 750 |
+
const newTopic = topicEl.value.trim();
|
| 751 |
+
if (newTopic && newTopic !== topic) {
|
| 752 |
+
topic = newTopic;
|
| 753 |
+
transcript = [];
|
| 754 |
+
chatEl.innerHTML = '';
|
| 755 |
+
resume = { round: 1, order: null, pos: 0 };
|
| 756 |
+
const m = addMsg(null, true);
|
| 757 |
+
m.body.textContent = newTopic;
|
| 758 |
+
transcript.push({ name: null, text: 'Tema propuesto: ' + newTopic });
|
| 759 |
+
recordTopic(newTopic);
|
| 760 |
+
} else if (!topic) {
|
| 761 |
+
topic = 'Tema libre';
|
| 762 |
+
}
|
| 763 |
+
runDebate();
|
| 764 |
+
});
|
| 765 |
+
stopBtn.addEventListener('click', () => { stopRequested = true; setStatus('Deteniendo\u2026'); });
|
| 766 |
+
topicEl.addEventListener('keydown', e => {
|
| 767 |
+
if (e.key === 'Enter') { e.preventDefault(); startBtn.click(); }
|
| 768 |
+
});
|
| 769 |
+
|
| 770 |
+
// --- Temas sugeridos (10 al azar en cada carga) ---
|
| 771 |
+
const TOPIC_POOL = [
|
| 772 |
+
'\u00bfConviene ejecutar LLMs en el navegador con WebGPU?',
|
| 773 |
+
'\u00bfEs mejor el caf\u00e9 solo o con leche?',
|
| 774 |
+
'\u00bfDeber\u00edan los coches aut\u00f3nomos decidir en un accidente?',
|
| 775 |
+
'\u00bfEs el trabajo remoto m\u00e1s productivo que la oficina?',
|
| 776 |
+
'\u00bfHa mejorado la IA la programaci\u00f3n o solo la ha acelerado?',
|
| 777 |
+
'\u00bfMerece la pena aprender Harbour en 2026?',
|
| 778 |
+
'\u00bfDeber\u00eda durar un smartphone 7 a\u00f1os?',
|
| 779 |
+
'Pizza con pi\u00f1a: \u00bfgenialidad o sacrilegio?',
|
| 780 |
+
'\u00bfSuscripci\u00f3n mensual o licencia perpetua para el software?',
|
| 781 |
+
'\u00bfEs la privacidad m\u00e1s importante que la comodidad?',
|
| 782 |
+
'\u00bfDeben los ni\u00f1os aprender a programar antes de los 10 a\u00f1os?',
|
| 783 |
+
'\u00bfSobrevivir\u00e1 el open source a la IA?',
|
| 784 |
+
'\u00bfSQL o NoSQL para la tienda de un barrio?',
|
| 785 |
+
'\u00bfTienen sentido los coches el\u00e9ctricos sin red de carga?',
|
| 786 |
+
'\u00bfEs la bater\u00eda el cuello de botella de la tecnolog\u00eda?',
|
| 787 |
+
'\u00bfEl 5G fue revoluci\u00f3n o marketing?',
|
| 788 |
+
'\u00bfPC de sobremesa o port\u00e1til hoy?',
|
| 789 |
+
'\u00bfSon los videojuegos cultura o solo ocio?',
|
| 790 |
+
'\u00bfEs mejor vivir en la ciudad o en un pueblo?',
|
| 791 |
+
'\u00bfDeber\u00eda existir un derecho al olvido digital?',
|
| 792 |
+
];
|
| 793 |
+
const suggEl = document.getElementById('topic-sugg');
|
| 794 |
+
(function fillSuggestions() {
|
| 795 |
+
const ph = document.createElement('option');
|
| 796 |
+
ph.value = ''; ph.textContent = '\u{1F3B2} 10 temas al azar\u2026';
|
| 797 |
+
suggEl.appendChild(ph);
|
| 798 |
+
[...TOPIC_POOL].sort(() => Math.random() - .5).slice(0, 10).forEach(t => {
|
| 799 |
+
const o = document.createElement('option');
|
| 800 |
+
o.value = t; o.textContent = t;
|
| 801 |
+
suggEl.appendChild(o);
|
| 802 |
+
});
|
| 803 |
+
})();
|
| 804 |
+
suggEl.addEventListener('change', () => {
|
| 805 |
+
if (suggEl.value) { topicEl.value = suggEl.value; topicEl.focus(); }
|
| 806 |
+
suggEl.selectedIndex = 0;
|
| 807 |
+
});
|
| 808 |
+
|
| 809 |
+
// --- Settings ---
|
| 810 |
+
const settingsPanel = document.getElementById('settings');
|
| 811 |
+
document.getElementById('settings-btn').addEventListener('click', () => {
|
| 812 |
+
if (!settingsPanel.classList.contains('open')) {
|
| 813 |
+
document.getElementById('set-repo').value = CONFIG.repo;
|
| 814 |
+
document.getElementById('set-file').value = CONFIG.file;
|
| 815 |
+
document.getElementById('set-ctx').value = CONFIG.nCtx;
|
| 816 |
+
document.getElementById('set-maxtokens').value = CONFIG.maxTokens;
|
| 817 |
+
document.getElementById('set-temp').value = CONFIG.temperature;
|
| 818 |
+
document.getElementById('set-rounds').value = CONFIG.rounds;
|
| 819 |
+
document.getElementById('set-order').value = CONFIG.order;
|
| 820 |
+
document.getElementById('set-agents').value = JSON.stringify(agents, null, 2);
|
| 821 |
+
}
|
| 822 |
+
settingsPanel.classList.toggle('open');
|
| 823 |
+
});
|
| 824 |
+
document.getElementById('set-preset').addEventListener('change', e => {
|
| 825 |
+
const v = e.target.value; if (!v) return;
|
| 826 |
+
const [r, f] = v.split('|');
|
| 827 |
+
document.getElementById('set-repo').value = r;
|
| 828 |
+
document.getElementById('set-file').value = f;
|
| 829 |
+
});
|
| 830 |
+
document.getElementById('apply-settings').addEventListener('click', async () => {
|
| 831 |
+
try { agents = JSON.parse(document.getElementById('set-agents').value); }
|
| 832 |
+
catch (e) { alert('JSON de agentes inv\u00e1lido: ' + e.message); return; }
|
| 833 |
+
if (!Array.isArray(agents) || agents.length < 2) { alert('Se necesitan al menos 2 agentes.'); return; }
|
| 834 |
+
persistAgents();
|
| 835 |
+
renderContacts();
|
| 836 |
+
CONFIG.maxTokens = parseInt(document.getElementById('set-maxtokens').value) || CONFIG.maxTokens;
|
| 837 |
+
CONFIG.temperature = parseFloat(document.getElementById('set-temp').value) || CONFIG.temperature;
|
| 838 |
+
CONFIG.rounds = parseInt(document.getElementById('set-rounds').value) || CONFIG.rounds;
|
| 839 |
+
CONFIG.order = document.getElementById('set-order').value === 'rand' ? 'rand' : 'seq';
|
| 840 |
+
const newCtx = parseInt(document.getElementById('set-ctx').value) || CONFIG.nCtx;
|
| 841 |
+
const newRepo = document.getElementById('set-repo').value.trim();
|
| 842 |
+
const newFile = document.getElementById('set-file').value.trim();
|
| 843 |
+
const reload = newCtx !== CONFIG.nCtx || newRepo !== CONFIG.repo || newFile !== CONFIG.file;
|
| 844 |
+
CONFIG.nCtx = newCtx; CONFIG.repo = newRepo; CONFIG.file = newFile;
|
| 845 |
+
settingsPanel.classList.remove('open');
|
| 846 |
+
if (reload || !wllama) { transcript = []; chatEl.innerHTML = ''; await loadModel(CONFIG.repo, CONFIG.file); }
|
| 847 |
+
else setStatus(`Ajustes aplicados. Agentes: ${agents.map(a => a.name).join(', ')}.`);
|
| 848 |
+
});
|
| 849 |
+
|
| 850 |
+
if (CONFIG.autoload) loadModel(CONFIG.repo, CONFIG.file);
|
| 851 |
+
else setStatus('Modo manual: carga el modelo desde Ajustes.');
|
| 852 |
+
</script>
|
| 853 |
+
</body>
|
| 854 |
</html>
|
knowledge.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|