File size: 1,162 Bytes
5900da3 2538a63 5900da3 2538a63 5900da3 2538a63 5900da3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
const textGenForm = document.querySelector('.text-gen-form');
const translateText = async (text) => {
const inferResponse = await fetch(`infer_t5?input=${text}`);
const inferJson = await inferResponse.json();
return inferJson;
};
textGenForm.addEventListener('submit', async (event) => {
event.preventDefault();
const textGenInput = document.getElementById('text-gen-input');
const textGenParagraph = document.querySelector('.text-gen-output');
const textGenParagraph_2 = document.querySelector('.text-gen-output_2');
const textGenParagraph_3 = document.querySelector('.text-gen-output_3');
const textGenParagraph_4 = document.querySelector('.text-gen-output_4');
const textGenParagraph_5 = document.querySelector('.text-gen-output_5');
try {
var text_out = await translateText(textGenInput.value);
textGenParagraph.textContent = text_out.size_str;
textGenParagraph_2.textContent = text_out.size_4;
textGenParagraph_3.textContent = text_out.cancer;
textGenParagraph_4.textContent = text_out.transfer;
textGenParagraph_5.textContent = text_out.ly_transfer;
} catch (err) {
console.error(err);
}
}); |