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 common = require('./common')4 5// get snippet for a single line, respecting maxLength6function getLine (buffer, lineStart, lineEnd, position, maxLineLength) {7 let head = ''8 let tail = ''9 const maxHalfLength = Math.floor(maxLineLength / 2) - 110 11 if (position - lineStart > maxHalfLength) {12 head = ' ... '13 lineStart = position - maxHalfLength + head.length14 }15 16 if (lineEnd - position > maxHalfLength) {17 tail = ' ...'18 lineEnd = position + maxHalfLength - tail.length19 }20 21 return {22 str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, '→') + tail,23 pos: position - lineStart + head.length // relative position24 }25}26 27function padStart (string, max) {28 return common.repeat(' ', max - string.length) + string29}30 31function makeSnippet (mark, options) {32 options = Object.create(options || null)33 34 if (!mark.buffer) return null35 36 if (!options.maxLength) options.maxLength = 7937 if (typeof options.indent !== 'number') options.indent = 138 if (typeof options.linesBefore !== 'number') options.linesBefore = 339 if (typeof options.linesAfter !== 'number') options.linesAfter = 240 41 const re = /\r?\n|\r|\0/g42 const lineStarts = [0]43 const lineEnds = []44 let match45 let foundLineNo = -146 47 while ((match = re.exec(mark.buffer))) {48 lineEnds.push(match.index)49 lineStarts.push(match.index + match[0].length)50 51 if (mark.position <= match.index && foundLineNo < 0) {52 foundLineNo = lineStarts.length - 253 }54 }55 56 if (foundLineNo < 0) foundLineNo = lineStarts.length - 157 58 let result = ''59 const lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length60 const maxLineLength = options.maxLength - (options.indent + lineNoLength + 3)61 62 for (let i = 1; i <= options.linesBefore; i++) {63 if (foundLineNo - i < 0) break64 const line = getLine(65 mark.buffer,66 lineStarts[foundLineNo - i],67 lineEnds[foundLineNo - i],68 mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),69 maxLineLength70 )71 result = common.repeat(' ', options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) +72 ' | ' + line.str + '\n' + result73 }74 75 const line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength)76 result += common.repeat(' ', options.indent) + padStart((mark.line + 1).toString(), lineNoLength) +77 ' | ' + line.str + '\n'78 result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n'79 80 for (let i = 1; i <= options.linesAfter; i++) {81 if (foundLineNo + i >= lineEnds.length) break82 const line = getLine(83 mark.buffer,84 lineStarts[foundLineNo + i],85 lineEnds[foundLineNo + i],86 mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),87 maxLineLength88 )89 result += common.repeat(' ', options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) +90 ' | ' + line.str + '\n'91 }92 93 return result.replace(/\n$/, '')94}95 96module.exports = makeSnippet97 