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'use strict';2 3const LogLevels = {4 silent: Number.NEGATIVE_INFINITY,5 fatal: 0,6 error: 0,7 warn: 1,8 log: 2,9 info: 3,10 success: 3,11 fail: 3,12 ready: 3,13 start: 3,14 box: 3,15 debug: 4,16 trace: 5,17 verbose: Number.POSITIVE_INFINITY18};19const LogTypes = {20 // Silent21 silent: {22 level: -123 },24 // Level 025 fatal: {26 level: LogLevels.fatal27 },28 error: {29 level: LogLevels.error30 },31 // Level 132 warn: {33 level: LogLevels.warn34 },35 // Level 236 log: {37 level: LogLevels.log38 },39 // Level 340 info: {41 level: LogLevels.info42 },43 success: {44 level: LogLevels.success45 },46 fail: {47 level: LogLevels.fail48 },49 ready: {50 level: LogLevels.info51 },52 start: {53 level: LogLevels.info54 },55 box: {56 level: LogLevels.info57 },58 // Level 459 debug: {60 level: LogLevels.debug61 },62 // Level 563 trace: {64 level: LogLevels.trace65 },66 // Verbose67 verbose: {68 level: LogLevels.verbose69 }70};71 72function isPlainObject$1(value) {73 if (value === null || typeof value !== "object") {74 return false;75 }76 const prototype = Object.getPrototypeOf(value);77 if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {78 return false;79 }80 if (Symbol.iterator in value) {81 return false;82 }83 if (Symbol.toStringTag in value) {84 return Object.prototype.toString.call(value) === "[object Module]";85 }86 return true;87}88 89function _defu(baseObject, defaults, namespace = ".", merger) {90 if (!isPlainObject$1(defaults)) {91 return _defu(baseObject, {}, namespace, merger);92 }93 const object = Object.assign({}, defaults);94 for (const key in baseObject) {95 if (key === "__proto__" || key === "constructor") {96 continue;97 }98 const value = baseObject[key];99 if (value === null || value === void 0) {100 continue;101 }102 if (merger && merger(object, key, value, namespace)) {103 continue;104 }105 if (Array.isArray(value) && Array.isArray(object[key])) {106 object[key] = [...value, ...object[key]];107 } else if (isPlainObject$1(value) && isPlainObject$1(object[key])) {108 object[key] = _defu(109 value,110 object[key],111 (namespace ? `${namespace}.` : "") + key.toString(),112 merger113 );114 } else {115 object[key] = value;116 }117 }118 return object;119}120function createDefu(merger) {121 return (...arguments_) => (122 // eslint-disable-next-line unicorn/no-array-reduce123 arguments_.reduce((p, c) => _defu(p, c, "", merger), {})124 );125}126const defu = createDefu();127 128function isPlainObject(obj) {129 return Object.prototype.toString.call(obj) === "[object Object]";130}131function isLogObj(arg) {132 if (!isPlainObject(arg)) {133 return false;134 }135 if (!arg.message && !arg.args) {136 return false;137 }138 if (arg.stack) {139 return false;140 }141 return true;142}143 144let paused = false;145const queue = [];146class Consola {147 options;148 _lastLog;149 _mockFn;150 /**151 * Creates an instance of Consola with specified options or defaults.152 *153 * @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.154 */155 constructor(options = {}) {156 const types = options.types || LogTypes;157 this.options = defu(158 {159 ...options,160 defaults: { ...options.defaults },161 level: _normalizeLogLevel(options.level, types),162 reporters: [...options.reporters || []]163 },164 {165 types: LogTypes,166 throttle: 1e3,167 throttleMin: 5,168 formatOptions: {169 date: true,170 colors: false,171 compact: true172 }173 }174 );175 for (const type in types) {176 const defaults = {177 type,178 ...this.options.defaults,179 ...types[type]180 };181 this[type] = this._wrapLogFn(defaults);182 this[type].raw = this._wrapLogFn(183 defaults,184 true185 );186 }187 if (this.options.mockFn) {188 this.mockTypes();189 }190 this._lastLog = {};191 }192 /**193 * Gets the current log level of the Consola instance.194 *195 * @returns {number} The current log level.196 */197 get level() {198 return this.options.level;199 }200 /**201 * Sets the minimum log level that will be output by the instance.202 *203 * @param {number} level - The new log level to set.204 */205 set level(level) {206 this.options.level = _normalizeLogLevel(207 level,208 this.options.types,209 this.options.level210 );211 }212 /**213 * Displays a prompt to the user and returns the response.214 * Throw an error if `prompt` is not supported by the current configuration.215 *216 * @template T217 * @param {string} message - The message to display in the prompt.218 * @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.219 * @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.220 */221 prompt(message, opts) {222 if (!this.options.prompt) {223 throw new Error("prompt is not supported!");224 }225 return this.options.prompt(message, opts);226 }227 /**228 * Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.229 *230 * @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.231 * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.232 */233 create(options) {234 const instance = new Consola({235 ...this.options,236 ...options237 });238 if (this._mockFn) {239 instance.mockTypes(this._mockFn);240 }241 return instance;242 }243 /**244 * Creates a new Consola instance with the specified default log object properties.245 *246 * @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.247 * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.248 */249 withDefaults(defaults) {250 return this.create({251 ...this.options,252 defaults: {253 ...this.options.defaults,254 ...defaults255 }256 });257 }258 /**259 * Creates a new Consola instance with a specified tag, which will be included in every log.260 *261 * @param {string} tag - The tag to include in each log of the new instance.262 * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.263 */264 withTag(tag) {265 return this.withDefaults({266 tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag267 });268 }269 /**270 * Adds a custom reporter to the Consola instance.271 * Reporters will be called for each log message, depending on their implementation and log level.272 *273 * @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.274 * @returns {Consola} The current Consola instance.275 */276 addReporter(reporter) {277 this.options.reporters.push(reporter);278 return this;279 }280 /**281 * Removes a custom reporter from the Consola instance.282 * If no reporter is specified, all reporters will be removed.283 *284 * @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.285 * @returns {Consola} The current Consola instance.286 */287 removeReporter(reporter) {288 if (reporter) {289 const i = this.options.reporters.indexOf(reporter);290 if (i !== -1) {291 return this.options.reporters.splice(i, 1);292 }293 } else {294 this.options.reporters.splice(0);295 }296 return this;297 }298 /**299 * Replaces all reporters of the Consola instance with the specified array of reporters.300 *301 * @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.302 * @returns {Consola} The current Consola instance.303 */304 setReporters(reporters) {305 this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];306 return this;307 }308 wrapAll() {309 this.wrapConsole();310 this.wrapStd();311 }312 restoreAll() {313 this.restoreConsole();314 this.restoreStd();315 }316 /**317 * Overrides console methods with Consola logging methods for consistent logging.318 */319 wrapConsole() {320 for (const type in this.options.types) {321 if (!console["__" + type]) {322 console["__" + type] = console[type];323 }324 console[type] = this[type].raw;325 }326 }327 /**328 * Restores the original console methods, removing Consola overrides.329 */330 restoreConsole() {331 for (const type in this.options.types) {332 if (console["__" + type]) {333 console[type] = console["__" + type];334 delete console["__" + type];335 }336 }337 }338 /**339 * Overrides standard output and error streams to redirect them through Consola.340 */341 wrapStd() {342 this._wrapStream(this.options.stdout, "log");343 this._wrapStream(this.options.stderr, "log");344 }345 _wrapStream(stream, type) {346 if (!stream) {347 return;348 }349 if (!stream.__write) {350 stream.__write = stream.write;351 }352 stream.write = (data) => {353 this[type].raw(String(data).trim());354 };355 }356 /**357 * Restores the original standard output and error streams, removing the Consola redirection.358 */359 restoreStd() {360 this._restoreStream(this.options.stdout);361 this._restoreStream(this.options.stderr);362 }363 _restoreStream(stream) {364 if (!stream) {365 return;366 }367 if (stream.__write) {368 stream.write = stream.__write;369 delete stream.__write;370 }371 }372 /**373 * Pauses logging, queues incoming logs until resumed.374 */375 pauseLogs() {376 paused = true;377 }378 /**379 * Resumes logging, processing any queued logs.380 */381 resumeLogs() {382 paused = false;383 const _queue = queue.splice(0);384 for (const item of _queue) {385 item[0]._logFn(item[1], item[2]);386 }387 }388 /**389 * Replaces logging methods with mocks if a mock function is provided.390 *391 * @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.392 */393 mockTypes(mockFn) {394 const _mockFn = mockFn || this.options.mockFn;395 this._mockFn = _mockFn;396 if (typeof _mockFn !== "function") {397 return;398 }399 for (const type in this.options.types) {400 this[type] = _mockFn(type, this.options.types[type]) || this[type];401 this[type].raw = this[type];402 }403 }404 _wrapLogFn(defaults, isRaw) {405 return (...args) => {406 if (paused) {407 queue.push([this, defaults, args, isRaw]);408 return;409 }410 return this._logFn(defaults, args, isRaw);411 };412 }413 _logFn(defaults, args, isRaw) {414 if ((defaults.level || 0) > this.level) {415 return false;416 }417 const logObj = {418 date: /* @__PURE__ */ new Date(),419 args: [],420 ...defaults,421 level: _normalizeLogLevel(defaults.level, this.options.types)422 };423 if (!isRaw && args.length === 1 && isLogObj(args[0])) {424 Object.assign(logObj, args[0]);425 } else {426 logObj.args = [...args];427 }428 if (logObj.message) {429 logObj.args.unshift(logObj.message);430 delete logObj.message;431 }432 if (logObj.additional) {433 if (!Array.isArray(logObj.additional)) {434 logObj.additional = logObj.additional.split("\n");435 }436 logObj.args.push("\n" + logObj.additional.join("\n"));437 delete logObj.additional;438 }439 logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";440 logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";441 const resolveLog = (newLog = false) => {442 const repeated = (this._lastLog.count || 0) - this.options.throttleMin;443 if (this._lastLog.object && repeated > 0) {444 const args2 = [...this._lastLog.object.args];445 if (repeated > 1) {446 args2.push(`(repeated ${repeated} times)`);447 }448 this._log({ ...this._lastLog.object, args: args2 });449 this._lastLog.count = 1;450 }451 if (newLog) {452 this._lastLog.object = logObj;453 this._log(logObj);454 }455 };456 clearTimeout(this._lastLog.timeout);457 const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;458 this._lastLog.time = logObj.date;459 if (diffTime < this.options.throttle) {460 try {461 const serializedLog = JSON.stringify([462 logObj.type,463 logObj.tag,464 logObj.args465 ]);466 const isSameLog = this._lastLog.serialized === serializedLog;467 this._lastLog.serialized = serializedLog;468 if (isSameLog) {469 this._lastLog.count = (this._lastLog.count || 0) + 1;470 if (this._lastLog.count > this.options.throttleMin) {471 this._lastLog.timeout = setTimeout(472 resolveLog,473 this.options.throttle474 );475 return;476 }477 }478 } catch {479 }480 }481 resolveLog(true);482 }483 _log(logObj) {484 for (const reporter of this.options.reporters) {485 reporter.log(logObj, {486 options: this.options487 });488 }489 }490}491function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {492 if (input === void 0) {493 return defaultLevel;494 }495 if (typeof input === "number") {496 return input;497 }498 if (types[input] && types[input].level !== void 0) {499 return types[input].level;500 }501 return defaultLevel;502}503Consola.prototype.add = Consola.prototype.addReporter;504Consola.prototype.remove = Consola.prototype.removeReporter;505Consola.prototype.clear = Consola.prototype.removeReporter;506Consola.prototype.withScope = Consola.prototype.withTag;507Consola.prototype.mock = Consola.prototype.mockTypes;508Consola.prototype.pause = Consola.prototype.pauseLogs;509Consola.prototype.resume = Consola.prototype.resumeLogs;510function createConsola(options = {}) {511 return new Consola(options);512}513 514exports.Consola = Consola;515exports.LogLevels = LogLevels;516exports.LogTypes = LogTypes;517exports.createConsola = createConsola;518 