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
common.js249 linesDownload Raw Back to http-proxy
1var common   = exports,2    url      = require('url'),3    extend   = require('util')._extend,4    required = require('requires-port');5 6var upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i,7    isSSL = /^https|wss/;8 9/**10 * Simple Regex for testing if protocol is https11 */12common.isSSL = isSSL;13/**14 * Copies the right headers from `options` and `req` to15 * `outgoing` which is then used to fire the proxied16 * request.17 *18 * Examples:19 *20 *    common.setupOutgoing(outgoing, options, req)21 *    // => { host: ..., hostname: ...}22 *23 * @param {Object} Outgoing Base object to be filled with required properties24 * @param {Object} Options Config object passed to the proxy25 * @param {ClientRequest} Req Request Object26 * @param {String} Forward String to select forward or target27 * 28 * @return {Object} Outgoing Object with all required properties set29 *30 * @api private31 */32 33common.setupOutgoing = function(outgoing, options, req, forward) {34  outgoing.port = options[forward || 'target'].port ||35                  (isSSL.test(options[forward || 'target'].protocol) ? 443 : 80);36 37  ['host', 'hostname', 'socketPath', 'pfx', 'key',38    'passphrase', 'cert', 'ca', 'ciphers', 'secureProtocol'].forEach(39    function(e) { outgoing[e] = options[forward || 'target'][e]; }40  );41 42  outgoing.method = options.method || req.method;43  outgoing.headers = extend({}, req.headers);44 45  if (options.headers){46    extend(outgoing.headers, options.headers);47  }48 49  if (options.auth) {50    outgoing.auth = options.auth;51  }52  53  if (options.ca) {54      outgoing.ca = options.ca;55  }56 57  if (isSSL.test(options[forward || 'target'].protocol)) {58    outgoing.rejectUnauthorized = (typeof options.secure === "undefined") ? true : options.secure;59  }60 61 62  outgoing.agent = options.agent || false;63  outgoing.localAddress = options.localAddress;64 65  //66  // Remark: If we are false and not upgrading, set the connection: close. This is the right thing to do67  // as node core doesn't handle this COMPLETELY properly yet.68  //69  if (!outgoing.agent) {70    outgoing.headers = outgoing.headers || {};71    if (typeof outgoing.headers.connection !== 'string'72        || !upgradeHeader.test(outgoing.headers.connection)73       ) { outgoing.headers.connection = 'close'; }74  }75 76 77  // the final path is target path + relative path requested by user:78  var target = options[forward || 'target'];79  var targetPath = target && options.prependPath !== false80    ? (target.path || '')81    : '';82 83  //84  // Remark: Can we somehow not use url.parse as a perf optimization?85  //86  var outgoingPath = !options.toProxy87    ? (url.parse(req.url).path || '')88    : req.url;89 90  //91  // Remark: ignorePath will just straight up ignore whatever the request's92  // path is. This can be labeled as FOOT-GUN material if you do not know what93  // you are doing and are using conflicting options.94  //95  outgoingPath = !options.ignorePath ? outgoingPath : '';96 97  outgoing.path = common.urlJoin(targetPath, outgoingPath);98 99  if (options.changeOrigin) {100    outgoing.headers.host =101      required(outgoing.port, options[forward || 'target'].protocol) && !hasPort(outgoing.host)102        ? outgoing.host + ':' + outgoing.port103        : outgoing.host;104  }105  return outgoing;106};107 108/**109 * Set the proper configuration for sockets,110 * set no delay and set keep alive, also set111 * the timeout to 0.112 *113 * Examples:114 *115 *    common.setupSocket(socket)116 *    // => Socket117 *118 * @param {Socket} Socket instance to setup119 * 120 * @return {Socket} Return the configured socket.121 *122 * @api private123 */124 125common.setupSocket = function(socket) {126  socket.setTimeout(0);127  socket.setNoDelay(true);128 129  socket.setKeepAlive(true, 0);130 131  return socket;132};133 134/**135 * Get the port number from the host. Or guess it based on the connection type.136 *137 * @param {Request} req Incoming HTTP request.138 *139 * @return {String} The port number.140 *141 * @api private142 */143common.getPort = function(req) {144  var res = req.headers.host ? req.headers.host.match(/:(\d+)/) : '';145 146  return res ?147    res[1] :148    common.hasEncryptedConnection(req) ? '443' : '80';149};150 151/**152 * Check if the request has an encrypted connection.153 *154 * @param {Request} req Incoming HTTP request.155 *156 * @return {Boolean} Whether the connection is encrypted or not.157 *158 * @api private159 */160common.hasEncryptedConnection = function(req) {161  return Boolean(req.connection.encrypted || req.connection.pair);162};163 164/**165 * OS-agnostic join (doesn't break on URLs like path.join does on Windows)>166 *167 * @return {String} The generated path.168 *169 * @api private170 */171 172common.urlJoin = function() {173    //174    // We do not want to mess with the query string. All we want to touch is the path.175    //176  var args = Array.prototype.slice.call(arguments),177      lastIndex = args.length - 1,178      last = args[lastIndex],179      lastSegs = last.split('?'),180      retSegs;181 182  args[lastIndex] = lastSegs.shift();183 184  //185  // Join all strings, but remove empty strings so we don't get extra slashes from186  // joining e.g. ['', 'am']187  //188  retSegs = [189    args.filter(Boolean).join('/')190        .replace(/\/+/g, '/')191        .replace('http:/', 'http://')192        .replace('https:/', 'https://')193  ];194 195  // Only join the query string if it exists so we don't have trailing a '?'196  // on every request197 198  // Handle case where there could be multiple ? in the URL.199  retSegs.push.apply(retSegs, lastSegs);200 201  return retSegs.join('?')202};203 204/**205 * Rewrites or removes the domain of a cookie header206 *207 * @param {String|Array} Header208 * @param {Object} Config, mapping of domain to rewritten domain.209 *                 '*' key to match any domain, null value to remove the domain.210 *211 * @api private212 */213common.rewriteCookieProperty = function rewriteCookieProperty(header, config, property) {214  if (Array.isArray(header)) {215    return header.map(function (headerElement) {216      return rewriteCookieProperty(headerElement, config, property);217    });218  }219  return header.replace(new RegExp("(;\\s*" + property + "=)([^;]+)", 'i'), function(match, prefix, previousValue) {220    var newValue;221    if (previousValue in config) {222      newValue = config[previousValue];223    } else if ('*' in config) {224      newValue = config['*'];225    } else {226      //no match, return previous value227      return match;228    }229    if (newValue) {230      //replace value231      return prefix + newValue;232    } else {233      //remove value234      return '';235    }236  });237};238 239/**240 * Check the host and see if it potentially has a port in it (keep it simple)241 *242 * @returns {Boolean} Whether we have one or not243 *244 * @api private245 */246function hasPort(host) {247  return !!~host.indexOf(':');248};249 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai