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 3/** @type {(value: string) => boolean} */4const isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu)5 6/** @type {(value: string) => boolean} */7const isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u)8 9/** @type {(value: string) => boolean} */10const isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu)11 12/** @type {(value: string) => boolean} */13const isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu)14 15/** @type {(value: string) => boolean} */16const isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu)17 18/**19 * @param {Array<string>} input20 * @returns {string}21 */22function stringArrayToHexStripped (input) {23 let acc = ''24 let code = 025 let i = 026 27 for (i = 0; i < input.length; i++) {28 code = input[i].charCodeAt(0)29 if (code === 48) {30 continue31 }32 if (!((code >= 48 && code <= 57) || (code >= 65 && code <= 70) || (code >= 97 && code <= 102))) {33 return ''34 }35 acc += input[i]36 break37 }38 39 for (i += 1; i < input.length; i++) {40 code = input[i].charCodeAt(0)41 if (!((code >= 48 && code <= 57) || (code >= 65 && code <= 70) || (code >= 97 && code <= 102))) {42 return ''43 }44 acc += input[i]45 }46 return acc47}48 49/**50 * @typedef {Object} GetIPV6Result51 * @property {boolean} error - Indicates if there was an error parsing the IPv6 address.52 * @property {string} address - The parsed IPv6 address.53 * @property {string} [zone] - The zone identifier, if present.54 */55 56/**57 * @param {string} value58 * @returns {boolean}59 */60const nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u)61 62/**63 * @param {Array<string>} buffer64 * @returns {boolean}65 */66function consumeIsZone (buffer) {67 buffer.length = 068 return true69}70 71/**72 * @param {Array<string>} buffer73 * @param {Array<string>} address74 * @param {GetIPV6Result} output75 * @returns {boolean}76 */77function consumeHextets (buffer, address, output) {78 if (buffer.length) {79 const hex = stringArrayToHexStripped(buffer)80 if (hex !== '') {81 address.push(hex)82 } else {83 output.error = true84 return false85 }86 buffer.length = 087 }88 return true89}90 91/**92 * @param {string} input93 * @returns {GetIPV6Result}94 */95function getIPV6 (input) {96 let tokenCount = 097 const output = { error: false, address: '', zone: '' }98 /** @type {Array<string>} */99 const address = []100 /** @type {Array<string>} */101 const buffer = []102 let endipv6Encountered = false103 let endIpv6 = false104 105 let consume = consumeHextets106 107 for (let i = 0; i < input.length; i++) {108 const cursor = input[i]109 if (cursor === '[' || cursor === ']') { continue }110 if (cursor === ':') {111 if (endipv6Encountered === true) {112 endIpv6 = true113 }114 if (!consume(buffer, address, output)) { break }115 if (++tokenCount > 7) {116 // not valid117 output.error = true118 break119 }120 if (i > 0 && input[i - 1] === ':') {121 endipv6Encountered = true122 }123 address.push(':')124 continue125 } else if (cursor === '%') {126 if (!consume(buffer, address, output)) { break }127 // switch to zone detection128 consume = consumeIsZone129 } else {130 buffer.push(cursor)131 continue132 }133 }134 if (buffer.length) {135 if (consume === consumeIsZone) {136 output.zone = buffer.join('')137 } else if (endIpv6) {138 address.push(buffer.join(''))139 } else {140 address.push(stringArrayToHexStripped(buffer))141 }142 }143 output.address = address.join('')144 return output145}146 147/**148 * @typedef {Object} NormalizeIPv6Result149 * @property {string} host - The normalized host.150 * @property {string} [escapedHost] - The escaped host.151 * @property {boolean} isIPV6 - Indicates if the host is an IPv6 address.152 */153 154/**155 * @param {string} host156 * @returns {NormalizeIPv6Result}157 */158function normalizeIPv6 (host) {159 if (findToken(host, ':') < 2) { return { host, isIPV6: false } }160 const ipv6 = getIPV6(host)161 162 if (!ipv6.error) {163 let newHost = ipv6.address164 let escapedHost = ipv6.address165 if (ipv6.zone) {166 newHost += '%' + ipv6.zone167 escapedHost += '%25' + ipv6.zone168 }169 return { host: newHost, isIPV6: true, escapedHost }170 } else {171 return { host, isIPV6: false }172 }173}174 175/**176 * @param {string} str177 * @param {string} token178 * @returns {number}179 */180function findToken (str, token) {181 let ind = 0182 for (let i = 0; i < str.length; i++) {183 if (str[i] === token) ind++184 }185 return ind186}187 188/**189 * @param {string} path190 * @returns {string}191 *192 * @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4193 */194function removeDotSegments (path) {195 let input = path196 const output = []197 let nextSlash = -1198 let len = 0199 200 // eslint-disable-next-line no-cond-assign201 while (len = input.length) {202 if (len === 1) {203 if (input === '.') {204 break205 } else if (input === '/') {206 output.push('/')207 break208 } else {209 output.push(input)210 break211 }212 } else if (len === 2) {213 if (input[0] === '.') {214 if (input[1] === '.') {215 break216 } else if (input[1] === '/') {217 input = input.slice(2)218 continue219 }220 } else if (input[0] === '/') {221 if (input[1] === '.' || input[1] === '/') {222 output.push('/')223 break224 }225 }226 } else if (len === 3) {227 if (input === '/..') {228 if (output.length !== 0) {229 output.pop()230 }231 output.push('/')232 break233 }234 }235 if (input[0] === '.') {236 if (input[1] === '.') {237 if (input[2] === '/') {238 input = input.slice(3)239 continue240 }241 } else if (input[1] === '/') {242 input = input.slice(2)243 continue244 }245 } else if (input[0] === '/') {246 if (input[1] === '.') {247 if (input[2] === '/') {248 input = input.slice(2)249 continue250 } else if (input[2] === '.') {251 if (input[3] === '/') {252 input = input.slice(3)253 if (output.length !== 0) {254 output.pop()255 }256 continue257 }258 }259 }260 }261 262 // Rule 2E: Move normal path segment to output263 if ((nextSlash = input.indexOf('/', 1)) === -1) {264 output.push(input)265 break266 } else {267 output.push(input.slice(0, nextSlash))268 input = input.slice(nextSlash)269 }270 }271 272 return output.join('')273}274 275/**276 * Re-escape RFC 3986 gen-delims that must not appear literally in the host.277 * After the URI regex parses, these characters cannot be literal in the host278 * field, so any that appear after decoding came from percent-encoding and279 * must be restored to prevent authority structure changes.280 *281 * @param {string} host282 * @param {boolean} isIP - true for IPv4/IPv6 hosts (skip colon re-escaping)283 * @returns {string}284 */285const HOST_DELIMS = { '@': '%40', '/': '%2F', '?': '%3F', '#': '%23', ':': '%3A' }286const HOST_DELIM_RE = /[@/?#:]/g287const HOST_DELIM_NO_COLON_RE = /[@/?#]/g288 289function reescapeHostDelimiters (host, isIP) {290 const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE291 re.lastIndex = 0292 return host.replace(re, (ch) => HOST_DELIMS[ch])293}294 295/**296 * Normalizes percent escapes and optionally decodes only unreserved ASCII bytes.297 * Reserved delimiters such as `%2F` and `%2E` stay escaped.298 *299 * @param {string} input300 * @param {boolean} [decodeUnreserved=false]301 * @returns {string}302 */303function normalizePercentEncoding (input, decodeUnreserved = false) {304 if (input.indexOf('%') === -1) {305 return input306 }307 308 let output = ''309 310 for (let i = 0; i < input.length; i++) {311 if (input[i] === '%' && i + 2 < input.length) {312 const hex = input.slice(i + 1, i + 3)313 if (isHexPair(hex)) {314 const normalizedHex = hex.toUpperCase()315 const decoded = String.fromCharCode(parseInt(normalizedHex, 16))316 317 if (decodeUnreserved && isUnreserved(decoded)) {318 output += decoded319 } else {320 output += '%' + normalizedHex321 }322 323 i += 2324 continue325 }326 }327 328 output += input[i]329 }330 331 return output332}333 334/**335 * Normalizes path data without turning reserved escapes into live path syntax.336 * Valid escapes are uppercased, raw unsafe characters are escaped, and only337 * unreserved bytes that are not `.` are decoded.338 *339 * @param {string} input340 * @returns {string}341 */342function normalizePathEncoding (input) {343 let output = ''344 345 for (let i = 0; i < input.length; i++) {346 if (input[i] === '%' && i + 2 < input.length) {347 const hex = input.slice(i + 1, i + 3)348 if (isHexPair(hex)) {349 const normalizedHex = hex.toUpperCase()350 const decoded = String.fromCharCode(parseInt(normalizedHex, 16))351 352 if (decoded !== '.' && isUnreserved(decoded)) {353 output += decoded354 } else {355 output += '%' + normalizedHex356 }357 358 i += 2359 continue360 }361 }362 363 if (isPathCharacter(input[i])) {364 output += input[i]365 } else {366 output += escape(input[i])367 }368 }369 370 return output371}372 373/**374 * Escapes a component while preserving existing valid percent escapes.375 *376 * @param {string} input377 * @returns {string}378 */379function escapePreservingEscapes (input) {380 let output = ''381 382 for (let i = 0; i < input.length; i++) {383 if (input[i] === '%' && i + 2 < input.length) {384 const hex = input.slice(i + 1, i + 3)385 if (isHexPair(hex)) {386 output += '%' + hex.toUpperCase()387 i += 2388 continue389 }390 }391 392 output += escape(input[i])393 }394 395 return output396}397 398/**399 * @param {import('../types/index').URIComponent} component400 * @returns {string|undefined}401 */402function recomposeAuthority (component) {403 const uriTokens = []404 405 if (component.userinfo !== undefined) {406 uriTokens.push(component.userinfo)407 uriTokens.push('@')408 }409 410 if (component.host !== undefined) {411 let host = unescape(component.host)412 if (!isIPv4(host)) {413 const ipV6res = normalizeIPv6(host)414 if (ipV6res.isIPV6 === true) {415 host = `[${ipV6res.escapedHost}]`416 } else {417 host = reescapeHostDelimiters(host, false)418 }419 }420 uriTokens.push(host)421 }422 423 if (typeof component.port === 'number' || typeof component.port === 'string') {424 uriTokens.push(':')425 uriTokens.push(String(component.port))426 }427 428 return uriTokens.length ? uriTokens.join('') : undefined429};430 431module.exports = {432 nonSimpleDomain,433 recomposeAuthority,434 reescapeHostDelimiters,435 normalizePercentEncoding,436 normalizePathEncoding,437 escapePreservingEscapes,438 removeDotSegments,439 isIPv4,440 isUUID,441 normalizeIPv6,442 stringArrayToHexStripped443}444 