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
read.js248 linesDownload Raw Back to lib
1/*!2 * body-parser3 * Copyright(c) 2014-2015 Douglas Christopher Wilson4 * MIT Licensed5 */6 7'use strict'8 9/**10 * Module dependencies.11 * @private12 */13 14const createError = require('http-errors')15const getBody = require('raw-body')16const iconv = require('iconv-lite')17const onFinished = require('on-finished')18const zlib = require('node:zlib')19const hasBody = require('type-is').hasBody20const { getCharset } = require('./utils')21 22/**23 * Module exports.24 */25 26module.exports = read27 28/**29 * Read a request into a buffer and parse.30 *31 * @param {Object} req32 * @param {Object} res33 * @param {Function} next34 * @param {Function} parse35 * @param {Function} debug36 * @param {Object} options37 * @private38 */39function read (req, res, next, parse, debug, options) {40  if (onFinished.isFinished(req)) {41    debug('body already parsed')42    next()43    return44  }45 46  if (!('body' in req)) {47    req.body = undefined48  }49 50  // skip requests without bodies51  if (!hasBody(req)) {52    debug('skip empty body')53    next()54    return55  }56 57  debug('content-type %j', req.headers['content-type'])58 59  // determine if request should be parsed60  if (!options.shouldParse(req)) {61    debug('skip parsing')62    next()63    return64  }65 66  let encoding = null67  if (options?.skipCharset !== true) {68    encoding = getCharset(req) || options.defaultCharset69 70    // validate charset71    if (!!options?.isValidCharset && !options.isValidCharset(encoding)) {72      debug('invalid charset')73      next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {74        charset: encoding,75        type: 'charset.unsupported'76      }))77      return78    }79  }80 81  let length82  const opts = options83  let stream84 85  // read options86  const verify = opts.verify87 88  try {89    // get the content stream90    stream = contentstream(req, debug, opts.inflate)91    length = stream.length92    stream.length = undefined93  } catch (err) {94    return next(err)95  }96 97  // set raw-body options98  opts.length = length99  opts.encoding = verify100    ? null101    : encoding102 103  // assert charset is supported104  if (opts.encoding === null && encoding !== null && !iconv.encodingExists(encoding)) {105    return next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {106      charset: encoding.toLowerCase(),107      type: 'charset.unsupported'108    }))109  }110 111  // read body112  debug('read body')113  getBody(stream, opts, function (error, body) {114    if (error) {115      let _error116 117      if (error.type === 'encoding.unsupported') {118        // echo back charset119        _error = createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {120          charset: encoding.toLowerCase(),121          type: 'charset.unsupported'122        })123      } else {124        // set status code on error125        _error = createError(400, error)126      }127 128      // unpipe from stream and destroy129      if (stream !== req) {130        req.unpipe()131        stream.destroy()132      }133 134      // read off entire request135      dump(req, function onfinished () {136        next(createError(400, _error))137      })138      return139    }140 141    // verify142    if (verify) {143      try {144        debug('verify body')145        verify(req, res, body, encoding)146      } catch (err) {147        next(createError(403, err, {148          body: body,149          type: err.type || 'entity.verify.failed'150        }))151        return152      }153    }154 155    // parse156    let str = body157    try {158      debug('parse body')159      str = typeof body !== 'string' && encoding !== null160        ? iconv.decode(body, encoding)161        : body162      req.body = parse(str, encoding)163    } catch (err) {164      next(createError(400, err, {165        body: str,166        type: err.type || 'entity.parse.failed'167      }))168      return169    }170 171    next()172  })173}174 175/**176 * Get the content stream of the request.177 *178 * @param {Object} req179 * @param {Function} debug180 * @param {boolean} inflate181 * @returns {Object}182 * @private183 */184function contentstream (req, debug, inflate) {185  const encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()186  const length = req.headers['content-length']187 188  debug('content-encoding "%s"', encoding)189 190  if (inflate === false && encoding !== 'identity') {191    throw createError(415, 'content encoding unsupported', {192      encoding: encoding,193      type: 'encoding.unsupported'194    })195  }196 197  if (encoding === 'identity') {198    req.length = length199    return req200  }201 202  const stream = createDecompressionStream(encoding, debug)203  req.pipe(stream)204  return stream205}206 207/**208 * Create a decompression stream for the given encoding.209 * @param {string} encoding210 * @param {Function} debug211 * @returns {Object}212 * @private213 */214function createDecompressionStream (encoding, debug) {215  switch (encoding) {216    case 'deflate':217      debug('inflate body')218      return zlib.createInflate()219    case 'gzip':220      debug('gunzip body')221      return zlib.createGunzip()222    case 'br':223      debug('brotli decompress body')224      return zlib.createBrotliDecompress()225    default:226      throw createError(415, 'unsupported content encoding "' + encoding + '"', {227        encoding: encoding,228        type: 'encoding.unsupported'229      })230  }231}232 233/**234 * Dump the contents of a request.235 *236 * @param {Object} req237 * @param {Function} callback238 * @private239 */240function dump (req, callback) {241  if (onFinished.isFinished(req)) {242    callback(null)243  } else {244    onFinished(req, callback)245    req.resume()246  }247}248 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai