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// To do: next major: remove.2/**3 * @typedef {Options} MarkdownTableOptions4 * Configuration.5 */6 7/**8 * @typedef Options9 * Configuration.10 * @property {boolean | null | undefined} [alignDelimiters=true]11 * Whether to align the delimiters (default: `true`);12 * they are aligned by default:13 *14 * ```markdown15 * | Alpha | B |16 * | ----- | ----- |17 * | C | Delta |18 * ```19 *20 * Pass `false` to make them staggered:21 *22 * ```markdown23 * | Alpha | B |24 * | - | - |25 * | C | Delta |26 * ```27 * @property {ReadonlyArray<string | null | undefined> | string | null | undefined} [align]28 * How to align columns (default: `''`);29 * one style for all columns or styles for their respective columns;30 * each style is either `'l'` (left), `'r'` (right), or `'c'` (center);31 * other values are treated as `''`, which doesn’t place the colon in the32 * alignment row but does align left;33 * *only the lowercased first character is used, so `Right` is fine.*34 * @property {boolean | null | undefined} [delimiterEnd=true]35 * Whether to end each row with the delimiter (default: `true`).36 *37 * > 👉 **Note**: please don’t use this: it could create fragile structures38 * > that aren’t understandable to some markdown parsers.39 *40 * When `true`, there are ending delimiters:41 *42 * ```markdown43 * | Alpha | B |44 * | ----- | ----- |45 * | C | Delta |46 * ```47 *48 * When `false`, there are no ending delimiters:49 *50 * ```markdown51 * | Alpha | B52 * | ----- | -----53 * | C | Delta54 * ```55 * @property {boolean | null | undefined} [delimiterStart=true]56 * Whether to begin each row with the delimiter (default: `true`).57 *58 * > 👉 **Note**: please don’t use this: it could create fragile structures59 * > that aren’t understandable to some markdown parsers.60 *61 * When `true`, there are starting delimiters:62 *63 * ```markdown64 * | Alpha | B |65 * | ----- | ----- |66 * | C | Delta |67 * ```68 *69 * When `false`, there are no starting delimiters:70 *71 * ```markdown72 * Alpha | B |73 * ----- | ----- |74 * C | Delta |75 * ```76 * @property {boolean | null | undefined} [padding=true]77 * Whether to add a space of padding between delimiters and cells78 * (default: `true`).79 *80 * When `true`, there is padding:81 *82 * ```markdown83 * | Alpha | B |84 * | ----- | ----- |85 * | C | Delta |86 * ```87 *88 * When `false`, there is no padding:89 *90 * ```markdown91 * |Alpha|B |92 * |-----|-----|93 * |C |Delta|94 * ```95 * @property {((value: string) => number) | null | undefined} [stringLength]96 * Function to detect the length of table cell content (optional);97 * this is used when aligning the delimiters (`|`) between table cells;98 * full-width characters and emoji mess up delimiter alignment when viewing99 * the markdown source;100 * to fix this, you can pass this function,101 * which receives the cell content and returns its “visible” size;102 * note that what is and isn’t visible depends on where the text is displayed.103 *104 * Without such a function, the following:105 *106 * ```js107 * markdownTable([108 * ['Alpha', 'Bravo'],109 * ['中文', 'Charlie'],110 * ['👩❤️👩', 'Delta']111 * ])112 * ```113 *114 * Yields:115 *116 * ```markdown117 * | Alpha | Bravo |118 * | - | - |119 * | 中文 | Charlie |120 * | 👩❤️👩 | Delta |121 * ```122 *123 * With [`string-width`](https://github.com/sindresorhus/string-width):124 *125 * ```js126 * import stringWidth from 'string-width'127 *128 * markdownTable(129 * [130 * ['Alpha', 'Bravo'],131 * ['中文', 'Charlie'],132 * ['👩❤️👩', 'Delta']133 * ],134 * {stringLength: stringWidth}135 * )136 * ```137 *138 * Yields:139 *140 * ```markdown141 * | Alpha | Bravo |142 * | ----- | ------- |143 * | 中文 | Charlie |144 * | 👩❤️👩 | Delta |145 * ```146 */147 148/**149 * @param {string} value150 * Cell value.151 * @returns {number}152 * Cell size.153 */154function defaultStringLength(value) {155 return value.length156}157 158/**159 * Generate a markdown160 * ([GFM](https://docs.github.com/en/github/writing-on-github/working-with-advanced-formatting/organizing-information-with-tables))161 * table.162 *163 * @param {ReadonlyArray<ReadonlyArray<string | null | undefined>>} table164 * Table data (matrix of strings).165 * @param {Readonly<Options> | null | undefined} [options]166 * Configuration (optional).167 * @returns {string}168 * Result.169 */170export function markdownTable(table, options) {171 const settings = options || {}172 // To do: next major: change to spread.173 const align = (settings.align || []).concat()174 const stringLength = settings.stringLength || defaultStringLength175 /** @type {Array<number>} Character codes as symbols for alignment per column. */176 const alignments = []177 /** @type {Array<Array<string>>} Cells per row. */178 const cellMatrix = []179 /** @type {Array<Array<number>>} Sizes of each cell per row. */180 const sizeMatrix = []181 /** @type {Array<number>} */182 const longestCellByColumn = []183 let mostCellsPerRow = 0184 let rowIndex = -1185 186 // This is a superfluous loop if we don’t align delimiters, but otherwise we’d187 // do superfluous work when aligning, so optimize for aligning.188 while (++rowIndex < table.length) {189 /** @type {Array<string>} */190 const row = []191 /** @type {Array<number>} */192 const sizes = []193 let columnIndex = -1194 195 if (table[rowIndex].length > mostCellsPerRow) {196 mostCellsPerRow = table[rowIndex].length197 }198 199 while (++columnIndex < table[rowIndex].length) {200 const cell = serialize(table[rowIndex][columnIndex])201 202 if (settings.alignDelimiters !== false) {203 const size = stringLength(cell)204 sizes[columnIndex] = size205 206 if (207 longestCellByColumn[columnIndex] === undefined ||208 size > longestCellByColumn[columnIndex]209 ) {210 longestCellByColumn[columnIndex] = size211 }212 }213 214 row.push(cell)215 }216 217 cellMatrix[rowIndex] = row218 sizeMatrix[rowIndex] = sizes219 }220 221 // Figure out which alignments to use.222 let columnIndex = -1223 224 if (typeof align === 'object' && 'length' in align) {225 while (++columnIndex < mostCellsPerRow) {226 alignments[columnIndex] = toAlignment(align[columnIndex])227 }228 } else {229 const code = toAlignment(align)230 231 while (++columnIndex < mostCellsPerRow) {232 alignments[columnIndex] = code233 }234 }235 236 // Inject the alignment row.237 columnIndex = -1238 /** @type {Array<string>} */239 const row = []240 /** @type {Array<number>} */241 const sizes = []242 243 while (++columnIndex < mostCellsPerRow) {244 const code = alignments[columnIndex]245 let before = ''246 let after = ''247 248 if (code === 99 /* `c` */) {249 before = ':'250 after = ':'251 } else if (code === 108 /* `l` */) {252 before = ':'253 } else if (code === 114 /* `r` */) {254 after = ':'255 }256 257 // There *must* be at least one hyphen-minus in each alignment cell.258 let size =259 settings.alignDelimiters === false260 ? 1261 : Math.max(262 1,263 longestCellByColumn[columnIndex] - before.length - after.length264 )265 266 const cell = before + '-'.repeat(size) + after267 268 if (settings.alignDelimiters !== false) {269 size = before.length + size + after.length270 271 if (size > longestCellByColumn[columnIndex]) {272 longestCellByColumn[columnIndex] = size273 }274 275 sizes[columnIndex] = size276 }277 278 row[columnIndex] = cell279 }280 281 // Inject the alignment row.282 cellMatrix.splice(1, 0, row)283 sizeMatrix.splice(1, 0, sizes)284 285 rowIndex = -1286 /** @type {Array<string>} */287 const lines = []288 289 while (++rowIndex < cellMatrix.length) {290 const row = cellMatrix[rowIndex]291 const sizes = sizeMatrix[rowIndex]292 columnIndex = -1293 /** @type {Array<string>} */294 const line = []295 296 while (++columnIndex < mostCellsPerRow) {297 const cell = row[columnIndex] || ''298 let before = ''299 let after = ''300 301 if (settings.alignDelimiters !== false) {302 const size =303 longestCellByColumn[columnIndex] - (sizes[columnIndex] || 0)304 const code = alignments[columnIndex]305 306 if (code === 114 /* `r` */) {307 before = ' '.repeat(size)308 } else if (code === 99 /* `c` */) {309 if (size % 2) {310 before = ' '.repeat(size / 2 + 0.5)311 after = ' '.repeat(size / 2 - 0.5)312 } else {313 before = ' '.repeat(size / 2)314 after = before315 }316 } else {317 after = ' '.repeat(size)318 }319 }320 321 if (settings.delimiterStart !== false && !columnIndex) {322 line.push('|')323 }324 325 if (326 settings.padding !== false &&327 // Don’t add the opening space if we’re not aligning and the cell is328 // empty: there will be a closing space.329 !(settings.alignDelimiters === false && cell === '') &&330 (settings.delimiterStart !== false || columnIndex)331 ) {332 line.push(' ')333 }334 335 if (settings.alignDelimiters !== false) {336 line.push(before)337 }338 339 line.push(cell)340 341 if (settings.alignDelimiters !== false) {342 line.push(after)343 }344 345 if (settings.padding !== false) {346 line.push(' ')347 }348 349 if (350 settings.delimiterEnd !== false ||351 columnIndex !== mostCellsPerRow - 1352 ) {353 line.push('|')354 }355 }356 357 lines.push(358 settings.delimiterEnd === false359 ? line.join('').replace(/ +$/, '')360 : line.join('')361 )362 }363 364 return lines.join('\n')365}366 367/**368 * @param {string | null | undefined} [value]369 * Value to serialize.370 * @returns {string}371 * Result.372 */373function serialize(value) {374 return value === null || value === undefined ? '' : String(value)375}376 377/**378 * @param {string | null | undefined} value379 * Value.380 * @returns {number}381 * Alignment.382 */383function toAlignment(value) {384 const code = typeof value === 'string' ? value.codePointAt(0) : 0385 386 return code === 67 /* `C` */ || code === 99 /* `c` */387 ? 99 /* `c` */388 : code === 76 /* `L` */ || code === 108 /* `l` */389 ? 108 /* `l` */390 : code === 82 /* `R` */ || code === 114 /* `r` */391 ? 114 /* `r` */392 : 0393}394 