Spaces:
Running
Running
Update index.html
Browse files- index.html +59 -19
index.html
CHANGED
|
@@ -1,19 +1,59 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="ja">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>LLM Token</title>
|
| 7 |
+
<style>
|
| 8 |
+
body { font-family: sans-serif; max-width: 800px; margin: 40px auto; padding: 0 20px; line-height: 1.6; background-color: #f9f9f9; }
|
| 9 |
+
textarea { width: 100%; height: 250px; padding: 15px; border: 2px solid #ddd; border-radius: 10px; font-size: 16px; box-sizing: border-box; }
|
| 10 |
+
textarea:focus { border-color: #007bff; outline: none; }
|
| 11 |
+
.stats { display: flex; gap: 30px; margin-top: 15px; background: white; padding: 15px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
|
| 12 |
+
.stat-item { display: flex; flex-direction: column; }
|
| 13 |
+
.label { font-size: 0.9em; color: #666; }
|
| 14 |
+
.value { font-size: 1.5em; font-weight: bold; color: #007bff; }
|
| 15 |
+
</style>
|
| 16 |
+
</head>
|
| 17 |
+
<body>
|
| 18 |
+
|
| 19 |
+
<h2>LLM トークンカウンター</h2>
|
| 20 |
+
|
| 21 |
+
<textarea id="inputText" placeholder="ここに文章を入力してください..."></textarea>
|
| 22 |
+
|
| 23 |
+
<div class="stats">
|
| 24 |
+
<div class="stat-item">
|
| 25 |
+
<span class="label">トークン数</span>
|
| 26 |
+
<span id="tokenCount" class="value">0</span>
|
| 27 |
+
</div>
|
| 28 |
+
<div class="stat-item">
|
| 29 |
+
<span class="label">文字数</span>
|
| 30 |
+
<span id="charCount" class="value">0</span>
|
| 31 |
+
</div>
|
| 32 |
+
</div>
|
| 33 |
+
|
| 34 |
+
<script type="module">
|
| 35 |
+
import { getEncoding } from "https://cdn.jsdelivr.net/npm/js-tiktoken@1.0.7/+esm";
|
| 36 |
+
|
| 37 |
+
const input = document.getElementById('inputText');
|
| 38 |
+
const tokenDisplay = document.getElementById('tokenCount');
|
| 39 |
+
const charDisplay = document.getElementById('charCount');
|
| 40 |
+
|
| 41 |
+
// エンコーダーの初期化
|
| 42 |
+
const enc = getEncoding("cl100k_base");
|
| 43 |
+
|
| 44 |
+
input.addEventListener('input', () => {
|
| 45 |
+
const text = input.value;
|
| 46 |
+
|
| 47 |
+
if (text) {
|
| 48 |
+
// トークン化して長さを計算
|
| 49 |
+
const tokens = enc.encode(text);
|
| 50 |
+
tokenDisplay.textContent = tokens.length.toLocaleString();
|
| 51 |
+
} else {
|
| 52 |
+
tokenDisplay.textContent = "0";
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
charDisplay.textContent = text.length.toLocaleString();
|
| 56 |
+
});
|
| 57 |
+
</script>
|
| 58 |
+
</body>
|
| 59 |
+
</html>
|