Upload bundle.js
Browse files
bundle.js
CHANGED
|
@@ -6,13 +6,7 @@
|
|
| 6 |
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 7 |
var __getProtoOf = Object.getPrototypeOf;
|
| 8 |
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 9 |
-
var
|
| 10 |
-
get: (a4, b4) => (typeof require !== "undefined" ? require : a4)[b4]
|
| 11 |
-
}) : x3)(function(x3) {
|
| 12 |
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
| 13 |
-
throw Error('Dynamic require of "' + x3 + '" is not supported');
|
| 14 |
-
});
|
| 15 |
-
var __commonJS = (cb, mod) => function __require2() {
|
| 16 |
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
| 17 |
};
|
| 18 |
var __copyProps = (to, from, except, desc) => {
|
|
@@ -8798,21 +8792,6 @@ WebGPU throws: "${t8.message}"`);
|
|
| 8798 |
const parts = path.split("/");
|
| 8799 |
return parts[parts.length - 1];
|
| 8800 |
}
|
| 8801 |
-
async function getOauthToken() {
|
| 8802 |
-
let oauthToken = localStorage.getItem("oauth");
|
| 8803 |
-
if (oauthToken) {
|
| 8804 |
-
try {
|
| 8805 |
-
return JSON.parse(oauthToken);
|
| 8806 |
-
} catch {
|
| 8807 |
-
return null;
|
| 8808 |
-
}
|
| 8809 |
-
}
|
| 8810 |
-
const newOauthToken = await oauthHandleRedirectIfPresent();
|
| 8811 |
-
if (newOauthToken) {
|
| 8812 |
-
localStorage.setItem("oauth", JSON.stringify(newOauthToken));
|
| 8813 |
-
}
|
| 8814 |
-
return newOauthToken;
|
| 8815 |
-
}
|
| 8816 |
var writingToCachePromise = void 0;
|
| 8817 |
async function loadModelWithCache(modelPath, modelFile) {
|
| 8818 |
if (modelFile) {
|
|
@@ -8844,11 +8823,9 @@ WebGPU throws: "${t8.message}"`);
|
|
| 8844 |
console.error("Error accessing OPFS:", e8);
|
| 8845 |
}
|
| 8846 |
}
|
| 8847 |
-
const oauthToken = await getOauthToken();
|
| 8848 |
-
const headers = oauthToken ? { "Authorization": `Bearer ${oauthToken.accessToken}` } : void 0;
|
| 8849 |
let expectedSize = -1;
|
| 8850 |
try {
|
| 8851 |
-
const headResponse = await fetch(modelPath, { method: "HEAD"
|
| 8852 |
if (!headResponse.ok) {
|
| 8853 |
const hfError = `Ensure you have accepted the proper model license on your HuggingFace account for the selected model.`;
|
| 8854 |
const localError = `Ensure the model is hosted at ${modelPath}.`;
|
|
@@ -8863,10 +8840,8 @@ WebGPU throws: "${t8.message}"`);
|
|
| 8863 |
console.warn(e8);
|
| 8864 |
}
|
| 8865 |
console.log("Fetching model from network and caching to OPFS.");
|
| 8866 |
-
const response = await fetch(modelPath
|
| 8867 |
if (!response.ok || !response.body) {
|
| 8868 |
-
localStorage.removeItem("oauth");
|
| 8869 |
-
window.dispatchEvent(new CustomEvent("oauth-removed"));
|
| 8870 |
const hfError = `Ensure you have accepted the proper model license on your HuggingFace account for the selected model.`;
|
| 8871 |
const localError = `Ensure the model is hosted at ${modelPath}.`;
|
| 8872 |
const error = isHostedOnHuggingFace() ? hfError : localError;
|
|
@@ -9206,23 +9181,6 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9206 |
});
|
| 9207 |
}
|
| 9208 |
|
| 9209 |
-
// src/hf-hub.ts
|
| 9210 |
-
var hubModulePromise = isHostedOnHuggingFace() ? import("https://esm.sh/@huggingface/hub") : Promise.resolve(null);
|
| 9211 |
-
var oauthLoginUrl2 = async (...args) => {
|
| 9212 |
-
const hub = await hubModulePromise;
|
| 9213 |
-
if (!hub) {
|
| 9214 |
-
throw new Error("Hugging Face Hub module is not available.");
|
| 9215 |
-
}
|
| 9216 |
-
return hub.oauthLoginUrl(...args);
|
| 9217 |
-
};
|
| 9218 |
-
var oauthHandleRedirectIfPresent = async (...args) => {
|
| 9219 |
-
const hub = await hubModulePromise;
|
| 9220 |
-
if (!hub) {
|
| 9221 |
-
return null;
|
| 9222 |
-
}
|
| 9223 |
-
return hub.oauthHandleRedirectIfPresent(...args);
|
| 9224 |
-
};
|
| 9225 |
-
|
| 9226 |
// src/custom_dropdown.ts
|
| 9227 |
var CustomDropdown = class extends i4 {
|
| 9228 |
constructor() {
|
|
@@ -9339,20 +9297,13 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9339 |
super(...arguments);
|
| 9340 |
this.cachedModels = /* @__PURE__ */ new Map();
|
| 9341 |
this.options = structuredClone(DEFAULT_OPTIONS);
|
| 9342 |
-
this.isLoggedIn = !!localStorage.getItem("oauth");
|
| 9343 |
-
this.handleOauthRemoved = () => {
|
| 9344 |
-
this.isLoggedIn = false;
|
| 9345 |
-
};
|
| 9346 |
}
|
| 9347 |
async connectedCallback() {
|
| 9348 |
super.connectedCallback();
|
| 9349 |
this.cachedModels = await getCachedModelsInfo();
|
| 9350 |
-
this.isLoggedIn = !!await getOauthToken();
|
| 9351 |
-
window.addEventListener("oauth-removed", this.handleOauthRemoved);
|
| 9352 |
}
|
| 9353 |
disconnectedCallback() {
|
| 9354 |
super.disconnectedCallback();
|
| 9355 |
-
window.removeEventListener("oauth-removed", this.handleOauthRemoved);
|
| 9356 |
}
|
| 9357 |
dispatchOptionsChanged() {
|
| 9358 |
const event = new CustomEvent("options-changed", {
|
|
@@ -9410,12 +9361,6 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9410 |
});
|
| 9411 |
this.dispatchEvent(event);
|
| 9412 |
}
|
| 9413 |
-
async handleLogin() {
|
| 9414 |
-
localStorage.removeItem("oauth");
|
| 9415 |
-
window.location.href = await oauthLoginUrl2({
|
| 9416 |
-
scopes: ["read-repos"]
|
| 9417 |
-
}) + "&prompt=consent";
|
| 9418 |
-
}
|
| 9419 |
getFileName(path) {
|
| 9420 |
return path.split("/").pop();
|
| 9421 |
}
|
|
@@ -9460,9 +9405,8 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9460 |
(model) => {
|
| 9461 |
const path = getModelUrl(model);
|
| 9462 |
const cachedSize = this.cachedModels.get(this.getFileName(path));
|
| 9463 |
-
const isDisabled = isHostedOnHuggingFace() && !this.isLoggedIn && !cachedSize;
|
| 9464 |
return b2`
|
| 9465 |
-
<div class="dropdown-item" data-value=${path}
|
| 9466 |
<span>${model.name}</span>
|
| 9467 |
${cachedSize ? b2`
|
| 9468 |
<span class="cached-info">
|
|
@@ -9479,14 +9423,6 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9479 |
<span>Total cached: ${this.getTotalCacheSize()}GB</span>
|
| 9480 |
${this.cachedModels.size > 0 ? b2`<button class="clear-all-btn" title="Remove all from cache" @click=${this.handleRemoveAllCached}>Clear all</button>` : ""}
|
| 9481 |
</div>
|
| 9482 |
-
${!this.isLoggedIn && isHostedOnHuggingFace() ? b2`
|
| 9483 |
-
<img
|
| 9484 |
-
class="login-button"
|
| 9485 |
-
src="https://huggingface.co/datasets/huggingface/badges/resolve/main/sign-in-with-huggingface-xl-dark.svg"
|
| 9486 |
-
alt="Sign in with Hugging Face"
|
| 9487 |
-
@click=${this.handleLogin}
|
| 9488 |
-
/>
|
| 9489 |
-
` : ""}
|
| 9490 |
`}
|
| 9491 |
</div>
|
| 9492 |
<div>
|
|
@@ -9629,10 +9565,6 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9629 |
.clear-all-btn:hover {
|
| 9630 |
color: #c00;
|
| 9631 |
}
|
| 9632 |
-
.login-button {
|
| 9633 |
-
cursor: pointer;
|
| 9634 |
-
display: inline-block;
|
| 9635 |
-
}
|
| 9636 |
.cache-info {
|
| 9637 |
display: flex;
|
| 9638 |
justify-content: space-between;
|
|
@@ -9648,9 +9580,6 @@ WebGPU throws: "${t8.message}"`);
|
|
| 9648 |
__decorateClass([
|
| 9649 |
r5()
|
| 9650 |
], LlmOptions.prototype, "options", 2);
|
| 9651 |
-
__decorateClass([
|
| 9652 |
-
r5()
|
| 9653 |
-
], LlmOptions.prototype, "isLoggedIn", 2);
|
| 9654 |
LlmOptions = __decorateClass([
|
| 9655 |
t3("llm-options")
|
| 9656 |
], LlmOptions);
|
|
|
|
| 6 |
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 7 |
var __getProtoOf = Object.getPrototypeOf;
|
| 8 |
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 9 |
+
var __commonJS = (cb, mod) => function __require() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
| 11 |
};
|
| 12 |
var __copyProps = (to, from, except, desc) => {
|
|
|
|
| 8792 |
const parts = path.split("/");
|
| 8793 |
return parts[parts.length - 1];
|
| 8794 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8795 |
var writingToCachePromise = void 0;
|
| 8796 |
async function loadModelWithCache(modelPath, modelFile) {
|
| 8797 |
if (modelFile) {
|
|
|
|
| 8823 |
console.error("Error accessing OPFS:", e8);
|
| 8824 |
}
|
| 8825 |
}
|
|
|
|
|
|
|
| 8826 |
let expectedSize = -1;
|
| 8827 |
try {
|
| 8828 |
+
const headResponse = await fetch(modelPath, { method: "HEAD" });
|
| 8829 |
if (!headResponse.ok) {
|
| 8830 |
const hfError = `Ensure you have accepted the proper model license on your HuggingFace account for the selected model.`;
|
| 8831 |
const localError = `Ensure the model is hosted at ${modelPath}.`;
|
|
|
|
| 8840 |
console.warn(e8);
|
| 8841 |
}
|
| 8842 |
console.log("Fetching model from network and caching to OPFS.");
|
| 8843 |
+
const response = await fetch(modelPath);
|
| 8844 |
if (!response.ok || !response.body) {
|
|
|
|
|
|
|
| 8845 |
const hfError = `Ensure you have accepted the proper model license on your HuggingFace account for the selected model.`;
|
| 8846 |
const localError = `Ensure the model is hosted at ${modelPath}.`;
|
| 8847 |
const error = isHostedOnHuggingFace() ? hfError : localError;
|
|
|
|
| 9181 |
});
|
| 9182 |
}
|
| 9183 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9184 |
// src/custom_dropdown.ts
|
| 9185 |
var CustomDropdown = class extends i4 {
|
| 9186 |
constructor() {
|
|
|
|
| 9297 |
super(...arguments);
|
| 9298 |
this.cachedModels = /* @__PURE__ */ new Map();
|
| 9299 |
this.options = structuredClone(DEFAULT_OPTIONS);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9300 |
}
|
| 9301 |
async connectedCallback() {
|
| 9302 |
super.connectedCallback();
|
| 9303 |
this.cachedModels = await getCachedModelsInfo();
|
|
|
|
|
|
|
| 9304 |
}
|
| 9305 |
disconnectedCallback() {
|
| 9306 |
super.disconnectedCallback();
|
|
|
|
| 9307 |
}
|
| 9308 |
dispatchOptionsChanged() {
|
| 9309 |
const event = new CustomEvent("options-changed", {
|
|
|
|
| 9361 |
});
|
| 9362 |
this.dispatchEvent(event);
|
| 9363 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9364 |
getFileName(path) {
|
| 9365 |
return path.split("/").pop();
|
| 9366 |
}
|
|
|
|
| 9405 |
(model) => {
|
| 9406 |
const path = getModelUrl(model);
|
| 9407 |
const cachedSize = this.cachedModels.get(this.getFileName(path));
|
|
|
|
| 9408 |
return b2`
|
| 9409 |
+
<div class="dropdown-item" data-value=${path}>
|
| 9410 |
<span>${model.name}</span>
|
| 9411 |
${cachedSize ? b2`
|
| 9412 |
<span class="cached-info">
|
|
|
|
| 9423 |
<span>Total cached: ${this.getTotalCacheSize()}GB</span>
|
| 9424 |
${this.cachedModels.size > 0 ? b2`<button class="clear-all-btn" title="Remove all from cache" @click=${this.handleRemoveAllCached}>Clear all</button>` : ""}
|
| 9425 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9426 |
`}
|
| 9427 |
</div>
|
| 9428 |
<div>
|
|
|
|
| 9565 |
.clear-all-btn:hover {
|
| 9566 |
color: #c00;
|
| 9567 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9568 |
.cache-info {
|
| 9569 |
display: flex;
|
| 9570 |
justify-content: space-between;
|
|
|
|
| 9580 |
__decorateClass([
|
| 9581 |
r5()
|
| 9582 |
], LlmOptions.prototype, "options", 2);
|
|
|
|
|
|
|
|
|
|
| 9583 |
LlmOptions = __decorateClass([
|
| 9584 |
t3("llm-options")
|
| 9585 |
], LlmOptions);
|