Team Ai
Datasetpublic

Brunobkr/llama.cpp_AlgMor24_github

ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes3.1kdownloads
index.js431 linesDownload Raw Back to dist
1"use strict";2Object.defineProperty(exports, "__esModule", { value: true });3exports.PathError = exports.TokenData = void 0;4exports.parse = parse;5exports.compile = compile;6exports.match = match;7exports.pathToRegexp = pathToRegexp;8exports.stringify = stringify;9const DEFAULT_DELIMITER = "/";10const NOOP_VALUE = (value) => value;11const ID_START = /^[$_\p{ID_Start}]$/u;12const ID_CONTINUE = /^[$\u200c\u200d\p{ID_Continue}]$/u;13const ID = /^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u;14/**15 * Escape text for stringify to path.16 */17function escapeText(str) {18    return str.replace(/[{}()\[\]+?!:*\\]/g, "\\$&");19}20/**21 * Escape a regular expression string.22 */23function escape(str) {24    return str.replace(/[.+*?^${}()[\]|/\\]/g, "\\$&");25}26/**27 * Tokenized path instance.28 */29class TokenData {30    constructor(tokens, originalPath) {31        this.tokens = tokens;32        this.originalPath = originalPath;33    }34}35exports.TokenData = TokenData;36/**37 * ParseError is thrown when there is an error processing the path.38 */39class PathError extends TypeError {40    constructor(message, originalPath) {41        let text = message;42        if (originalPath)43            text += `: ${originalPath}`;44        text += `; visit https://git.new/pathToRegexpError for info`;45        super(text);46        this.originalPath = originalPath;47    }48}49exports.PathError = PathError;50/**51 * Parse a string for the raw tokens.52 */53function parse(str, options = {}) {54    const { encodePath = NOOP_VALUE } = options;55    const chars = [...str];56    let index = 0;57    function consumeUntil(end) {58        const output = [];59        let path = "";60        function writePath() {61            if (!path)62                return;63            output.push({64                type: "text",65                value: encodePath(path),66            });67            path = "";68        }69        while (index < chars.length) {70            const value = chars[index++];71            if (value === end) {72                writePath();73                return output;74            }75            if (value === "\\") {76                if (index === chars.length) {77                    throw new PathError(`Unexpected end after \\ at index ${index}`, str);78                }79                path += chars[index++];80                continue;81            }82            if (value === ":" || value === "*") {83                const type = value === ":" ? "param" : "wildcard";84                let name = "";85                if (ID_START.test(chars[index])) {86                    do {87                        name += chars[index++];88                    } while (ID_CONTINUE.test(chars[index]));89                }90                else if (chars[index] === '"') {91                    let quoteStart = index;92                    while (index < chars.length) {93                        if (chars[++index] === '"') {94                            index++;95                            quoteStart = 0;96                            break;97                        }98                        // Increment over escape characters.99                        if (chars[index] === "\\")100                            index++;101                        name += chars[index];102                    }103                    if (quoteStart) {104                        throw new PathError(`Unterminated quote at index ${quoteStart}`, str);105                    }106                }107                if (!name) {108                    throw new PathError(`Missing parameter name at index ${index}`, str);109                }110                writePath();111                output.push({ type, name });112                continue;113            }114            if (value === "{") {115                writePath();116                output.push({117                    type: "group",118                    tokens: consumeUntil("}"),119                });120                continue;121            }122            if (value === "}" ||123                value === "(" ||124                value === ")" ||125                value === "[" ||126                value === "]" ||127                value === "+" ||128                value === "?" ||129                value === "!") {130                throw new PathError(`Unexpected ${value} at index ${index - 1}`, str);131            }132            path += value;133        }134        if (end) {135            throw new PathError(`Unexpected end at index ${index}, expected ${end}`, str);136        }137        writePath();138        return output;139    }140    return new TokenData(consumeUntil(""), str);141}142/**143 * Compile a string to a template function for the path.144 */145function compile(path, options = {}) {146    const { encode = encodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;147    const data = typeof path === "object" ? path : parse(path, options);148    const fn = tokensToFunction(data.tokens, delimiter, encode);149    return function path(params = {}) {150        const missing = [];151        const path = fn(params, missing);152        if (missing.length) {153            throw new TypeError(`Missing parameters: ${missing.join(", ")}`);154        }155        return path;156    };157}158function tokensToFunction(tokens, delimiter, encode) {159    const encoders = tokens.map((token) => tokenToFunction(token, delimiter, encode));160    return (data, missing) => {161        let result = "";162        for (const encoder of encoders) {163            result += encoder(data, missing);164        }165        return result;166    };167}168/**169 * Convert a single token into a path building function.170 */171function tokenToFunction(token, delimiter, encode) {172    if (token.type === "text")173        return () => token.value;174    if (token.type === "group") {175        const fn = tokensToFunction(token.tokens, delimiter, encode);176        return (data, missing) => {177            const len = missing.length;178            const value = fn(data, missing);179            if (missing.length === len)180                return value;181            missing.length = len; // Reset optional group.182            return "";183        };184    }185    const encodeValue = encode || NOOP_VALUE;186    if (token.type === "wildcard" && encode !== false) {187        return (data, missing) => {188            const value = data[token.name];189            if (value == null) {190                missing.push(token.name);191                return "";192            }193            if (!Array.isArray(value) || value.length === 0) {194                throw new TypeError(`Expected "${token.name}" to be a non-empty array`);195            }196            let result = "";197            for (let i = 0; i < value.length; i++) {198                if (typeof value[i] !== "string") {199                    throw new TypeError(`Expected "${token.name}/${i}" to be a string`);200                }201                if (i > 0)202                    result += delimiter;203                result += encodeValue(value[i]);204            }205            return result;206        };207    }208    return (data, missing) => {209        const value = data[token.name];210        if (value == null) {211            missing.push(token.name);212            return "";213        }214        if (typeof value !== "string") {215            throw new TypeError(`Expected "${token.name}" to be a string`);216        }217        return encodeValue(value);218    };219}220/**221 * Transform a path into a match function.222 */223function match(path, options = {}) {224    const { decode = decodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;225    const { regexp, keys } = pathToRegexp(path, options);226    const decoders = keys.map((key) => {227        if (decode === false)228            return NOOP_VALUE;229        if (key.type === "param")230            return decode;231        return (value) => value.split(delimiter).map(decode);232    });233    return function match(input) {234        const m = regexp.exec(input);235        if (!m)236            return false;237        const path = m[0];238        const params = Object.create(null);239        for (let i = 1; i < m.length; i++) {240            if (m[i] === undefined)241                continue;242            const key = keys[i - 1];243            const decoder = decoders[i - 1];244            params[key.name] = decoder(m[i]);245        }246        return { path, params };247    };248}249/**250 * Transform a path into a regular expression and capture keys.251 */252function pathToRegexp(path, options = {}) {253    const { delimiter = DEFAULT_DELIMITER, end = true, sensitive = false, trailing = true, } = options;254    const keys = [];255    let source = "";256    let combinations = 0;257    function process(path) {258        if (Array.isArray(path)) {259            for (const p of path)260                process(p);261            return;262        }263        const data = typeof path === "object" ? path : parse(path, options);264        flatten(data.tokens, 0, [], (tokens) => {265            if (combinations >= 256) {266                throw new PathError("Too many path combinations", data.originalPath);267            }268            if (combinations > 0)269                source += "|";270            source += toRegExpSource(tokens, delimiter, keys, data.originalPath);271            combinations++;272        });273    }274    process(path);275    let pattern = `^(?:${source})`;276    if (trailing)277        pattern += "(?:" + escape(delimiter) + "$)?";278    pattern += end ? "$" : "(?=" + escape(delimiter) + "|$)";279    return { regexp: new RegExp(pattern, sensitive ? "" : "i"), keys };280}281/**282 * Generate a flat list of sequence tokens from the given tokens.283 */284function flatten(tokens, index, result, callback) {285    while (index < tokens.length) {286        const token = tokens[index++];287        if (token.type === "group") {288            const len = result.length;289            flatten(token.tokens, 0, result, (seq) => flatten(tokens, index, seq, callback));290            result.length = len;291            continue;292        }293        result.push(token);294    }295    callback(result);296}297/**298 * Transform a flat sequence of tokens into a regular expression.299 */300function toRegExpSource(tokens, delimiter, keys, originalPath) {301    let result = "";302    let backtrack = "";303    let wildcardBacktrack = "";304    let prevCaptureType = 0;305    let hasSegmentCapture = 0;306    let index = 0;307    function hasInSegment(index, type) {308        while (index < tokens.length) {309            const token = tokens[index++];310            if (token.type === type)311                return true;312            if (token.type === "text") {313                if (token.value.includes(delimiter))314                    break;315            }316        }317        return false;318    }319    function peekText(index) {320        let result = "";321        while (index < tokens.length) {322            const token = tokens[index++];323            if (token.type !== "text")324                break;325            result += token.value;326        }327        return result;328    }329    while (index < tokens.length) {330        const token = tokens[index++];331        if (token.type === "text") {332            result += escape(token.value);333            backtrack += token.value;334            if (prevCaptureType === 2)335                wildcardBacktrack += token.value;336            if (token.value.includes(delimiter))337                hasSegmentCapture = 0;338            continue;339        }340        if (token.type === "param" || token.type === "wildcard") {341            if (prevCaptureType && !backtrack) {342                throw new PathError(`Missing text before "${token.name}" ${token.type}`, originalPath);343            }344            if (token.type === "param") {345                result +=346                    hasSegmentCapture & 2 // Seen wildcard in segment.347                        ? `(${negate(delimiter, backtrack)}+)`348                        : hasInSegment(index, "wildcard") // See wildcard later in segment.349                            ? `(${negate(delimiter, peekText(index))}+)`350                            : hasSegmentCapture & 1 // Seen parameter in segment.351                                ? `(${negate(delimiter, backtrack)}+|${escape(backtrack)})`352                                : `(${negate(delimiter, "")}+)`;353                hasSegmentCapture |= prevCaptureType = 1;354            }355            else {356                result +=357                    hasSegmentCapture & 2 // Seen wildcard in segment.358                        ? `(${negate(backtrack, "")}+)`359                        : wildcardBacktrack // No capture in segment, seen wildcard in path.360                            ? `(${negate(wildcardBacktrack, "")}+|${negate(delimiter, "")}+)`361                            : `([^]+)`;362                wildcardBacktrack = "";363                hasSegmentCapture |= prevCaptureType = 2;364            }365            keys.push(token);366            backtrack = "";367            continue;368        }369        throw new TypeError(`Unknown token type: ${token.type}`);370    }371    return result;372}373/**374 * Block backtracking on previous text/delimiter.375 */376function negate(a, b) {377    if (b.length > a.length)378        return negate(b, a); // Longest string first.379    if (a === b)380        b = ""; // Cleaner regex strings, no duplication.381    if (b.length > 1)382        return `(?:(?!${escape(a)}|${escape(b)})[^])`;383    if (a.length > 1)384        return `(?:(?!${escape(a)})[^${escape(b)}])`;385    return `[^${escape(a + b)}]`;386}387/**388 * Stringify an array of tokens into a path string.389 */390function stringifyTokens(tokens, index) {391    let value = "";392    while (index < tokens.length) {393        const token = tokens[index++];394        if (token.type === "text") {395            value += escapeText(token.value);396            continue;397        }398        if (token.type === "group") {399            value += "{" + stringifyTokens(token.tokens, 0) + "}";400            continue;401        }402        if (token.type === "param") {403            value += ":" + stringifyName(token.name, tokens[index]);404            continue;405        }406        if (token.type === "wildcard") {407            value += "*" + stringifyName(token.name, tokens[index]);408            continue;409        }410        throw new TypeError(`Unknown token type: ${token.type}`);411    }412    return value;413}414/**415 * Stringify token data into a path string.416 */417function stringify(data) {418    return stringifyTokens(data.tokens, 0);419}420/**421 * Stringify a parameter name, escaping when it cannot be emitted directly.422 */423function stringifyName(name, next) {424    if (!ID.test(name))425        return JSON.stringify(name);426    if ((next === null || next === void 0 ? void 0 : next.type) === "text" && ID_CONTINUE.test(next.value[0])) {427        return JSON.stringify(name);428    }429    return name;430}431//# sourceMappingURL=index.js.map
Brunobkr/llama.cpp_AlgMor24_github · Team Ai