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.
03k
1const {2 entries,3 setPrototypeOf,4 isFrozen,5 getPrototypeOf,6 getOwnPropertyDescriptor,7} = Object;8 9let { freeze, seal, create } = Object; // eslint-disable-line import/no-mutable-exports10let { apply, construct } = typeof Reflect !== 'undefined' && Reflect;11 12if (!freeze) {13 freeze = function <T>(x: T): T {14 return x;15 };16}17 18if (!seal) {19 seal = function <T>(x: T): T {20 return x;21 };22}23 24if (!apply) {25 apply = function <T>(26 func: (thisArg: any, ...args: any[]) => T,27 thisArg: any,28 ...args: any[]29 ): T {30 return func.apply(thisArg, args);31 };32}33 34if (!construct) {35 construct = function <T>(Func: new (...args: any[]) => T, ...args: any[]): T {36 return new Func(...args);37 };38}39 40const arrayForEach = unapply(Array.prototype.forEach);41const arrayIndexOf = unapply(Array.prototype.indexOf);42const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);43const arrayPop = unapply(Array.prototype.pop);44const arrayPush = unapply(Array.prototype.push);45const arraySlice = unapply(Array.prototype.slice);46const arraySplice = unapply(Array.prototype.splice);47const arrayIsArray = Array.isArray;48 49const stringToLowerCase = unapply(String.prototype.toLowerCase);50const stringToString = unapply(String.prototype.toString);51const stringMatch = unapply(String.prototype.match);52const stringReplace = unapply(String.prototype.replace);53const stringIndexOf = unapply(String.prototype.indexOf);54const stringTrim = unapply(String.prototype.trim);55 56const numberToString = unapply(Number.prototype.toString);57const booleanToString = unapply(Boolean.prototype.toString);58const bigintToString =59 typeof BigInt === 'undefined' ? null : unapply(BigInt.prototype.toString);60const symbolToString =61 typeof Symbol === 'undefined' ? null : unapply(Symbol.prototype.toString);62 63const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);64const objectToString = unapply(Object.prototype.toString);65 66const regExpTest = unapply(RegExp.prototype.test);67 68const typeErrorCreate = unconstruct(TypeError);69 70/**71 * Creates a new function that calls the given function with a specified thisArg and arguments.72 *73 * @param func - The function to be wrapped and called.74 * @returns A new function that calls the given function with a specified thisArg and arguments.75 */76function unapply<T>(77 func: (thisArg: any, ...args: any[]) => T78): (thisArg: any, ...args: any[]) => T {79 return (thisArg: any, ...args: any[]): T => {80 if (thisArg instanceof RegExp) {81 thisArg.lastIndex = 0;82 }83 84 return apply(func, thisArg, args);85 };86}87 88/**89 * Creates a new function that constructs an instance of the given constructor function with the provided arguments.90 *91 * @param func - The constructor function to be wrapped and called.92 * @returns A new function that constructs an instance of the given constructor function with the provided arguments.93 */94function unconstruct<T>(95 Func: new (...args: any[]) => T96): (...args: any[]) => T {97 return (...args: any[]): T => construct(Func, args);98}99 100/**101 * Add properties to a lookup table102 *103 * @param set - The set to which elements will be added.104 * @param array - The array containing elements to be added to the set.105 * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.106 * @returns The modified set with added elements.107 */108function addToSet(109 set: Record<string, boolean>,110 array: readonly unknown[],111 transformCaseFunc: ReturnType<typeof unapply<string>> = stringToLowerCase112): Record<string, boolean> {113 if (setPrototypeOf) {114 // Make 'in' and truthy checks like Boolean(set.constructor)115 // independent of any properties defined on Object.prototype.116 // Prevent prototype setters from intercepting set as a this value.117 setPrototypeOf(set, null);118 }119 120 if (!arrayIsArray(array)) {121 return set;122 }123 124 let l = array.length;125 while (l--) {126 let element = array[l];127 128 if (typeof element === 'string') {129 const lcElement = transformCaseFunc(element);130 131 if (lcElement !== element) {132 // Config presets (e.g. tags.js, attrs.js) are immutable.133 if (!isFrozen(array)) {134 (array as unknown[])[l] = lcElement;135 }136 137 element = lcElement;138 }139 }140 141 set[element as string] = true;142 }143 144 return set;145}146 147/**148 * Clean up an array to harden against CSPP149 *150 * @param array - The array to be cleaned.151 * @returns The cleaned version of the array152 */153function cleanArray<T>(array: T[]): Array<T | null> {154 for (let index = 0; index < array.length; index++) {155 const isPropertyExist = objectHasOwnProperty(array, index);156 157 if (!isPropertyExist) {158 array[index] = null;159 }160 }161 162 return array;163}164 165/**166 * Shallow clone an object167 *168 * @param object - The object to be cloned.169 * @returns A new object that copies the original.170 */171function clone<T extends Record<string, any>>(object: T): T {172 const newObject = create(null);173 174 for (const [property, value] of entries(object)) {175 const isPropertyExist = objectHasOwnProperty(object, property);176 177 if (isPropertyExist) {178 if (arrayIsArray(value)) {179 newObject[property] = cleanArray(value);180 } else if (181 value &&182 typeof value === 'object' &&183 value.constructor === Object184 ) {185 newObject[property] = clone(value);186 } else {187 newObject[property] = value;188 }189 }190 }191 192 return newObject;193}194 195/**196 * Convert non-node values into strings without depending on direct property access.197 *198 * @param value - The value to stringify.199 * @returns A string representation of the provided value.200 */201function stringifyValue(value: unknown): string {202 switch (typeof value) {203 case 'string': {204 return value;205 }206 207 case 'number': {208 return numberToString(value);209 }210 211 case 'boolean': {212 return booleanToString(value);213 }214 215 case 'bigint': {216 return bigintToString ? bigintToString(value) : '0';217 }218 219 case 'symbol': {220 return symbolToString ? symbolToString(value) : 'Symbol()';221 }222 223 case 'undefined': {224 return objectToString(value);225 }226 227 case 'function':228 case 'object': {229 if (value === null) {230 return objectToString(value);231 }232 233 const valueAsRecord = value as Record<string, any>;234 const valueToString = lookupGetter(valueAsRecord, 'toString');235 236 if (typeof valueToString === 'function') {237 const stringified = valueToString(valueAsRecord);238 239 return typeof stringified === 'string'240 ? stringified241 : objectToString(stringified);242 }243 244 return objectToString(value);245 }246 247 default: {248 return objectToString(value);249 }250 }251}252 253/**254 * This method automatically checks if the prop is function or getter and behaves accordingly.255 *256 * @param object - The object to look up the getter function in its prototype chain.257 * @param prop - The property name for which to find the getter function.258 * @returns The getter function found in the prototype chain or a fallback function.259 */260function lookupGetter<T extends Record<string, any>>(261 object: T,262 prop: string263): ReturnType<typeof unapply<any>> | (() => null) {264 while (object !== null) {265 const desc = getOwnPropertyDescriptor(object, prop);266 267 if (desc) {268 if (desc.get) {269 return unapply(desc.get);270 }271 272 if (typeof desc.value === 'function') {273 return unapply(desc.value);274 }275 }276 277 object = getPrototypeOf(object);278 }279 280 function fallbackValue(): null {281 return null;282 }283 284 return fallbackValue;285}286 287function isRegex(value: unknown): value is RegExp {288 try {289 regExpTest(value as RegExp, '');290 return true;291 } catch {292 return false;293 }294}295 296export {297 // Array298 arrayForEach,299 arrayIndexOf,300 arrayIsArray,301 arrayLastIndexOf,302 arrayPop,303 arrayPush,304 arraySlice,305 arraySplice,306 // Object307 entries,308 freeze,309 getPrototypeOf,310 getOwnPropertyDescriptor,311 isFrozen,312 setPrototypeOf,313 seal,314 clone,315 create,316 objectHasOwnProperty,317 objectToString,318 // RegExp319 regExpTest,320 isRegex,321 // String322 stringIndexOf,323 stringMatch,324 stringReplace,325 stringToLowerCase,326 stringToString,327 stringTrim,328 // Other conversion329 stringifyValue,330 // Errors331 typeErrorCreate,332 // Other333 lookupGetter,334 addToSet,335 // Reflect336 unapply,337 unconstruct,338};339 