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.
03.1k
1//#region rolldown:runtime2var __create = Object.create;3var __defProp = Object.defineProperty;4var __getOwnPropDesc = Object.getOwnPropertyDescriptor;5var __getOwnPropNames = Object.getOwnPropertyNames;6var __getProtoOf = Object.getPrototypeOf;7var __hasOwnProp = Object.prototype.hasOwnProperty;8var __copyProps = (to, from, except, desc) => {9 if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {10 key = keys[i];11 if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {12 get: ((k) => from[k]).bind(null, key),13 enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable14 });15 }16 return to;17};18var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {19 value: mod,20 enumerable: true21}) : target, mod));22 23//#endregion24let node_fs = require("node:fs");25node_fs = __toESM(node_fs);26let node_path = require("node:path");27node_path = __toESM(node_path);28 29//#region src/err.ts30var EtaError = class extends Error {31 constructor(message) {32 super(message);33 this.name = "Eta Error";34 }35};36var EtaParseError = class extends EtaError {37 constructor(message) {38 super(message);39 this.name = "EtaParser Error";40 }41};42var EtaRuntimeError = class extends EtaError {43 constructor(message) {44 super(message);45 this.name = "EtaRuntime Error";46 }47};48var EtaFileResolutionError = class extends EtaError {49 constructor(message) {50 super(message);51 this.name = "EtaFileResolution Error";52 }53};54var EtaNameResolutionError = class extends EtaError {55 constructor(message) {56 super(message);57 this.name = "EtaNameResolution Error";58 }59};60/**61* Throws an EtaError with a nicely formatted error and message showing where in the template the error occurred.62*/63function ParseErr(message, str, indx) {64 const whitespace = str.slice(0, indx).split(/\n/);65 const lineNo = whitespace.length;66 const colNo = whitespace[lineNo - 1].length + 1;67 message += " at line " + lineNo + " col " + colNo + ":\n\n " + str.split(/\n/)[lineNo - 1] + "\n " + Array(colNo).join(" ") + "^";68 throw new EtaParseError(message);69}70function RuntimeErr(originalError, str, lineNo, path) {71 const lines = str.split("\n");72 const start = Math.max(lineNo - 3, 0);73 const end = Math.min(lines.length, lineNo + 3);74 const filename = path;75 const context = lines.slice(start, end).map((line, i) => {76 const curr = i + start + 1;77 return (curr === lineNo ? " >> " : " ") + curr + "| " + line;78 }).join("\n");79 const err = new EtaRuntimeError((filename ? filename + ":" + lineNo + "\n" : "line " + lineNo + "\n") + context + "\n\n" + originalError.message);80 err.name = originalError.name;81 err.cause = originalError;82 throw err;83}84 85//#endregion86//#region src/file-handling.ts87function readFile(path) {88 let res = "";89 try {90 res = node_fs.readFileSync(path, "utf8");91 } catch (err) {92 if (err?.code === "ENOENT") throw new EtaFileResolutionError(`Could not find template: ${path}`);93 else throw err;94 }95 return res;96}97function resolvePath(templatePath, options) {98 let resolvedFilePath = "";99 const views = this.config.views;100 if (!views) throw new EtaFileResolutionError("Views directory is not defined");101 const baseFilePath = options?.filepath;102 const defaultExtension = this.config.defaultExtension === void 0 ? ".eta" : this.config.defaultExtension;103 const cacheIndex = JSON.stringify({104 filename: baseFilePath,105 path: templatePath,106 views: this.config.views107 });108 templatePath += node_path.extname(templatePath) ? "" : defaultExtension;109 if (baseFilePath) {110 if (this.config.cacheFilepaths && this.filepathCache[cacheIndex]) return this.filepathCache[cacheIndex];111 if (absolutePathRegExp.exec(templatePath)?.length) {112 const formattedPath = templatePath.replace(/^\/*|^\\*/, "");113 resolvedFilePath = node_path.join(views, formattedPath);114 } else resolvedFilePath = node_path.join(node_path.dirname(baseFilePath), templatePath);115 } else resolvedFilePath = node_path.join(views, templatePath);116 if (dirIsChild(views, resolvedFilePath)) {117 if (baseFilePath && this.config.cacheFilepaths) this.filepathCache[cacheIndex] = resolvedFilePath;118 return resolvedFilePath;119 } else throw new EtaFileResolutionError(`Template '${templatePath}' is not in the views directory`);120}121function dirIsChild(parent, dir) {122 const relative = node_path.relative(parent, dir);123 return relative && !relative.startsWith("..") && !node_path.isAbsolute(relative);124}125const absolutePathRegExp = /^\\|^\//;126 127//#endregion128//#region src/compile.ts129/* istanbul ignore next */130const AsyncFunction = (async () => {}).constructor;131/**132* Takes a template string and returns a template function that can be called with (data, config)133*134* @param str - The template string135* @param config - A custom configuration object (optional)136*/137function compile(str, options) {138 const config = this.config;139 const ctor = options?.async ? AsyncFunction : Function;140 try {141 return new ctor(config.varName, "options", this.compileToString.call(this, str, options));142 } catch (e) {143 if (e instanceof SyntaxError) throw new EtaParseError("Bad template syntax\n\n" + e.message + "\n" + Array(e.message.length + 1).join("=") + "\n" + this.compileToString.call(this, str, options) + "\n");144 else throw e;145 }146}147 148//#endregion149//#region src/compile-string.ts150/**151* Compiles a template string to a function string. Most often users just use `compile()`, which calls `compileToString` and creates a new function using the result152*/153function compileToString(str, options) {154 const config = this.config;155 const isAsync = options?.async;156 const compileBody$1 = this.compileBody;157 const buffer = this.parse.call(this, str);158 let res = `${config.functionHeader}159let include = (__eta_t, __eta_d) => this.render(__eta_t, {...${config.varName}, ...(__eta_d ?? {})}, options);160let includeAsync = (__eta_t, __eta_d) => this.renderAsync(__eta_t, {...${config.varName}, ...(__eta_d ?? {})}, options);161 162let __eta = {res: "", e: this.config.escapeFunction, f: this.config.filterFunction, blocks: {}${config.debug ? ", line: 1, templateStr: \"" + str.replace(/\\|"/g, "\\$&").replace(/\r\n|\n|\r/g, "\\n") + "\"" : ""}};163 164function layout(path, data) {165 __eta.layout = path;166 __eta.layoutData = data;167}${config.debug ? "try {" : ""}${config.useWith ? "with(" + config.varName + "||{}){" : ""}168 169function ${config.outputFunctionName}(s){__eta.res+=s;}170function capture(fn){const s=__eta.res;__eta.res='';try{fn();return __eta.res}finally{__eta.res=s;}}171async function captureAsync(fn){const s=__eta.res;__eta.res='';try{await fn();return __eta.res}finally{__eta.res=s;}}172function block(name,fn){if(__eta.layout){if(fn){__eta.blocks[name]=capture(fn);}return '';}const b=${config.varName}.__blocks||{};if(name in b){return b[name];}return fn?capture(fn):'';}173async function blockAsync(name,fn){if(__eta.layout){if(fn){__eta.blocks[name]=await captureAsync(fn);}return '';}const b=${config.varName}.__blocks||{};if(name in b){return b[name];}return fn?await captureAsync(fn):'';}174 175${compileBody$1.call(this, buffer)}176if (__eta.layout) {177 __eta.res = ${isAsync ? "await includeAsync" : "include"} (__eta.layout, {...${config.varName}, body: __eta.res, ...__eta.layoutData, __blocks: __eta.blocks});178}179${config.useWith ? "}" : ""}${config.debug ? "} catch (e) { this.RuntimeErr(e, __eta.templateStr, __eta.line, options.filepath) }" : ""}180return __eta.res;181`;182 if (config.plugins) for (let i = 0; i < config.plugins.length; i++) {183 const plugin = config.plugins[i];184 if (plugin.processFnString) res = plugin.processFnString(res, config);185 }186 return res;187}188/**189* Loops through the AST generated by `parse` and transform each item into JS calls190*191* **Example**192*193* ```js194* let templateAST = ['Hi ', { val: 'it.name', t: 'i' }]195* compileBody.call(Eta, templateAST)196* // => "__eta.res+='Hi '\n__eta.res+=__eta.e(it.name)\n"197* ```198*/199function compileBody(buff) {200 const config = this.config;201 let i = 0;202 const buffLength = buff.length;203 let returnStr = "";204 for (; i < buffLength; i++) {205 const currentBlock = buff[i];206 if (typeof currentBlock === "string") returnStr += "__eta.res+='" + currentBlock + "';\n";207 else {208 const type = currentBlock.t;209 let content = currentBlock.val || "";210 if (config.debug) returnStr += "__eta.line=" + currentBlock.lineNo + "\n";211 if (type === "r") {212 if (config.autoFilter) content = "__eta.f(" + content + ")";213 returnStr += "__eta.res+=" + content + ";\n";214 } else if (type === "i") {215 if (config.autoFilter) content = "__eta.f(" + content + ")";216 if (config.autoEscape) content = "__eta.e(" + content + ")";217 returnStr += "__eta.res+=" + content + ";\n";218 } else if (type === "e") returnStr += content + "\n";219 else if (Object.hasOwn(config.customTags, type)) returnStr += `__eta.res+=this.config.customTags[${JSON.stringify(type)}](${JSON.stringify(content)},${config.varName});\n`;220 }221 }222 return returnStr;223}224 225//#endregion226//#region src/utils.ts227/**228* Takes a string within a template and trims it, based on the preceding tag's whitespace control and `config.autoTrim`229*/230function trimWS(str, config, wsLeft, wsRight) {231 let leftTrim;232 let rightTrim;233 if (Array.isArray(config.autoTrim)) {234 leftTrim = config.autoTrim[1];235 rightTrim = config.autoTrim[0];236 } else leftTrim = rightTrim = config.autoTrim;237 if (wsLeft || wsLeft === false) leftTrim = wsLeft;238 if (wsRight || wsRight === false) rightTrim = wsRight;239 if (!rightTrim && !leftTrim) return str;240 if (leftTrim === "slurp" && rightTrim === "slurp") return str.trim();241 if (leftTrim === "_" || leftTrim === "slurp") str = str.trimStart();242 else if (leftTrim === "-" || leftTrim === "nl") str = str.replace(/^(?:\r\n|\n|\r)/, "");243 if (rightTrim === "_" || rightTrim === "slurp") str = str.trimEnd();244 else if (rightTrim === "-" || rightTrim === "nl") str = str.replace(/(?:\r\n|\n|\r)$/, "");245 return str;246}247/**248* A map of special HTML characters to their XML-escaped equivalents249*/250const escMap = {251 "&": "&",252 "<": "<",253 ">": ">",254 "\"": """,255 "'": "'"256};257function replaceChar(s) {258 return escMap[s];259}260/**261* XML-escapes an input value after converting it to a string262*263* @param str - Input value (usually a string)264* @returns XML-escaped string265*/266function XMLEscape(str) {267 const newStr = String(str);268 if (/[&<>"']/.test(newStr)) return newStr.replace(/[&<>"']/g, replaceChar);269 else return newStr;270}271 272//#endregion273//#region src/config.ts274/** Eta's base (global) configuration */275const defaultConfig = {276 autoEscape: true,277 autoFilter: false,278 autoTrim: [false, "nl"],279 cache: false,280 cacheFilepaths: true,281 customTags: {},282 debug: false,283 escapeFunction: XMLEscape,284 filterFunction: (val) => String(val),285 outputFunctionName: "output",286 functionHeader: "",287 parse: {288 exec: "",289 interpolate: "=",290 raw: "~"291 },292 plugins: [],293 rmWhitespace: false,294 tags: ["<%", "%>"],295 useWith: false,296 varName: "it",297 defaultExtension: ".eta"298};299 300//#endregion301//#region src/parse.ts302const templateLitReg = /`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g;303const singleQuoteReg = /'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g;304const doubleQuoteReg = /"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g;305/** Escape special regular expression characters inside a string */306function escapeRegExp(string) {307 return string.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&");308}309function getLineNo(str, index) {310 return str.slice(0, index).split("\n").length;311}312function parse(str) {313 const config = this.config;314 let buffer = [];315 let trimLeftOfNextStr = false;316 let lastIndex = 0;317 const parseOptions = config.parse;318 const customTagPrefixes = Object.keys(config.customTags);319 if (config.plugins) for (let i = 0; i < config.plugins.length; i++) {320 const plugin = config.plugins[i];321 if (plugin.processTemplate) str = plugin.processTemplate(str, config);322 }323 if (config.rmWhitespace) str = str.replace(/[\r\n]+/g, "\n").replace(/^\s+|\s+$/gm, "");324 templateLitReg.lastIndex = 0;325 singleQuoteReg.lastIndex = 0;326 doubleQuoteReg.lastIndex = 0;327 function pushString(strng, shouldTrimRightOfString) {328 if (strng) {329 strng = trimWS(strng, config, trimLeftOfNextStr, shouldTrimRightOfString);330 if (strng) {331 strng = strng.replace(/\\|'/g, "\\$&").replace(/\r\n|\n|\r/g, "\\n");332 buffer.push(strng);333 }334 }335 }336 const prefixes = [337 parseOptions.exec,338 parseOptions.interpolate,339 parseOptions.raw,340 ...customTagPrefixes341 ].reduce((accumulator, prefix) => {342 if (accumulator && prefix) return accumulator + "|" + escapeRegExp(prefix);343 else if (prefix) return escapeRegExp(prefix);344 else return accumulator;345 }, "");346 const parseOpenReg = new RegExp(escapeRegExp(config.tags[0]) + "(-|_)?\\s*(" + prefixes + ")?\\s*", "g");347 const parseCloseReg = new RegExp("'|\"|`|\\/\\*|(\\s*(-|_)?" + escapeRegExp(config.tags[1]) + ")", "g");348 let m;349 while (m = parseOpenReg.exec(str)) {350 const precedingString = str.slice(lastIndex, m.index);351 lastIndex = m[0].length + m.index;352 const wsLeft = m[1];353 const prefix = m[2] || "";354 pushString(precedingString, wsLeft);355 parseCloseReg.lastIndex = lastIndex;356 let closeTag;357 let currentObj = false;358 while (closeTag = parseCloseReg.exec(str)) if (closeTag[1]) {359 const content = str.slice(lastIndex, closeTag.index);360 parseOpenReg.lastIndex = lastIndex = parseCloseReg.lastIndex;361 trimLeftOfNextStr = closeTag[2];362 currentObj = {363 t: prefix === parseOptions.exec ? "e" : prefix === parseOptions.raw ? "r" : prefix === parseOptions.interpolate ? "i" : customTagPrefixes.includes(prefix) ? prefix : "",364 val: content365 };366 break;367 } else {368 const char = closeTag[0];369 if (char === "/*") {370 const commentCloseInd = str.indexOf("*/", parseCloseReg.lastIndex);371 if (commentCloseInd === -1) ParseErr("unclosed comment", str, closeTag.index);372 parseCloseReg.lastIndex = commentCloseInd;373 } else if (char === "'") {374 singleQuoteReg.lastIndex = closeTag.index;375 if (singleQuoteReg.exec(str)) parseCloseReg.lastIndex = singleQuoteReg.lastIndex;376 else ParseErr("unclosed string", str, closeTag.index);377 } else if (char === "\"") {378 doubleQuoteReg.lastIndex = closeTag.index;379 if (doubleQuoteReg.exec(str)) parseCloseReg.lastIndex = doubleQuoteReg.lastIndex;380 else ParseErr("unclosed string", str, closeTag.index);381 } else if (char === "`") {382 templateLitReg.lastIndex = closeTag.index;383 if (templateLitReg.exec(str)) parseCloseReg.lastIndex = templateLitReg.lastIndex;384 else ParseErr("unclosed string", str, closeTag.index);385 }386 }387 if (currentObj) {388 if (config.debug) currentObj.lineNo = getLineNo(str, m.index);389 buffer.push(currentObj);390 } else ParseErr("unclosed tag", str, m.index);391 }392 pushString(str.slice(lastIndex, str.length), false);393 if (config.plugins) for (let i = 0; i < config.plugins.length; i++) {394 const plugin = config.plugins[i];395 if (plugin.processAST) buffer = plugin.processAST(buffer, config);396 }397 return buffer;398}399 400//#endregion401//#region src/render.ts402function handleCache(template, options) {403 const templateStore = options?.async ? this.templatesAsync : this.templatesSync;404 if (this.resolvePath && this.readFile && !template.startsWith("@")) {405 const templatePath = options.filepath;406 const cachedTemplate = templateStore.get(templatePath);407 if (this.config.cache && cachedTemplate) return cachedTemplate;408 else {409 const templateString = this.readFile(templatePath);410 const templateFn = this.compile(templateString, options);411 if (this.config.cache) templateStore.define(templatePath, templateFn);412 return templateFn;413 }414 } else {415 const cachedTemplate = templateStore.get(template);416 if (cachedTemplate) return cachedTemplate;417 else throw new EtaNameResolutionError(`Failed to get template '${template}'`);418 }419}420function render(template, data, meta) {421 let templateFn;422 const options = {423 ...meta,424 async: false425 };426 if (typeof template === "string") {427 if (this.resolvePath && this.readFile && !template.startsWith("@")) options.filepath = this.resolvePath(template, options);428 templateFn = handleCache.call(this, template, options);429 } else templateFn = template;430 return templateFn.call(this, data, options);431}432function renderAsync(template, data, meta) {433 let templateFn;434 const options = {435 ...meta,436 async: true437 };438 if (typeof template === "string") {439 if (this.resolvePath && this.readFile && !template.startsWith("@")) options.filepath = this.resolvePath(template, options);440 templateFn = handleCache.call(this, template, options);441 } else templateFn = template;442 const res = templateFn.call(this, data, options);443 return Promise.resolve(res);444}445function renderString(template, data) {446 const templateFn = this.compile(template, { async: false });447 return render.call(this, templateFn, data);448}449function renderStringAsync(template, data) {450 const templateFn = this.compile(template, { async: true });451 return renderAsync.call(this, templateFn, data);452}453 454//#endregion455//#region src/storage.ts456/**457* Handles storage and accessing of values458*459* In this case, we use it to store compiled template functions460* Indexed by their `name` or `filename`461*/462var Cacher = class {463 constructor(cache) {464 this.cache = cache;465 }466 define(key, val) {467 this.cache[key] = val;468 }469 get(key) {470 return this.cache[key];471 }472 remove(key) {473 delete this.cache[key];474 }475 reset() {476 this.cache = {};477 }478 load(cacheObj) {479 this.cache = {480 ...this.cache,481 ...cacheObj482 };483 }484};485 486//#endregion487//#region src/internal.ts488var Eta$1 = class {489 constructor(customConfig) {490 if (customConfig) this.config = {491 ...defaultConfig,492 ...customConfig493 };494 else this.config = { ...defaultConfig };495 const reserved = [496 this.config.parse.exec,497 this.config.parse.interpolate,498 this.config.parse.raw,499 "-",500 "_"501 ];502 for (const prefix of Object.keys(this.config.customTags)) if (reserved.includes(prefix)) throw new EtaError(`Custom tag prefix "${prefix}" conflicts with a built-in prefix`);503 }504 config;505 RuntimeErr = RuntimeErr;506 compile = compile;507 compileToString = compileToString;508 compileBody = compileBody;509 parse = parse;510 render = render;511 renderAsync = renderAsync;512 renderString = renderString;513 renderStringAsync = renderStringAsync;514 filepathCache = {};515 templatesSync = new Cacher({});516 templatesAsync = new Cacher({});517 resolvePath = null;518 readFile = null;519 configure(customConfig) {520 this.config = {521 ...this.config,522 ...customConfig523 };524 }525 withConfig(customConfig) {526 return {527 ...this,528 config: {529 ...this.config,530 ...customConfig531 }532 };533 }534 loadTemplate(name, template, options) {535 if (typeof template === "string") (options?.async ? this.templatesAsync : this.templatesSync).define(name, this.compile(template, options));536 else {537 let templates = this.templatesSync;538 if (template.constructor.name === "AsyncFunction" || options?.async) templates = this.templatesAsync;539 templates.define(name, template);540 }541 }542};543 544//#endregion545//#region src/index.ts546var Eta = class extends Eta$1 {547 readFile = readFile;548 resolvePath = resolvePath;549};550 551//#endregion552exports.Eta = Eta;553exports.EtaError = EtaError;554exports.EtaFileResolutionError = EtaFileResolutionError;555exports.EtaNameResolutionError = EtaNameResolutionError;556exports.EtaParseError = EtaParseError;557exports.EtaRuntimeError = EtaRuntimeError;558//# sourceMappingURL=index.cjs.map