First upload version 0.0.1

This commit is contained in:
Neyra
2026-02-05 15:27:49 +08:00
commit 8e9b7201ed
4182 changed files with 593136 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
import filenamify from "filenamify";
const binarySplitGgufPartsRegex = /\.gguf\.part(?<part>\d+)of(?<parts>\d+)$/;
export function resolveBinarySplitGgufPartUrls(ggufUrl) {
const parsedGgufUrl = new URL(ggufUrl);
const binaryPartsMatch = parsedGgufUrl.pathname.match(binarySplitGgufPartsRegex);
if (binaryPartsMatch != null) {
const partString = binaryPartsMatch.groups?.part;
const part = Number(partString);
const partsString = binaryPartsMatch.groups?.parts;
const parts = Number(partsString);
if (partString == null || !Number.isFinite(part) || partsString == null || !Number.isFinite(parts) || part > parts || part === 0 ||
parts === 0)
return ggufUrl;
const ggufIndex = parsedGgufUrl.pathname.indexOf(".gguf");
const pathnameWithoutPart = parsedGgufUrl.pathname.slice(0, ggufIndex + ".gguf".length);
const res = [];
for (let i = 1; i <= parts; i++) {
const url = new URL(parsedGgufUrl.href);
url.pathname = pathnameWithoutPart + `.part${String(i).padStart(partString.length, "0")}of${partsString}`;
res.push(url.href);
}
return res;
}
return ggufUrl;
}
export function getFilenameForBinarySplitGgufPartUrls(urls) {
if (urls.length === 0)
return undefined;
const firstParsedUrl = new URL(urls[0]);
if (binarySplitGgufPartsRegex.test(firstParsedUrl.pathname)) {
const ggufIndex = firstParsedUrl.pathname.toLowerCase().indexOf(".gguf");
const urlWithoutPart = firstParsedUrl.pathname.slice(0, ggufIndex + ".gguf".length);
const filename = decodeURIComponent(urlWithoutPart.split("/").pop());
return filenamify(filename);
}
return undefined;
}
//# sourceMappingURL=resolveBinarySplitGgufPartUrls.js.map