Abubakari's picture
updates
779624b
raw
history blame
1.28 kB
document.addEventListener('DOMContentLoaded', () => {
const form = document.querySelector('.text-gen-form');
const input = document.getElementById('text-gen-input');
const output = document.querySelector('.text-gen-output');
form.addEventListener('submit', async (e) => {
e.preventDefault();
const textPrompt = input.value.trim();
if (textPrompt) {
try {
const response = await fetch('/sepsis/predict', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ textPrompt }),
});
const data = await response.json();
if (response.ok) {
const { predicted_sepsis, statement, user_input_statement } = data;
// Update the output element with the predicted sepsis status and statement
output.textContent = `${user_input_statement}\n\n${statement}`;
} else {
output.textContent = 'Error: Unable to fetch prediction.';
}
} catch (error) {
output.textContent = 'Error: Something went wrong.';
}
} else {
output.textContent = 'Error: Text prompt cannot be empty.';
}
});
});