MaduRox commited on
Commit
8ca1f22
·
1 Parent(s): beabdf0

feat: deploy Kalpana RIF O(1) Studio with Needle-in-a-Haystack benchmarks, layer architecture, and Swagger API

Browse files
Files changed (1) hide show
  1. app.js +34 -28
app.js CHANGED
@@ -14,7 +14,7 @@ let ingestedChunks = [];
14
  // --- UI Element Selectors ---
15
  const chatHistory = document.getElementById('chatHistory');
16
  const chatInput = document.getElementById('chatInput');
17
- const btnSend = document.getElementById('btnSend');
18
  const tabButtons = document.querySelectorAll('.nav-btn');
19
  const tabPanes = document.querySelectorAll('.tab-pane');
20
 
@@ -372,37 +372,43 @@ if (btnRunH2H) {
372
  }
373
 
374
  // --- Ingestion Modal Logic ---
375
- btnOpenIngestModal.addEventListener('click', () => ingestModal.classList.add('active'));
376
- btnCloseModal.addEventListener('click', () => ingestModal.classList.remove('active'));
377
-
378
- btnIngestSubmit.addEventListener('click', () => {
379
- const txt = rawText.value.trim();
380
- if (!txt) return;
381
-
382
- const chunks = txt.split('\n').filter((c) => c.trim().length > 5);
383
- for (const chunk of chunks) {
384
- const id = ingestedChunks.length;
385
- const vec = computeSemanticEmbedding(chunk, DIM);
386
- ingestedChunks.push({ id, text: chunk, vec });
387
- if (memoryVault && memoryVault.ingestEmbedding) {
388
- try { memoryVault.ingestEmbedding(vec, { id, text: chunk }); } catch (e) {}
 
 
 
389
  }
390
- }
391
 
392
- rawText.value = '';
393
- ingestModal.classList.remove('active');
394
- const hudChunks = document.getElementById('hudChunks');
395
- if (hudChunks) hudChunks.textContent = `${ingestedChunks.length} chunks`;
396
- });
 
397
 
398
  // --- Event Listeners for Chat ---
399
- btnSend.addEventListener('click', handleUserChat);
400
- chatInput.addEventListener('keydown', (e) => {
401
- if (e.key === 'Enter' && !e.shiftKey) {
402
- e.preventDefault();
403
- handleUserChat();
404
- }
405
- });
 
 
406
 
407
  // Initialize on page load
408
  initVault();
 
 
14
  // --- UI Element Selectors ---
15
  const chatHistory = document.getElementById('chatHistory');
16
  const chatInput = document.getElementById('chatInput');
17
+ const btnSend = document.getElementById('btnSendChat') || document.getElementById('btnSend');
18
  const tabButtons = document.querySelectorAll('.nav-btn');
19
  const tabPanes = document.querySelectorAll('.tab-pane');
20
 
 
372
  }
373
 
374
  // --- Ingestion Modal Logic ---
375
+ if (btnOpenIngestModal) btnOpenIngestModal.addEventListener('click', () => ingestModal && ingestModal.classList.add('active'));
376
+ if (btnCloseModal) btnCloseModal.addEventListener('click', () => ingestModal && ingestModal.classList.remove('active'));
377
+
378
+ if (btnIngestSubmit) {
379
+ btnIngestSubmit.addEventListener('click', () => {
380
+ if (!rawText) return;
381
+ const txt = rawText.value.trim();
382
+ if (!txt) return;
383
+
384
+ const chunks = txt.split('\n').filter((c) => c.trim().length > 5);
385
+ for (const chunk of chunks) {
386
+ const id = ingestedChunks.length;
387
+ const vec = computeSemanticEmbedding(chunk, DIM);
388
+ ingestedChunks.push({ id, text: chunk, vec });
389
+ if (memoryVault && memoryVault.ingestEmbedding) {
390
+ try { memoryVault.ingestEmbedding(vec, { id, text: chunk }); } catch (e) {}
391
+ }
392
  }
 
393
 
394
+ rawText.value = '';
395
+ if (ingestModal) ingestModal.classList.remove('active');
396
+ const hudChunks = document.getElementById('hudChunks');
397
+ if (hudChunks) hudChunks.textContent = `${ingestedChunks.length} chunks`;
398
+ });
399
+ }
400
 
401
  // --- Event Listeners for Chat ---
402
+ if (btnSend) btnSend.addEventListener('click', handleUserChat);
403
+ if (chatInput) {
404
+ chatInput.addEventListener('keydown', (e) => {
405
+ if (e.key === 'Enter' && !e.shiftKey) {
406
+ e.preventDefault();
407
+ handleUserChat();
408
+ }
409
+ });
410
+ }
411
 
412
  // Initialize on page load
413
  initVault();
414
+