Sahil commited on
Commit
1dacc08
Β·
verified Β·
1 Parent(s): 9b276f2

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +96 -172
index.html CHANGED
@@ -4,7 +4,7 @@
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>ContinuumLearner - AI Training Pipeline</title>
8
  <style>
9
  * {
10
  margin: 0;
@@ -67,7 +67,20 @@
67
  font-size: 14px;
68
  }
69
 
70
- .training-area {
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  background: white;
72
  padding: 30px;
73
  border-radius: 20px;
@@ -75,32 +88,6 @@
75
  margin-bottom: 30px;
76
  }
77
 
78
- .model-selector {
79
- display: grid;
80
- grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
81
- gap: 10px;
82
- margin-bottom: 20px;
83
- }
84
-
85
- .model-btn {
86
- padding: 15px;
87
- background: linear-gradient(135deg, #667eea, #764ba2);
88
- color: white;
89
- border: none;
90
- border-radius: 10px;
91
- cursor: pointer;
92
- font-size: 14px;
93
- transition: transform 0.2s;
94
- }
95
-
96
- .model-btn:hover {
97
- transform: translateY(-2px);
98
- }
99
-
100
- .model-btn.active {
101
- background: linear-gradient(135deg, #f093fb, #f5576c);
102
- }
103
-
104
  .input-area {
105
  margin-bottom: 20px;
106
  }
@@ -132,11 +119,6 @@
132
  transform: translateY(-2px);
133
  }
134
 
135
- .btn:disabled {
136
- opacity: 0.5;
137
- cursor: not-allowed;
138
- }
139
-
140
  .response-area {
141
  background: #f8f9fa;
142
  padding: 20px;
@@ -165,184 +147,110 @@
165
  font-size: 14px;
166
  }
167
 
168
- .log-entry:last-child {
169
- border-bottom: none;
170
- }
171
-
172
- .success {
173
- color: #28a745;
174
- }
175
-
176
- .error {
177
- color: #dc3545;
178
- }
179
-
180
- .loading {
181
- display: inline-block;
182
- width: 20px;
183
- height: 20px;
184
- border: 2px solid rgba(255, 255, 255, 0.3);
185
- border-radius: 50%;
186
- border-top-color: white;
187
- animation: spin 1s linear infinite;
188
- }
189
-
190
- @keyframes spin {
191
- to { transform: rotate(360deg); }
192
- }
193
  </style>
194
  </head>
195
  <body>
196
  <div class="container">
197
  <div class="header">
198
- <h1>🧠 ContinuumLearner</h1>
199
- <p>Model Training Pipeline - Copy AI Behavior</p>
200
  <p style="margin-top: 10px; color: #666;">
201
- Training dataset: <a href="https://huggingface.co/datasets/Sahil5112/ContinuumGPT" target="_blank" style="color: #667eea;">Sahil5112/ContinuumGPT</a>
202
  </p>
203
  <p style="margin-top: 5px; color: #999; font-size: 13px;">
204
- πŸŽ“ Train ContinuumGPT by copying responses from top AI models
205
  </p>
206
  </div>
207
 
208
  <div class="stats">
209
  <div class="stat-card">
210
- <h3 id="totalConversations">0</h3>
211
- <p>Training Examples</p>
212
- </div>
213
- <div class="stat-card">
214
- <h3 id="totalTokens">0</h3>
215
- <p>Total Tokens</p>
216
  </div>
217
  <div class="stat-card">
218
- <h3 id="autoGenerated">0</h3>
219
- <p>Auto-Generated</p>
 
220
  </div>
221
  <div class="stat-card">
222
- <h3 id="manualGenerated">0</h3>
223
- <p>Manual</p>
 
224
  </div>
225
  <div class="stat-card">
226
  <h3 id="bufferedCount">0</h3>
227
  <p>Buffered (Unsaved)</p>
228
  </div>
229
  <div class="stat-card">
230
- <h3 id="sessionCount">0</h3>
231
- <p>This Session</p>
232
  </div>
233
  </div>
234
 
235
- <div class="training-area">
236
- <h2 style="margin-bottom: 20px; color: #667eea;">AI Model</h2>
237
- <div class="model-selector" id="modelSelector">
238
- <button class="model-btn active" data-model="gpt-4o-mini">GPT-4o-mini (Low Credits)</button>
239
- </div>
240
 
241
  <div class="input-area">
242
- <h3 style="margin-bottom: 10px; color: #667eea;">Training Input</h3>
243
- <textarea id="userInput" placeholder="Enter a message to train the AI..."></textarea>
244
  </div>
245
 
246
- <button class="btn" onclick="trainModel()">πŸš€ Train Model</button>
247
- <button class="btn" onclick="flushBuffer()">πŸ’Ύ Save to HuggingFace</button>
248
- <button class="btn" onclick="refreshStats()">πŸ”„ Refresh Stats</button>
 
249
 
250
  <div class="response-area">
251
- <h3>AI Response</h3>
252
  <div id="responseText" style="white-space: pre-wrap;"></div>
 
253
  </div>
254
  </div>
255
 
256
  <div class="log">
257
- <h2 style="margin-bottom: 15px; color: #667eea;">Training Log</h2>
258
- <div id="trainingLog"></div>
259
  </div>
260
  </div>
261
 
262
  <script>
263
- let selectedModel = "gpt-4o-mini";
264
- let sessionCount = 0;
265
-
266
- // Model selector
267
- document.querySelectorAll('.model-btn').forEach(btn => {
268
- btn.addEventListener('click', function() {
269
- document.querySelectorAll('.model-btn').forEach(b => b.classList.remove('active'));
270
- this.classList.add('active');
271
- selectedModel = this.dataset.model;
272
- addLog(`Selected model: ${selectedModel}`, 'success');
273
- });
274
- });
275
-
276
- async function trainModel() {
277
- const userInput = document.getElementById('userInput').value.trim();
278
- if (!userInput) {
279
  alert('Please enter a message');
280
  return;
281
  }
282
 
283
  const responseText = document.getElementById('responseText');
284
- responseText.innerHTML = '<div class="loading"></div> Generating response...';
 
 
285
 
286
  try {
287
- // Get AI response from backend
288
- addLog(`πŸ”„ Calling ${selectedModel}...`, 'success');
289
-
290
- const generateResponse = await fetch('/api/generate', {
291
  method: 'POST',
292
  headers: { 'Content-Type': 'application/json' },
293
- body: JSON.stringify({
294
- prompt: userInput,
295
- model: selectedModel
296
- })
297
  });
298
 
299
- const generateData = await generateResponse.json();
300
-
301
- if (!generateData.success) {
302
- responseText.textContent = `Error: ${generateData.error}`;
303
- addLog(`❌ Error: ${generateData.error}`, 'error');
304
 
305
- if (generateData.error.includes('OPENAI_API_KEY')) {
306
- addLog('πŸ’‘ Add OPENAI_API_KEY to Secrets to enable AI model training', 'error');
307
- }
308
  return;
309
  }
310
 
311
- const response = generateData.response;
312
- responseText.textContent = response;
313
- addLog(`βœ… Generated response using ${selectedModel}`, 'success');
314
 
315
- // Send to backend for training
316
- const trainResponse = await fetch('/api/train', {
317
- method: 'POST',
318
- headers: { 'Content-Type': 'application/json' },
319
- body: JSON.stringify({
320
- user_input: userInput,
321
- ai_response: response,
322
- model_used: selectedModel
323
- })
324
- });
325
-
326
- const trainData = await trainResponse.json();
327
-
328
- if (trainData.success) {
329
- sessionCount++;
330
- document.getElementById('sessionCount').textContent = sessionCount;
331
- document.getElementById('bufferedCount').textContent = trainData.buffered;
332
- addLog(trainData.message, 'success');
333
-
334
- // Clear input
335
- document.getElementById('userInput').value = '';
336
-
337
- // Auto-save when buffer is full
338
- if (trainData.buffered >= 10) {
339
- addLog('Buffer full! Auto-saving to HuggingFace...', 'success');
340
- await flushBuffer();
341
- }
342
- } else {
343
- addLog('❌ Failed to save training data', 'error');
344
- }
345
 
 
346
  } catch (error) {
347
  responseText.textContent = `Error: ${error.message}`;
348
  addLog(`❌ Error: ${error.message}`, 'error');
@@ -358,10 +266,27 @@
358
  addLog(`πŸ’Ύ ${data.message}`, 'success');
359
  await refreshStats();
360
  } else {
361
- addLog(data.message || 'Buffer empty', 'success');
362
  }
363
  } catch (error) {
364
- addLog(`❌ Error flushing buffer: ${error.message}`, 'error');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  }
366
  }
367
 
@@ -371,46 +296,45 @@
371
  const data = await response.json();
372
 
373
  if (data.success) {
374
- document.getElementById('totalConversations').textContent = data.total_examples;
375
- document.getElementById('totalTokens').textContent = data.total_tokens.toLocaleString();
376
- document.getElementById('autoGenerated').textContent = data.auto_generated || 0;
377
- document.getElementById('manualGenerated').textContent = data.manual_generated || 0;
378
  document.getElementById('bufferedCount').textContent = data.buffered;
 
379
  addLog('πŸ“Š Stats refreshed', 'success');
380
  }
381
  } catch (error) {
382
- addLog(`❌ Error refreshing stats: ${error.message}`, 'error');
383
  }
384
  }
385
 
386
  function addLog(message, type = '') {
387
- const log = document.getElementById('trainingLog');
388
  const entry = document.createElement('div');
389
  entry.className = `log-entry ${type}`;
390
  entry.textContent = `[${new Date().toLocaleTimeString()}] ${message}`;
391
  log.insertBefore(entry, log.firstChild);
392
 
393
- // Keep only last 50 entries
394
  while (log.children.length > 50) {
395
  log.removeChild(log.lastChild);
396
  }
397
  }
398
 
399
- // Initialize stats on load
400
  refreshStats();
401
- addLog('πŸš€ ContinuumLearner initialized', 'success');
402
- addLog('πŸ€– AUTO-TRAINING ACTIVE - Training runs every 5 minutes', 'success');
403
- addLog('πŸ’‘ You can also manually train by entering prompts!', 'success');
404
-
405
- // Auto-refresh stats every 30 seconds
406
  setInterval(refreshStats, 30000);
407
 
408
- // Enter key to submit
409
- document.getElementById('userInput').addEventListener('keydown', function(e) {
410
  if (e.key === 'Enter' && e.ctrlKey) {
411
- trainModel();
412
  }
413
  });
414
- </script>
 
415
  </body>
416
  </html>
 
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>ContinuumGPT - Hierarchical Memory</title>
8
  <style>
9
  * {
10
  margin: 0;
 
67
  font-size: 14px;
68
  }
69
 
70
+ .level-badge {
71
+ display: inline-block;
72
+ padding: 2px 8px;
73
+ border-radius: 12px;
74
+ font-size: 11px;
75
+ font-weight: bold;
76
+ margin-top: 5px;
77
+ }
78
+
79
+ .level-1 { background: #4CAF50; color: white; }
80
+ .level-2 { background: #FF9800; color: white; }
81
+ .level-3 { background: #9C27B0; color: white; }
82
+
83
+ .chat-area {
84
  background: white;
85
  padding: 30px;
86
  border-radius: 20px;
 
88
  margin-bottom: 30px;
89
  }
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  .input-area {
92
  margin-bottom: 20px;
93
  }
 
119
  transform: translateY(-2px);
120
  }
121
 
 
 
 
 
 
122
  .response-area {
123
  background: #f8f9fa;
124
  padding: 20px;
 
147
  font-size: 14px;
148
  }
149
 
150
+ .success { color: #28a745; }
151
+ .error { color: #dc3545; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  </style>
153
  </head>
154
  <body>
155
  <div class="container">
156
  <div class="header">
157
+ <h1>🧠 ContinuumGPT</h1>
158
+ <p>Hierarchical Memory System</p>
159
  <p style="margin-top: 10px; color: #666;">
160
+ Dataset: <a href="https://huggingface.co/datasets/Sahil5112/ContinuumGPT" target="_blank" style="color: #667eea;">Sahil5112/ContinuumGPT</a>
161
  </p>
162
  <p style="margin-top: 5px; color: #999; font-size: 13px;">
163
+ πŸ—„οΈ Level 1: Fresh β†’ Level 2: Archived β†’ Level 3: Super-Summary
164
  </p>
165
  </div>
166
 
167
  <div class="stats">
168
  <div class="stat-card">
169
+ <h3 id="level1Count">0</h3>
170
+ <p>Level 1 (Fresh)</p>
171
+ <span class="level-badge level-1">Detailed Q&A</span>
 
 
 
172
  </div>
173
  <div class="stat-card">
174
+ <h3 id="level2Count">0</h3>
175
+ <p>Level 2 (Archived)</p>
176
+ <span class="level-badge level-2">Compressed</span>
177
  </div>
178
  <div class="stat-card">
179
+ <h3 id="level3Count">0</h3>
180
+ <p>Level 3 (Super)</p>
181
+ <span class="level-badge level-3">Global Knowledge</span>
182
  </div>
183
  <div class="stat-card">
184
  <h3 id="bufferedCount">0</h3>
185
  <p>Buffered (Unsaved)</p>
186
  </div>
187
  <div class="stat-card">
188
+ <h3 id="totalEntries">0</h3>
189
+ <p>Total Entries</p>
190
  </div>
191
  </div>
192
 
193
+ <div class="chat-area">
194
+ <h2 style="margin-bottom: 20px; color: #667eea;">Chat with ContinuumGPT</h2>
 
 
 
195
 
196
  <div class="input-area">
197
+ <textarea id="userQuery" placeholder="Ask me anything..."></textarea>
 
198
  </div>
199
 
200
+ <button class="btn" onclick="sendMessage()">πŸ’¬ Send</button>
201
+ <button class="btn" onclick="flushBuffer()">πŸ’Ύ Save Buffer</button>
202
+ <button class="btn" onclick="archiveNow()">πŸ“¦ Archive Now</button>
203
+ <button class="btn" onclick="refreshStats()">πŸ”„ Refresh</button>
204
 
205
  <div class="response-area">
206
+ <h3>Response</h3>
207
  <div id="responseText" style="white-space: pre-wrap;"></div>
208
+ <div id="summaryText" style="margin-top: 10px; font-style: italic; color: #666;"></div>
209
  </div>
210
  </div>
211
 
212
  <div class="log">
213
+ <h2 style="margin-bottom: 15px; color: #667eea;">Activity Log</h2>
214
+ <div id="activityLog"></div>
215
  </div>
216
  </div>
217
 
218
  <script>
219
+ async function sendMessage() {
220
+ const query = document.getElementById('userQuery').value.trim();
221
+ if (!query) {
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  alert('Please enter a message');
223
  return;
224
  }
225
 
226
  const responseText = document.getElementById('responseText');
227
+ const summaryText = document.getElementById('summaryText');
228
+ responseText.innerHTML = 'πŸ”„ Thinking...';
229
+ summaryText.innerHTML = '';
230
 
231
  try {
232
+ const response = await fetch('/api/chat', {
 
 
 
233
  method: 'POST',
234
  headers: { 'Content-Type': 'application/json' },
235
+ body: JSON.stringify({ query })
 
 
 
236
  });
237
 
238
+ const data = await response.json();
 
 
 
 
239
 
240
+ if (!data.success) {
241
+ responseText.textContent = `Error: ${data.error}`;
242
+ addLog(`❌ Error: ${data.error}`, 'error');
243
  return;
244
  }
245
 
246
+ responseText.textContent = data.response;
247
+ summaryText.innerHTML = `πŸ“ Summary: ${data.summary}`;
248
+ addLog(`βœ… Response saved to Level ${data.level} (${data.buffered} buffered)`, 'success');
249
 
250
+ document.getElementById('userQuery').value = '';
251
+ document.getElementById('bufferedCount').textContent = data.buffered;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
 
253
+ await refreshStats();
254
  } catch (error) {
255
  responseText.textContent = `Error: ${error.message}`;
256
  addLog(`❌ Error: ${error.message}`, 'error');
 
266
  addLog(`πŸ’Ύ ${data.message}`, 'success');
267
  await refreshStats();
268
  } else {
269
+ addLog(data.message, 'success');
270
  }
271
  } catch (error) {
272
+ addLog(`❌ Error: ${error.message}`, 'error');
273
+ }
274
+ }
275
+
276
+ async function archiveNow() {
277
+ try {
278
+ addLog('πŸ”„ Running archive process...', 'success');
279
+ const response = await fetch('/api/archive-now', { method: 'POST' });
280
+ const data = await response.json();
281
+
282
+ if (data.success) {
283
+ addLog(`πŸ“¦ ${data.message}`, 'success');
284
+ await refreshStats();
285
+ } else {
286
+ addLog(`Error: ${data.error}`, 'error');
287
+ }
288
+ } catch (error) {
289
+ addLog(`❌ Error: ${error.message}`, 'error');
290
  }
291
  }
292
 
 
296
  const data = await response.json();
297
 
298
  if (data.success) {
299
+ document.getElementById('level1Count').textContent = data.level_1_fresh;
300
+ document.getElementById('level2Count').textContent = data.level_2_archived;
301
+ document.getElementById('level3Count').textContent = data.level_3_super;
 
302
  document.getElementById('bufferedCount').textContent = data.buffered;
303
+ document.getElementById('totalEntries').textContent = data.total_entries;
304
  addLog('πŸ“Š Stats refreshed', 'success');
305
  }
306
  } catch (error) {
307
+ addLog(`❌ Error: ${error.message}`, 'error');
308
  }
309
  }
310
 
311
  function addLog(message, type = '') {
312
+ const log = document.getElementById('activityLog');
313
  const entry = document.createElement('div');
314
  entry.className = `log-entry ${type}`;
315
  entry.textContent = `[${new Date().toLocaleTimeString()}] ${message}`;
316
  log.insertBefore(entry, log.firstChild);
317
 
 
318
  while (log.children.length > 50) {
319
  log.removeChild(log.lastChild);
320
  }
321
  }
322
 
323
+ // Initialize
324
  refreshStats();
325
+ addLog('πŸš€ ContinuumGPT Hierarchical Memory initialized', 'success');
326
+ addLog('πŸ—„οΈ Auto-archiving runs every 10 minutes', 'success');
327
+
328
+ // Auto-refresh
 
329
  setInterval(refreshStats, 30000);
330
 
331
+ // Enter to send
332
+ document.getElementById('userQuery').addEventListener('keydown', function(e) {
333
  if (e.key === 'Enter' && e.ctrlKey) {
334
+ sendMessage();
335
  }
336
  });
337
+
338
+ </script>
339
  </body>
340
  </html>