Spaces:
Running
Running
Update index.html
Browse files- index.html +24 -20
index.html
CHANGED
@@ -18,30 +18,34 @@
|
|
18 |
</p>
|
19 |
</div>
|
20 |
|
21 |
-
<
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
</
|
32 |
|
33 |
<script type="module">
|
34 |
import { HfInference } from 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/+esm';
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
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>
|