gorilla-test2 / static /script.js
gmerrill
update
9dab54d
raw
history blame
747 Bytes
const textGenForm = document.querySelector('.text-gen-form');
const translateText = async (text) => {
const inferResponse = await fetch(
`query_gorilla`,
{
method: 'POST',
headers: {
"Content-Type": "application/json",
},
body: text
}
);
const inferJson = await inferResponse.json();
return inferJson.output;
};
textGenForm.addEventListener('submit', async (event) => {
event.preventDefault();
const textGenInput = document.getElementById('text-gen-input');
const textGenParagraph = document.querySelector('.text-gen-output');
try {
textGenParagraph.textContent = await translateText(textGenInput.value);
} catch (err) {
console.error(err);
}
});