llama-chat-api / static /script.js
Pavel
style update
2519913
Raw History Blame Contribute Delete
1.37 kB
const textGenFormT5 = document.querySelector(".text-gen-form-t5");
const translateTextT5 = async (text) => {
const inferResponseT5 = await fetch(`infer_t5?input=${text}`);
const inferJson = await inferResponseT5.json();
return inferJson.output;
};
textGenFormT5.addEventListener("submit", async (event) => {
event.preventDefault();
const textGenInputT5 = document.getElementById("text-gen-input-t5");
const textGenParagraphT5 = document.querySelector(".text-gen-output-t5");
// textGenParagraphT5.textContent = await translateTextT5(textGenInputT5.value);
try {
textGenParagraphT5.textContent = await translateText(textGenInputT5.value);
} catch (err) {
console.error(err);
}
});
// const textGenFormLlama = document.querySelector(".text-gen-form-llama2");
// const translateTextLlama = async (text) => {
// const inferResponse = await fetch(`llama2_generate?input=${text}`);
// const inferJson = await inferResponse.json();
// return inferJson.output;
// };
// textGenFormLlama.addEventListener("submit", async (event) => {
// event.preventDefault();
// const textGenInputLlama2 = document.getElementById("text-gen-input-llama2");
// const textGenParagraphLlama2 = document.querySelector(".text-gen-output-llama2");
// textGenParagraphLlama2.textContent = await translateTextLlama(textGenInputLlama2.value);
// });