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 COMMAND = 0;2const NUMBER = 1;3const EOD = 2;4const PARAMS = { A: 7, a: 7, C: 6, c: 6, H: 1, h: 1, L: 2, l: 2, M: 2, m: 2, Q: 4, q: 4, S: 4, s: 4, T: 2, t: 2, V: 1, v: 1, Z: 0, z: 0 };5function tokenize(d) {6 const tokens = new Array();7 while (d !== '') {8 if (d.match(/^([ \t\r\n,]+)/)) {9 d = d.substr(RegExp.$1.length);10 }11 else if (d.match(/^([aAcChHlLmMqQsStTvVzZ])/)) {12 tokens[tokens.length] = { type: COMMAND, text: RegExp.$1 };13 d = d.substr(RegExp.$1.length);14 }15 else if (d.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/)) {16 tokens[tokens.length] = { type: NUMBER, text: `${parseFloat(RegExp.$1)}` };17 d = d.substr(RegExp.$1.length);18 }19 else {20 return [];21 }22 }23 tokens[tokens.length] = { type: EOD, text: '' };24 return tokens;25}26function isType(token, type) {27 return token.type === type;28}29export function parsePath(d) {30 const segments = [];31 const tokens = tokenize(d);32 let mode = 'BOD';33 let index = 0;34 let token = tokens[index];35 while (!isType(token, EOD)) {36 let paramsCount = 0;37 const params = [];38 if (mode === 'BOD') {39 if (token.text === 'M' || token.text === 'm') {40 index++;41 paramsCount = PARAMS[token.text];42 mode = token.text;43 }44 else {45 return parsePath('M0,0' + d);46 }47 }48 else if (isType(token, NUMBER)) {49 paramsCount = PARAMS[mode];50 }51 else {52 index++;53 paramsCount = PARAMS[token.text];54 mode = token.text;55 }56 if ((index + paramsCount) < tokens.length) {57 for (let i = index; i < index + paramsCount; i++) {58 const numbeToken = tokens[i];59 if (isType(numbeToken, NUMBER)) {60 params[params.length] = +numbeToken.text;61 }62 else {63 throw new Error('Param not a number: ' + mode + ',' + numbeToken.text);64 }65 }66 if (typeof PARAMS[mode] === 'number') {67 const segment = { key: mode, data: params };68 segments.push(segment);69 index += paramsCount;70 token = tokens[index];71 if (mode === 'M')72 mode = 'L';73 if (mode === 'm')74 mode = 'l';75 }76 else {77 throw new Error('Bad segment: ' + mode);78 }79 }80 else {81 throw new Error('Path data ended short');82 }83 }84 return segments;85}86export function serialize(segments) {87 const tokens = [];88 for (const { key, data } of segments) {89 tokens.push(key);90 switch (key) {91 case 'C':92 case 'c':93 tokens.push(data[0], `${data[1]},`, data[2], `${data[3]},`, data[4], data[5]);94 break;95 case 'S':96 case 's':97 case 'Q':98 case 'q':99 tokens.push(data[0], `${data[1]},`, data[2], data[3]);100 break;101 default:102 tokens.push(...data);103 break;104 }105 }106 return tokens.join(' ');107}108 