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";2Object.defineProperty(exports, "__esModule", { value: !0 });3class ParseError extends Error {4 constructor(message, options) {5 super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;6 }7}8const LF = 10, CR = 13, SPACE = 32;9function noop(_arg) {10}11function createParser(config) {12 if (typeof config == "function")13 throw new TypeError(14 "`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"15 );16 const { onEvent = noop, onError = noop, onRetry = noop, onComment, maxBufferSize } = config, pendingFragments = [];17 let pendingFragmentsLength = 0, isFirstChunk = !0, id, data = "", dataLines = 0, eventType, terminated = !1;18 function feed(chunk) {19 if (terminated)20 throw new Error(21 "Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."22 );23 if (isFirstChunk && (isFirstChunk = !1, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {24 const trailing2 = processLines(chunk);25 trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();26 return;27 }28 if (chunk.indexOf(`29`) === -1 && chunk.indexOf("\r") === -1) {30 pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();31 return;32 }33 pendingFragments.push(chunk);34 const input = pendingFragments.join("");35 pendingFragments.length = 0, pendingFragmentsLength = 0;36 const trailing = processLines(input);37 trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();38 }39 function checkBufferSize() {40 maxBufferSize !== void 0 && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = !0, pendingFragments.length = 0, pendingFragmentsLength = 0, id = void 0, data = "", dataLines = 0, eventType = void 0, onError(41 new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {42 type: "max-buffer-size-exceeded"43 })44 )));45 }46 function processLines(chunk) {47 let searchIndex = 0;48 if (chunk.indexOf("\r") === -1) {49 let lfIndex = chunk.indexOf(`50`, searchIndex);51 for (; lfIndex !== -1; ) {52 if (searchIndex === lfIndex) {53 dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`54`, searchIndex);55 continue;56 }57 const firstCharCode = chunk.charCodeAt(searchIndex);58 if (isDataPrefix(chunk, searchIndex, firstCharCode)) {59 const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);60 if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {61 onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`62`, searchIndex);63 continue;64 }65 data = dataLines === 0 ? value : `${data}66${value}`, dataLines++;67 } else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(68 chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,69 lfIndex70 ) || void 0 : parseLine(chunk, searchIndex, lfIndex);71 searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`72`, searchIndex);73 }74 return chunk.slice(searchIndex);75 }76 for (; searchIndex < chunk.length; ) {77 const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`78`, searchIndex);79 let lineEnd = -1;80 if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = crIndex < lfIndex ? crIndex : lfIndex : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1)81 break;82 parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;83 }84 return chunk.slice(searchIndex);85 }86 function parseLine(chunk, start, end) {87 if (start === end) {88 dispatchEvent();89 return;90 }91 const firstCharCode = chunk.charCodeAt(start);92 if (isDataPrefix(chunk, start, firstCharCode)) {93 const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);94 data = dataLines === 0 ? value2 : `${data}95${value2}`, dataLines++;96 return;97 }98 if (isEventPrefix(chunk, start, firstCharCode)) {99 eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;100 return;101 }102 if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {103 const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);104 id = value2.includes("\0") ? void 0 : value2;105 return;106 }107 if (firstCharCode === 58) {108 if (onComment) {109 const line2 = chunk.slice(start, end);110 onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));111 }112 return;113 }114 const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");115 if (fieldSeparatorIndex === -1) {116 processField(line, "", line);117 return;118 }119 const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);120 processField(field, value, line);121 }122 function processField(field, value, line) {123 switch (field) {124 case "event":125 eventType = value || void 0;126 break;127 case "data":128 data = dataLines === 0 ? value : `${data}129${value}`, dataLines++;130 break;131 case "id":132 id = value.includes("\0") ? void 0 : value;133 break;134 case "retry":135 /^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(136 new ParseError(`Invalid \`retry\` value: "${value}"`, {137 type: "invalid-retry",138 value,139 line140 })141 );142 break;143 default:144 onError(145 new ParseError(146 `Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,147 { type: "unknown-field", field, value, line }148 )149 );150 break;151 }152 }153 function dispatchEvent() {154 dataLines > 0 && onEvent({155 id,156 event: eventType,157 data158 }), id = void 0, data = "", dataLines = 0, eventType = void 0;159 }160 function reset(options = {}) {161 if (options.consume && pendingFragments.length > 0) {162 const incompleteLine = pendingFragments.join("");163 parseLine(incompleteLine, 0, incompleteLine.length);164 }165 isFirstChunk = !0, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = !1;166 }167 return { feed, reset };168}169function isDataPrefix(chunk, i, firstCharCode) {170 return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;171}172function isEventPrefix(chunk, i, firstCharCode) {173 return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;174}175exports.ParseError = ParseError;176exports.createParser = createParser;177//# sourceMappingURL=index.cjs.map178 