Team Ai
Datasetpublic

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.

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes3.1kdownloads
parseJson.ts178 linesDownload Raw Back to runtime
1const rxParseJson = /position\s(\d+)(?: \(line \d+ column \d+\))?$/2 3export function parseJson(s: string, pos: number): unknown {4  let endPos: number | undefined5  parseJson.message = undefined6  let matches: RegExpExecArray | null7  if (pos) s = s.slice(pos)8  try {9    parseJson.position = pos + s.length10    return JSON.parse(s)11  } catch (e) {12    matches = rxParseJson.exec((e as Error).message)13    if (!matches) {14      parseJson.message = "unexpected end"15      return undefined16    }17    endPos = +matches[1]18    const c = s[endPos]19    s = s.slice(0, endPos)20    parseJson.position = pos + endPos21    try {22      return JSON.parse(s)23    } catch (e1) {24      parseJson.message = `unexpected token ${c}`25      return undefined26    }27  }28}29 30parseJson.message = undefined as string | undefined31parseJson.position = 0 as number32parseJson.code = 'require("ajv/dist/runtime/parseJson").parseJson'33 34export function parseJsonNumber(s: string, pos: number, maxDigits?: number): number | undefined {35  let numStr = ""36  let c: string37  parseJsonNumber.message = undefined38  if (s[pos] === "-") {39    numStr += "-"40    pos++41  }42  if (s[pos] === "0") {43    numStr += "0"44    pos++45  } else {46    if (!parseDigits(maxDigits)) {47      errorMessage()48      return undefined49    }50  }51  if (maxDigits) {52    parseJsonNumber.position = pos53    return +numStr54  }55  if (s[pos] === ".") {56    numStr += "."57    pos++58    if (!parseDigits()) {59      errorMessage()60      return undefined61    }62  }63  if (((c = s[pos]), c === "e" || c === "E")) {64    numStr += "e"65    pos++66    if (((c = s[pos]), c === "+" || c === "-")) {67      numStr += c68      pos++69    }70    if (!parseDigits()) {71      errorMessage()72      return undefined73    }74  }75  parseJsonNumber.position = pos76  return +numStr77 78  function parseDigits(maxLen?: number): boolean {79    let digit = false80    while (((c = s[pos]), c >= "0" && c <= "9" && (maxLen === undefined || maxLen-- > 0))) {81      digit = true82      numStr += c83      pos++84    }85    return digit86  }87 88  function errorMessage(): void {89    parseJsonNumber.position = pos90    parseJsonNumber.message = pos < s.length ? `unexpected token ${s[pos]}` : "unexpected end"91  }92}93 94parseJsonNumber.message = undefined as string | undefined95parseJsonNumber.position = 0 as number96parseJsonNumber.code = 'require("ajv/dist/runtime/parseJson").parseJsonNumber'97 98const escapedChars: {[X in string]?: string} = {99  b: "\b",100  f: "\f",101  n: "\n",102  r: "\r",103  t: "\t",104  '"': '"',105  "/": "/",106  "\\": "\\",107}108 109const CODE_A: number = "a".charCodeAt(0)110const CODE_0: number = "0".charCodeAt(0)111 112export function parseJsonString(s: string, pos: number): string | undefined {113  let str = ""114  let c: string | undefined115  parseJsonString.message = undefined116  // eslint-disable-next-line no-constant-condition, @typescript-eslint/no-unnecessary-condition117  while (true) {118    c = s[pos++]119    if (c === '"') break120    if (c === "\\") {121      c = s[pos]122      if (c in escapedChars) {123        str += escapedChars[c]124        pos++125      } else if (c === "u") {126        pos++127        let count = 4128        let code = 0129        while (count--) {130          code <<= 4131          c = s[pos]132          // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition133          if (c === undefined) {134            errorMessage("unexpected end")135            return undefined136          }137          c = c.toLowerCase()138          if (c >= "a" && c <= "f") {139            code += c.charCodeAt(0) - CODE_A + 10140          } else if (c >= "0" && c <= "9") {141            code += c.charCodeAt(0) - CODE_0142          } else {143            errorMessage(`unexpected token ${c}`)144            return undefined145          }146          pos++147        }148        str += String.fromCharCode(code)149      } else {150        errorMessage(`unexpected token ${c}`)151        return undefined152      }153      // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition154    } else if (c === undefined) {155      errorMessage("unexpected end")156      return undefined157    } else {158      if (c.charCodeAt(0) >= 0x20) {159        str += c160      } else {161        errorMessage(`unexpected token ${c}`)162        return undefined163      }164    }165  }166  parseJsonString.position = pos167  return str168 169  function errorMessage(msg: string): void {170    parseJsonString.position = pos171    parseJsonString.message = msg172  }173}174 175parseJsonString.message = undefined as string | undefined176parseJsonString.position = 0 as number177parseJsonString.code = 'require("ajv/dist/runtime/parseJson").parseJsonString'178 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai