everydaytok commited on
Commit
1357925
·
verified ·
1 Parent(s): b39794e

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +68 -127
index.html CHANGED
@@ -2,193 +2,134 @@
2
  <html lang="en">
3
  <head>
4
  <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
6
- <title>Mesh Reasoner Lab Mobile</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
8
  <script src="https://cdn.plot.ly/plotly-2.24.1.min.js"></script>
9
  <style>
10
- body { background: #06090e; color: #cbd5e1; font-family: monospace; overflow: hidden; }
11
  .glass { background: rgba(15,23,42,0.95); border: 1px solid #334155; }
12
- .force-pos { color: #4ade80; }
13
- .force-neg { color: #f87171; }
14
- /* Control Drawer for Mobile */
15
- #drawer { transition: transform 0.3s ease-in-out; z-index: 50; }
16
  .drawer-hidden { transform: translateY(100%); }
17
- @media (min-width: 1024px) {
18
- #drawer { transform: none !important; position: static; width: 24rem; height: 100%; }
19
- #drawer-toggle { display: none; }
20
- }
21
  </style>
22
  </head>
23
- <body class="flex flex-col lg:flex-row h-screen">
24
 
25
- <!-- Header for Mobile -->
26
- <header class="lg:hidden glass p-3 flex justify-between items-center z-10">
27
- <h1 class="text-blue-400 font-bold text-sm">MESH REASONER</h1>
28
- <button onclick="toggleDrawer()" id="drawer-toggle" class="bg-blue-600 px-4 py-1 rounded text-white text-xs font-bold">⚙️ SETTINGS</button>
29
  </header>
30
 
31
- <!-- Controls Drawer / Sidebar -->
32
- <aside id="drawer" class="fixed inset-x-0 bottom-0 lg:relative lg:translate-y-0 drawer-hidden glass p-4 flex flex-col gap-4 overflow-y-auto max-h-[80vh] lg:max-h-full">
33
- <div class="flex justify-between items-center lg:hidden border-b border-slate-700 pb-2">
34
- <span class="text-orange-400 font-bold">CONFIG DIALS</span>
35
- <button onclick="toggleDrawer()" class="text-slate-400">CLOSE ✕</button>
36
  </div>
37
 
38
- <div class="space-y-4 text-sm lg:text-xs">
39
  <section>
40
- <label class="text-slate-500 block mb-1">PHASE</label>
41
- <select id="mode" onchange="sendConfig()" class="w-full bg-slate-900 border border-slate-700 p-2 lg:p-1 rounded">
42
- <option value="inference">INFERENCE (Solving)</option>
43
- <option value="training">TRAINING (Learning K)</option>
44
  </select>
45
  </section>
46
 
47
- <section>
48
- <label class="text-slate-500 block mb-1">CONSTRAINT LOGIC</label>
49
- <select id="probType" onchange="sendConfig()" class="w-full bg-slate-900 border border-slate-700 p-2 lg:p-1 rounded">
50
- <option value="add">A + B = C</option>
51
- <option value="mult">A * B = C</option>
52
- </select>
53
  </section>
54
 
55
- <section class="border-t border-slate-800 pt-2">
56
- <label class="text-green-400 block mb-1">TARGET C:</label>
57
- <input type="number" id="singleVal" value="45" class="w-full bg-black border border-slate-700 p-2 text-center text-lg lg:text-base font-bold">
58
- <button onclick="triggerSingle(); toggleDrawer()" class="w-full bg-blue-700 mt-2 py-3 lg:py-1 font-bold rounded shadow-lg">ENGAGE SINGLE RUN</button>
 
 
 
59
  </section>
60
 
61
- <section class="bg-slate-900/50 p-2 rounded border border-slate-800">
62
- <label class="text-purple-400 block mb-1">BATCH TEST SETS:</label>
63
- <input type="number" id="b_count" value="10" class="w-full bg-black border border-slate-700 p-2 mb-1">
64
- <button onclick="triggerBatch(); toggleDrawer()" class="w-full bg-purple-700 py-3 lg:py-1 font-bold rounded">START BATCH RUN</button>
65
- </section>
66
-
67
- <button onclick="triggerHalt(); toggleDrawer()" class="w-full border border-red-500 text-red-500 py-2 hover:bg-red-900 rounded">RESET ENGINE</button>
68
- </div>
69
-
70
- <div class="mt-auto border-t border-slate-800 pt-4 pb-6 lg:pb-0">
71
- <h3 class="text-xs text-orange-400 uppercase tracking-widest">Live Error</h3>
72
- <div id="error-meter" class="text-3xl lg:text-2xl font-bold">0.000</div>
73
- <div class="w-full bg-slate-800 h-3 mt-1 rounded-full overflow-hidden">
74
- <div id="error-bar" class="bg-red-500 h-full transition-all" style="width: 0%"></div>
75
- </div>
76
  </div>
77
  </aside>
78
 
79
- <!-- Main Viewport -->
80
  <main class="flex-grow flex flex-col min-h-0">
81
- <!-- 3D Plot Area -->
82
- <div id="plot" class="flex-grow min-h-[40vh]"></div>
83
 
84
- <!-- Live Data Feed Area -->
85
- <div class="h-48 lg:h-64 border-t border-slate-700 flex flex-col lg:flex-row bg-black/80 backdrop-blur-md">
86
- <!-- Force Meters -->
87
- <div id="force-tracker" class="w-full lg:w-1/2 p-3 border-b lg:border-b-0 lg:border-r border-slate-800 text-[10px] lg:text-[11px] overflow-y-auto">
88
- <h4 class="text-blue-300 mb-1 sticky top-0 bg-black/80">NODE FORCES (ADOPTION)</h4>
89
- <div id="node-details" class="space-y-1">Waiting...</div>
90
- </div>
91
- <!-- Event Log -->
92
- <div id="logger" class="hidden lg:block lg:w-1/2 p-3 text-[10px] text-slate-500 overflow-y-auto">
93
- <h4 class="text-slate-400 mb-1">EVENT LOG</h4>
94
- <div id="log-content">...</div>
95
  </div>
 
 
96
  </div>
97
  </main>
98
 
99
  <script>
100
- let drawerOpen = false;
101
- function toggleDrawer() {
102
- const drawer = document.getElementById('drawer');
103
- drawerOpen = !drawerOpen;
104
- if (drawerOpen) drawer.classList.remove('drawer-hidden');
105
- else drawer.classList.add('drawer-hidden');
106
- }
107
 
108
  async function sendConfig() {
109
- await fetch('/apply_config', {
110
  method: 'POST', headers: {'Content-Type': 'application/json'},
111
- body: JSON.stringify({
112
- mode: document.getElementById('mode').value,
113
- distribution: 'individual',
114
- problem_type: document.getElementById('probType').value,
115
- asymmetric: false
116
- })
117
  });
118
  }
119
 
120
- async function triggerSingle() {
121
- await sendConfig();
122
- await fetch('/single_run', {
123
  method: 'POST', headers: {'Content-Type':'application/json'},
124
- body: JSON.stringify({ target: document.getElementById('singleVal').value })
125
  });
126
  }
127
 
128
- async function triggerBatch() {
129
- await fetch('/batch_run', {
 
130
  method: 'POST', headers: {'Content-Type':'application/json'},
131
- body: JSON.stringify({
132
- batch_size: document.getElementById('b_count').value,
133
- val_min: 10, val_max: 100
134
- })
135
  });
136
  }
137
 
138
- async function triggerHalt() { await fetch('/halt', {method: 'POST'}); }
139
 
140
  setInterval(async () => {
141
  try {
142
- const r = await fetch('/state');
143
- const d = await r.json();
144
-
145
- // 1. Error Logic
146
- const err = Math.abs(d.error);
147
- document.getElementById('error-meter').innerText = d.error.toFixed(4);
148
- document.getElementById('error-bar').style.width = Math.min(100, err * 2) + "%";
149
- document.getElementById('error-meter').className = err < 0.1 ? "text-green-400 text-3xl font-bold" : "text-red-400 text-3xl font-bold";
150
 
151
- // 2. Nodes/Forces Logic
152
- let forceHTML = "";
 
153
  let px=[], py=[], pz=[], ids=[];
154
  Object.keys(d.nodes).forEach(id => {
155
  const n = d.nodes[id];
156
- const fColor = n.force > 0 ? "text-green-400" : "text-red-400";
157
- forceHTML += `<div class="border-b border-slate-900 pb-1">NODE ${id}: <span class="text-white">X=${n.x.toFixed(2)}</span> | <span class="${fColor}">F=${n.force.toFixed(3)}</span> | K=${n.k.toFixed(3)}</div>`;
158
- px.push(n.x); py.push(n.y); pz.push(n.z); ids.push(id);
159
  });
160
- document.getElementById('node-details').innerHTML = forceHTML;
161
- document.getElementById('log-content').innerHTML = d.logs.map(l => `<div>${l}</div>`).join('');
162
 
163
- // 3. Optimized Plotly Logic
164
  const trace = {
165
  type: 'scatter3d', mode: 'lines+markers+text',
166
  x: px.concat([px[0]]), y: py.concat([py[0]]), z: pz.concat([pz[0]]),
167
- text: ids.concat(['']),
168
- marker: {size: 8, color: ['#fb923c','#c084fc','#38bdf8']},
169
- line: {color: '#334155', width: 2}
170
  };
171
  const layout = {
172
- margin: {l:0,r:0,t:0,b:0},
173
- paper_bgcolor: 'transparent',
174
- showlegend: false,
175
- scene: {
176
- xaxis: {range: [-5, 105], color: '#475569'},
177
- yaxis: {range: [-3, 3], color: '#475569'},
178
- zaxis: {range: [-3, 3], color: '#475569'},
179
- camera: { eye: {x: 1.2, y: 1.2, z: 1.2} }
180
  }
181
  };
182
- const config = { responsive: true, displayModeBar: false };
183
-
184
- if(!window.plotted){
185
- Plotly.newPlot('plot', [trace], layout, config);
186
- window.plotted=true;
187
- } else {
188
- Plotly.react('plot', [trace], layout, config);
189
- }
190
-
191
- } catch(e) {}
192
  }, 200);
193
  </script>
194
  </body>
 
2
  <html lang="en">
3
  <head>
4
  <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Mesh Reasoner Lab</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
8
  <script src="https://cdn.plot.ly/plotly-2.24.1.min.js"></script>
9
  <style>
10
+ body { background: #06090e; color: #cbd5e1; font-family: monospace; }
11
  .glass { background: rgba(15,23,42,0.95); border: 1px solid #334155; }
12
+ #drawer { transition: transform 0.3s ease-in-out; }
 
 
 
13
  .drawer-hidden { transform: translateY(100%); }
 
 
 
 
14
  </style>
15
  </head>
16
+ <body class="flex flex-col h-screen overflow-hidden">
17
 
18
+ <header class="glass p-3 flex justify-between items-center z-10">
19
+ <h1 class="text-blue-400 font-bold text-xs uppercase tracking-tighter">Topological Model</h1>
20
+ <button onclick="toggleDrawer()" class="bg-blue-600 px-4 py-1 rounded text-white text-xs font-bold">SETTINGS / TOOLS</button>
 
21
  </header>
22
 
23
+ <aside id="drawer" class="fixed inset-x-0 bottom-0 drawer-hidden glass p-4 flex flex-col gap-4 z-50 max-h-[90vh] overflow-y-auto">
24
+ <div class="flex justify-between items-center border-b border-slate-700 pb-2">
25
+ <span class="text-orange-400 font-bold">CONTROLS</span>
26
+ <button onclick="toggleDrawer()" class="text-slate-400 text-xl"></button>
 
27
  </div>
28
 
29
+ <div class="space-y-4">
30
  <section>
31
+ <label class="text-slate-500 text-[10px]">MODE</label>
32
+ <select id="mode" onchange="sendConfig()" class="w-full bg-slate-900 border border-slate-700 p-2 text-white">
33
+ <option value="training">TRAINING (A,B,C Locked -> Learn K)</option>
34
+ <option value="inference">INFERENCE (A,B Locked -> C Drifts)</option>
35
  </select>
36
  </section>
37
 
38
+ <section class="bg-purple-900/20 p-3 rounded border border-purple-800">
39
+ <label class="text-purple-400 font-bold text-xs">FACTORIZATION DATASET</label>
40
+ <div class="flex gap-2 mt-2">
41
+ <input type="number" id="batch_count" value="10" class="w-1/2 bg-black text-center p-2 border border-slate-700">
42
+ <button onclick="genFactors()" class="w-1/2 bg-purple-700 font-bold text-xs rounded">START SET</button>
43
+ </div>
44
  </section>
45
 
46
+ <section class="bg-blue-900/20 p-3 rounded border border-blue-800">
47
+ <label class="text-blue-400 font-bold text-xs">CUSTOM TEST (FORWARD PASS)</label>
48
+ <div class="grid grid-cols-2 gap-2 mt-2">
49
+ <input type="number" id="custom_a" placeholder="A" class="bg-black text-center p-2 border border-slate-700">
50
+ <input type="number" id="custom_b" placeholder="B" class="bg-black text-center p-2 border border-slate-700">
51
+ </div>
52
+ <button onclick="testCustom()" class="w-full bg-blue-700 mt-2 py-2 font-bold text-xs rounded uppercase">Predict C</button>
53
  </section>
54
 
55
+ <button onclick="triggerHalt()" class="w-full border border-red-500 text-red-500 py-3 rounded font-bold">RESET ENGINE</button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  </div>
57
  </aside>
58
 
 
59
  <main class="flex-grow flex flex-col min-h-0">
60
+ <div id="plot" class="flex-grow"></div>
 
61
 
62
+ <div class="h-56 glass border-t border-slate-700 p-4 flex flex-col overflow-y-auto">
63
+ <div class="flex justify-between items-center mb-2">
64
+ <h4 class="text-blue-300 text-[10px] font-bold">MODEL STATE</h4>
65
+ <div id="error-val" class="text-xs font-bold">ERR: 0.000</div>
 
 
 
 
 
 
 
66
  </div>
67
+ <div id="nodes-ui" class="space-y-1 text-[11px]"></div>
68
+ <div id="logs" class="mt-3 pt-2 border-t border-slate-800 text-[9px] text-slate-500 space-y-1"></div>
69
  </div>
70
  </main>
71
 
72
  <script>
73
+ let drawer = document.getElementById('drawer');
74
+ function toggleDrawer() { drawer.classList.toggle('drawer-hidden'); }
 
 
 
 
 
75
 
76
  async function sendConfig() {
77
+ await fetch('/config', {
78
  method: 'POST', headers: {'Content-Type': 'application/json'},
79
+ body: JSON.stringify({ mode: document.getElementById('mode').value })
 
 
 
 
 
80
  });
81
  }
82
 
83
+ async function genFactors() {
84
+ toggleDrawer();
85
+ await fetch('/generate_factors', {
86
  method: 'POST', headers: {'Content-Type':'application/json'},
87
+ body: JSON.stringify({ count: document.getElementById('batch_count').value })
88
  });
89
  }
90
 
91
+ async function testCustom() {
92
+ toggleDrawer();
93
+ await fetch('/test_custom', {
94
  method: 'POST', headers: {'Content-Type':'application/json'},
95
+ body: JSON.stringify({ a: document.getElementById('custom_a').value, b: document.getElementById('custom_b').value })
 
 
 
96
  });
97
  }
98
 
99
+ async function triggerHalt() { toggleDrawer(); await fetch('/halt', {method: 'POST'}); }
100
 
101
  setInterval(async () => {
102
  try {
103
+ const res = await fetch('/state');
104
+ const d = await res.json();
 
 
 
 
 
 
105
 
106
+ document.getElementById('error-val').innerText = "ERR: " + d.error.toFixed(4);
107
+
108
+ let ui = "";
109
  let px=[], py=[], pz=[], ids=[];
110
  Object.keys(d.nodes).forEach(id => {
111
  const n = d.nodes[id];
112
+ ui += `<div class="flex justify-between"><span>NODE ${id}: <b class="text-white">${n.x.toFixed(2)}</b></span> <span class="text-slate-500">K: ${n.k.toFixed(4)} | F: ${n.f.toFixed(3)}</span></div>`;
113
+ px.push(n.x); py.push(id==='A'?1:id==='B'?-1:0); pz.push(0); ids.push(id);
 
114
  });
115
+ document.getElementById('nodes-ui').innerHTML = ui;
116
+ document.getElementById('logs').innerHTML = d.logs.map(l => `<div>${l}</div>`).join('');
117
 
 
118
  const trace = {
119
  type: 'scatter3d', mode: 'lines+markers+text',
120
  x: px.concat([px[0]]), y: py.concat([py[0]]), z: pz.concat([pz[0]]),
121
+ text: ids.concat(['']), marker: {size: 10, color:['#fb923c','#c084fc','#38bdf8']}
 
 
122
  };
123
  const layout = {
124
+ margin:{l:0,r:0,t:0,b:0}, paper_bgcolor:'transparent',
125
+ scene:{
126
+ xaxis:{color:'#475569'}, yaxis:{range:[-3,3], color:'#475569'}, zaxis:{range:[-3,3], color:'#475569'},
127
+ camera: {eye:{x:1.5, y:1.5, z:1.5}}
 
 
 
 
128
  }
129
  };
130
+ if(!window.plotted){ Plotly.newPlot('plot', [trace], layout, {displayModeBar:false}); window.plotted=true; }
131
+ else { Plotly.react('plot', [trace], layout); }
132
+ } catch(e){}
 
 
 
 
 
 
 
133
  }, 200);
134
  </script>
135
  </body>