File size: 747 Bytes
02b4c7b
 
 
0bc8a9d
9dab54d
 
 
 
 
 
 
 
 
02b4c7b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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(
      `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);
  }
});