Spaces:
Running
Running
Upload js/app.js with huggingface_hub
Browse files
js/app.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
* FADA Mobile - Main application logic.
|
| 3 |
* Manages UI state, chat interaction, and autonomous pipeline.
|
| 4 |
*/
|
| 5 |
-
import { loadModel, runInference, getLoadingStatus, getActiveDevice } from "./model.js";
|
| 6 |
import { parseModelOutput, rescalePredictions } from "./output-parser.js";
|
| 7 |
import { parseIntent } from "./intent-parser.js";
|
| 8 |
import { parseInterpretationJson, extractClsLabel, mapInterpretationToClasses } from "./class-mapper.js";
|
|
@@ -130,6 +130,7 @@ async function handleLoadModel() {
|
|
| 130 |
setStatus(`Model loaded on ${device} - ready for inference`);
|
| 131 |
showProgress(false);
|
| 132 |
enableChat(true);
|
|
|
|
| 133 |
if (device === "webgpu") {
|
| 134 |
addMessage("system", "Model loaded on GPU. First inference may take 1-2 min for shader compilation.");
|
| 135 |
} else {
|
|
@@ -507,3 +508,27 @@ function setProgress(pct, text) {
|
|
| 507 |
progressBar.style.width = `${pct}%`;
|
| 508 |
progressText.textContent = text || "";
|
| 509 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
* FADA Mobile - Main application logic.
|
| 3 |
* Manages UI state, chat interaction, and autonomous pipeline.
|
| 4 |
*/
|
| 5 |
+
import { loadModel, runInference, getLoadingStatus, getActiveDevice, testTextOnly } from "./model.js";
|
| 6 |
import { parseModelOutput, rescalePredictions } from "./output-parser.js";
|
| 7 |
import { parseIntent } from "./intent-parser.js";
|
| 8 |
import { parseInterpretationJson, extractClsLabel, mapInterpretationToClasses } from "./class-mapper.js";
|
|
|
|
| 130 |
setStatus(`Model loaded on ${device} - ready for inference`);
|
| 131 |
showProgress(false);
|
| 132 |
enableChat(true);
|
| 133 |
+
document.getElementById('test-text-btn').disabled = false;
|
| 134 |
if (device === "webgpu") {
|
| 135 |
addMessage("system", "Model loaded on GPU. First inference may take 1-2 min for shader compilation.");
|
| 136 |
} else {
|
|
|
|
| 508 |
progressBar.style.width = `${pct}%`;
|
| 509 |
progressText.textContent = text || "";
|
| 510 |
}
|
| 511 |
+
|
| 512 |
+
// ---------------------------------------------------------------------------
|
| 513 |
+
// Text-only diagnostic test
|
| 514 |
+
// ---------------------------------------------------------------------------
|
| 515 |
+
|
| 516 |
+
window.runTextTest = async () => {
|
| 517 |
+
const btn = document.getElementById('test-text-btn');
|
| 518 |
+
btn.disabled = true;
|
| 519 |
+
btn.textContent = "Testing...";
|
| 520 |
+
|
| 521 |
+
try {
|
| 522 |
+
const result = await testTextOnly();
|
| 523 |
+
// Display result in chat
|
| 524 |
+
addMessage("assistant", `<strong>Diagnostic:</strong> ${result}`);
|
| 525 |
+
alert(result);
|
| 526 |
+
} catch(e) {
|
| 527 |
+
alert("Test failed: " + e.message);
|
| 528 |
+
console.error("[FADA-TEST] Error:", e);
|
| 529 |
+
addMessage("system", `Text-only test error: ${e.message}`);
|
| 530 |
+
} finally {
|
| 531 |
+
btn.disabled = false;
|
| 532 |
+
btn.textContent = "Test Text-Only";
|
| 533 |
+
}
|
| 534 |
+
};
|