boazchung commited on
Commit
967483e
1 Parent(s): 2597bec

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +24 -20
index.html CHANGED
@@ -18,30 +18,34 @@
18
  </p>
19
  </div>
20
 
21
- <div>
22
- <label for="hf-token"
23
- >Hugging Face Token (optional but limited if absent)</label
24
- >
25
- <input
26
- id="hf-token"
27
- v-model="token"
28
- placeholder="HF-TOKEN"
29
- type="password"
30
- />
31
- </div>
32
 
33
  <script type="module">
34
  import { HfInference } from 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/+esm';
35
- const token = document.getElementById('hf-token').value;
36
- console.log(token);
37
- const hf = new HfInference(token);
38
-
39
- // You can also omit "model" to use the recommended model for the task
40
- const result = await hf.translation({
41
-     model: 't5-base',
42
-     inputs: 'My name is Wolfgang and I live in Amsterdam',
 
 
 
 
 
43
  });
44
- console.log(result);
45
  </script>
46
  </body>
47
  </html>
 
18
  </p>
19
  </div>
20
 
21
+ <form id="hf-form">
22
+ <div>
23
+ <label for="hf-token">Hugging Face Token (optional but limited if absent)</label>
24
+ <input
25
+ id="hf-token"
26
+ placeholder="HF-TOKEN"
27
+ type="password"
28
+ />
29
+ </div>
30
+ <input type="submit" value="Translate"/>
31
+ </form>
32
 
33
  <script type="module">
34
  import { HfInference } from 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/+esm';
35
+
36
+ document.getElementById('hf-form').addEventListener('submit', async (event) => {
37
+ event.preventDefault();
38
+ const token = document.getElementById('hf-token').value;
39
+ console.log(token);
40
+ const hf = new HfInference(token);
41
+
42
+ // You can also omit "model" to use the recommended model for the task
43
+ const result = await hf.translation({
44
+ model: 't5-base',
45
+ inputs: 'My name is Wolfgang and I live in Amsterdam',
46
+ });
47
+ console.log(result);
48
  });
 
49
  </script>
50
  </body>
51
  </html>