Spaces:
Runtime error
Runtime error
| async function runNER() { | |
| const text = document.getElementById("text").value; | |
| const mode = document.getElementById("mode").value; | |
| const status = document.getElementById("status"); | |
| const button = document.getElementById("extractBtn"); | |
| const output = document.getElementById("output"); | |
| // Show processing message | |
| status.textContent = "⏳ Extracting entities..."; | |
| status.style.color = "blue"; | |
| button.disabled = true; | |
| try { | |
| const response = await fetch("/predict", { | |
| method: "POST", | |
| headers: { | |
| "Content-Type": "application/json" | |
| }, | |
| body: JSON.stringify({ text, mode }) | |
| }); | |
| const data = await response.json(); | |
| output.textContent = JSON.stringify(data, null, 2); | |
| // Finished successfully | |
| status.textContent = "✅ Extraction completed."; | |
| status.style.color = "green"; | |
| } catch (error) { | |
| output.textContent = error; | |
| status.textContent = "❌ An error occurred during extraction."; | |
| status.style.color = "red"; | |
| } finally { | |
| button.disabled = false; | |
| } | |
| } |