Spaces:
Runtime error
Runtime error
Update index.html
Browse files- index.html +14 -12
index.html
CHANGED
|
@@ -104,26 +104,28 @@
|
|
| 104 |
</section>
|
| 105 |
</div>
|
| 106 |
</main>
|
| 107 |
-
|
| 108 |
<script type="module">
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
|
|
|
| 117 |
env.useBrowserCache = true;
|
| 118 |
env.allowLocalModels = true;
|
| 119 |
env.localModelPath = new URL('assets/models/', window.location.href).href;
|
| 120 |
-
env.allowRemoteModels = false;
|
| 121 |
env.backends.onnx.webgpu = { enabled: false };
|
| 122 |
env.backends.onnx.preferredBackend = 'wasm';
|
| 123 |
env.backends.onnx.wasm.numThreads = 1;
|
| 124 |
env.backends.onnx.wasm.proxy = false;
|
| 125 |
-
if (typeof env.backends.onnx.wasm.jsep !== 'undefined')
|
| 126 |
-
|
|
|
|
|
|
|
| 127 |
|
| 128 |
// --- DOM helpers / UI state ---
|
| 129 |
const $ = (s) => document.querySelector(s);
|
|
|
|
| 104 |
</section>
|
| 105 |
</div>
|
| 106 |
</main>
|
|
|
|
| 107 |
<script type="module">
|
| 108 |
+
// Import the Hugging Face Transformers.js module
|
| 109 |
+
const {
|
| 110 |
+
pipeline,
|
| 111 |
+
env,
|
| 112 |
+
AutoTokenizer,
|
| 113 |
+
AutoModelForCausalLM,
|
| 114 |
+
} = await import('https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.3');
|
| 115 |
+
|
| 116 |
+
// --- Backend config (no cross‑origin isolation) ---
|
| 117 |
env.useBrowserCache = true;
|
| 118 |
env.allowLocalModels = true;
|
| 119 |
env.localModelPath = new URL('assets/models/', window.location.href).href;
|
| 120 |
+
env.allowRemoteModels = false;
|
| 121 |
env.backends.onnx.webgpu = { enabled: false };
|
| 122 |
env.backends.onnx.preferredBackend = 'wasm';
|
| 123 |
env.backends.onnx.wasm.numThreads = 1;
|
| 124 |
env.backends.onnx.wasm.proxy = false;
|
| 125 |
+
if (typeof env.backends.onnx.wasm.jsep !== 'undefined') {
|
| 126 |
+
env.backends.onnx.wasm.jsep = false;
|
| 127 |
+
}
|
| 128 |
+
env.backends.onnx.wasm.wasmPaths = 'https://cdn.jsdelivr.net/npm/onnxruntime-web@1.17.1/dist/';
|
| 129 |
|
| 130 |
// --- DOM helpers / UI state ---
|
| 131 |
const $ = (s) => document.querySelector(s);
|