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