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.
03k
1#!/usr/bin/env node2 3'use strict';4 5var chalk = require('chalk'),6 os = require('os'),7 httpServer = require('../lib/http-server'),8 portfinder = require('portfinder'),9 opener = require('opener'),10 11 fs = require('fs'),12 url = require('url');13var argv = require('minimist')(process.argv.slice(2), {14 alias: {15 tls: 'ssl'16 }17});18var ifaces = os.networkInterfaces();19 20process.title = 'http-server';21 22if (argv.h || argv.help) {23 console.log([24 'usage: http-server [path] [options]',25 '',26 'options:',27 ' -p --port Port to use. If 0, look for open port. [8080]',28 ' -a Address to use [0.0.0.0]',29 ' -d Show directory listings [true]',30 ' -i Display autoIndex [true]',31 ' -g --gzip Serve gzip files when possible [false]',32 ' -b --brotli Serve brotli files when possible [false]',33 ' If both brotli and gzip are enabled, brotli takes precedence',34 ' -e --ext Default file extension if none supplied [none]',35 ' -s --silent Suppress log messages from output',36 ' --cors[=headers] Enable CORS via the "Access-Control-Allow-Origin" header',37 ' Optionally provide CORS headers list separated by commas',38 ' -o [path] Open browser window after starting the server.',39 ' Optionally provide a URL path to open the browser window to.',40 ' -c Cache time (max-age) in seconds [3600], e.g. -c10 for 10 seconds.',41 ' To disable caching, use -c-1.',42 ' -t Connections timeout in seconds [120], e.g. -t60 for 1 minute.',43 ' To disable timeout, use -t0',44 ' -U --utc Use UTC time format in log messages.',45 ' --log-ip Enable logging of the client\'s IP address',46 '',47 ' -P --proxy Fallback proxy if the request cannot be resolved. e.g.: http://someurl.com',48 ' --proxy-options Pass options to proxy using nested dotted objects. e.g.: --proxy-options.secure false',49 '',50 ' --username Username for basic authentication [none]',51 ' Can also be specified with the env variable NODE_HTTP_SERVER_USERNAME',52 ' --password Password for basic authentication [none]',53 ' Can also be specified with the env variable NODE_HTTP_SERVER_PASSWORD',54 '',55 ' -S --tls --ssl Enable secure request serving with TLS/SSL (HTTPS)',56 ' -C --cert Path to TLS cert file (default: cert.pem)',57 ' -K --key Path to TLS key file (default: key.pem)',58 '',59 ' -r --robots Respond to /robots.txt [User-agent: *\\nDisallow: /]',60 ' --no-dotfiles Do not show dotfiles',61 ' --mimetypes Path to a .types file for custom mimetype definition',62 ' -h --help Print this list and exit.',63 ' -v --version Print the version and exit.'64 ].join('\n'));65 process.exit();66}67 68var port = argv.p || argv.port || parseInt(process.env.PORT, 10),69 host = argv.a || '0.0.0.0',70 tls = argv.S || argv.tls,71 sslPassphrase = process.env.NODE_HTTP_SERVER_SSL_PASSPHRASE,72 proxy = argv.P || argv.proxy,73 proxyOptions = argv['proxy-options'],74 utc = argv.U || argv.utc,75 version = argv.v || argv.version,76 logger;77 78var proxyOptionsBooleanProps = [79 'ws', 'xfwd', 'secure', 'toProxy', 'prependPath', 'ignorePath', 'changeOrigin',80 'preserveHeaderKeyCase', 'followRedirects', 'selfHandleResponse'81];82 83if (proxyOptions) {84 Object.keys(proxyOptions).forEach(function (key) {85 if (proxyOptionsBooleanProps.indexOf(key) > -1) {86 proxyOptions[key] = proxyOptions[key].toLowerCase() === 'true';87 }88 });89}90 91if (!argv.s && !argv.silent) {92 logger = {93 info: console.log,94 request: function (req, res, error) {95 var date = utc ? new Date().toUTCString() : new Date();96 var ip = argv['log-ip']97 ? req.headers['x-forwarded-for'] || '' + req.connection.remoteAddress98 : '';99 if (error) {100 logger.info(101 '[%s] %s "%s %s" Error (%s): "%s"',102 date, ip, chalk.red(req.method), chalk.red(req.url),103 chalk.red(error.status.toString()), chalk.red(error.message)104 );105 }106 else {107 logger.info(108 '[%s] %s "%s %s" "%s"',109 date, ip, chalk.cyan(req.method), chalk.cyan(req.url),110 req.headers['user-agent']111 );112 }113 }114 };115}116else if (chalk) {117 logger = {118 info: function () {},119 request: function () {}120 };121}122 123if (version) {124 logger.info('v' + require('../package.json').version);125 process.exit();126}127 128if (!port) {129 portfinder.basePort = 8080;130 portfinder.getPort(function (err, port) {131 if (err) { throw err; }132 listen(port);133 });134}135else {136 listen(port);137}138 139function listen(port) {140 var options = {141 root: argv._[0],142 cache: argv.c,143 timeout: argv.t,144 showDir: argv.d,145 autoIndex: argv.i,146 gzip: argv.g || argv.gzip,147 brotli: argv.b || argv.brotli,148 robots: argv.r || argv.robots,149 ext: argv.e || argv.ext,150 logFn: logger.request,151 proxy: proxy,152 proxyOptions: proxyOptions,153 showDotfiles: argv.dotfiles,154 mimetypes: argv.mimetypes,155 username: argv.username || process.env.NODE_HTTP_SERVER_USERNAME,156 password: argv.password || process.env.NODE_HTTP_SERVER_PASSWORD157 };158 159 if (argv.cors) {160 options.cors = true;161 if (typeof argv.cors === 'string') {162 options.corsHeaders = argv.cors;163 }164 }165 166 if (proxy) {167 try {168 new url.URL(proxy)169 }170 catch (err) {171 logger.info(chalk.red('Error: Invalid proxy url'));172 process.exit(1);173 }174 }175 176 if (tls) {177 options.https = {178 cert: argv.C || argv.cert || 'cert.pem',179 key: argv.K || argv.key || 'key.pem',180 passphrase: sslPassphrase,181 };182 try {183 fs.lstatSync(options.https.cert);184 }185 catch (err) {186 logger.info(chalk.red('Error: Could not find certificate ' + options.https.cert));187 process.exit(1);188 }189 try {190 fs.lstatSync(options.https.key);191 }192 catch (err) {193 logger.info(chalk.red('Error: Could not find private key ' + options.https.key));194 process.exit(1);195 }196 }197 198 var server = httpServer.createServer(options);199 server.listen(port, host, function () {200 var protocol = tls ? 'https://' : 'http://';201 202 logger.info([203 chalk.yellow('Starting up http-server, serving '),204 chalk.cyan(server.root),205 tls ? (chalk.yellow(' through') + chalk.cyan(' https')) : ''206 ].join(''));207 208 logger.info([chalk.yellow('\nhttp-server version: '), chalk.cyan(require('../package.json').version)].join(''));209 210 logger.info([211 chalk.yellow('\nhttp-server settings: '),212 ([chalk.yellow('CORS: '), argv.cors ? chalk.cyan(argv.cors) : chalk.red('disabled')].join('')),213 ([chalk.yellow('Cache: '), argv.c ? (argv.c === '-1' ? chalk.red('disabled') : chalk.cyan(argv.c + ' seconds')) : chalk.cyan('3600 seconds')].join('')),214 ([chalk.yellow('Connection Timeout: '), argv.t === '0' ? chalk.red('disabled') : (argv.t ? chalk.cyan(argv.t + ' seconds') : chalk.cyan('120 seconds'))].join('')),215 ([chalk.yellow('Directory Listings: '), argv.d ? chalk.red('not visible') : chalk.cyan('visible')].join('')),216 ([chalk.yellow('AutoIndex: '), argv.i ? chalk.red('not visible') : chalk.cyan('visible')].join('')),217 ([chalk.yellow('Serve GZIP Files: '), argv.g || argv.gzip ? chalk.cyan('true') : chalk.red('false')].join('')),218 ([chalk.yellow('Serve Brotli Files: '), argv.b || argv.brotli ? chalk.cyan('true') : chalk.red('false')].join('')),219 ([chalk.yellow('Default File Extension: '), argv.e ? chalk.cyan(argv.e) : (argv.ext ? chalk.cyan(argv.ext) : chalk.red('none'))].join(''))220 ].join('\n'));221 222 logger.info(chalk.yellow('\nAvailable on:'));223 224 if (argv.a && host !== '0.0.0.0') {225 logger.info(` ${protocol}${host}:${chalk.green(port.toString())}`);226 } else {227 Object.keys(ifaces).forEach(function (dev) {228 ifaces[dev].forEach(function (details) {229 if (details.family === 'IPv4') {230 logger.info((' ' + protocol + details.address + ':' + chalk.green(port.toString())));231 }232 });233 });234 }235 236 if (typeof proxy === 'string') {237 if (proxyOptions) {238 logger.info('Unhandled requests will be served from: ' + proxy + '. Options: ' + JSON.stringify(proxyOptions));239 }240 else {241 logger.info('Unhandled requests will be served from: ' + proxy);242 }243 }244 245 logger.info('Hit CTRL-C to stop the server');246 if (argv.o) {247 const openHost = host === '0.0.0.0' ? '127.0.0.1' : host;248 let openUrl = `${protocol}${openHost}:${port}`;249 if (typeof argv.o === 'string') {250 openUrl += argv.o[0] === '/' ? argv.o : '/' + argv.o;251 }252 logger.info('Open: ' + openUrl);253 opener(openUrl);254 }255 256 // Spacing before logs257 if (!argv.s) logger.info();258 });259}260 261if (process.platform === 'win32') {262 require('readline').createInterface({263 input: process.stdin,264 output: process.stdout265 }).on('SIGINT', function () {266 process.emit('SIGINT');267 });268}269 270process.on('SIGINT', function () {271 logger.info(chalk.red('http-server stopped.'));272 process.exit();273});274 275process.on('SIGTERM', function () {276 logger.info(chalk.red('http-server stopped.'));277 process.exit();278});279 