File size: 2,738 Bytes
aa5568f
 
 
 
 
947004f
aa5568f
 
947004f
aa5568f
 
 
a5e5b39
b206969
aa5568f
 
 
 
 
cf64483
967483e
4061877
 
 
0624a6e
 
 
4061877
967483e
 
 
 
 
 
718a619
967483e
 
cf64483
 
 
 
 
9bef67f
bffff4f
cf64483
 
 
 
 
967483e
 
2597bec
3f57d24
149d146
967483e
 
 
 
cf64483
967483e
 
 
 
415f6bf
cf64483
967483e
 
76dced8
 
947004f
 
aa5568f
 
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width" />
		<title>T5-base Language Translator</title>
		<link rel="stylesheet" href="style.css" />
	</head>

	<body>
		<div class="card">
			<h1>Welcome to your static Space!</h1>
			<h2 style="color: blue;">huggingface.js ํ…Œ์ŠคํŠธ ํŽ˜์ด์ง€</h2>
            <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
			<p>
				Also don't forget to check the
				<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
			</p>
		</div>
        <br/><br/><br/>
        <form id="hf-form">
            <!-- Hidden username field for accessibility -->
            <input
                type="text"
                style="display:none"  
                autocomplete="username"  
                value="user" 
            />
            <div>
                <label for="hf-token">Hugging Face Token (optional but limited if absent)</label>
                <input
                    id="hf-token"
                    placeholder="HF-TOKEN"
                    type="password"
                    autocomplete="new-password"
                />
            </div>

            <div>
                <label for="text-to-translate">Text to Translate</label>
                <input
                    id="text-to-translate"
                    value="translate_ko2en: IBM ์™“์ŠจX๋Š” AI ๋ฐ ๋ฐ์ดํ„ฐ ํ”Œ๋žซํผ์ด๋‹ค. ํŒŒ์šด๋ฐ์ด์…˜ ๋ชจ๋ธ์— ๋Œ€ํ•œ ๊ธฐ์ˆ ๊ณผ ์„œ๋น„์Šค๋ฅผ ์ œ๊ณตํ•œ๋‹ค"
                    placeholder="Enter some text here"
                    type="text"
                    autocomplete="off"
                />
            </div>
          
            <input type="submit" value="Translate"/>
        </form>
      
      <script type="module">
          import { HfInference } from 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/+esm';

          document.getElementById('hf-form').addEventListener('submit', async (event) => {
              event.preventDefault();
              const token = document.getElementById('hf-token').value;
              const textToTranslate = document.getElementById('text-to-translate').value;
              const hf = new HfInference(token);

              // You can also omit "model" to use the recommended model for the task
              const result = await hf.translation({
                  model: 'KETI-AIR-Downstream/long-ke-t5-base-translation-aihub-bidirection',
                  inputs: textToTranslate,
              });
              console.log(result);
              console.log(hf);
              console.log("TOEKN: ", token)
          });
      </script>
	</body>
</html>