Spaces:
Running
Running
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
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 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
const
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
|
|
|
|
|
|
|
|
|
| 389 |
}
|
| 390 |
-
}
|
| 391 |
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
});
|
|
|
|
| 397 |
|
| 398 |
// --- Event Listeners for Chat ---
|
| 399 |
-
btnSend.addEventListener('click', handleUserChat);
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
e.
|
| 403 |
-
|
| 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 |
+
|