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
wsServer.js122 linesDownload Raw Back to utils
1"use strict";2var __defProp = Object.defineProperty;3var __getOwnPropDesc = Object.getOwnPropertyDescriptor;4var __getOwnPropNames = Object.getOwnPropertyNames;5var __hasOwnProp = Object.prototype.hasOwnProperty;6var __export = (target, all) => {7  for (var name in all)8    __defProp(target, name, { get: all[name], enumerable: true });9};10var __copyProps = (to, from, except, desc) => {11  if (from && typeof from === "object" || typeof from === "function") {12    for (let key of __getOwnPropNames(from))13      if (!__hasOwnProp.call(to, key) && key !== except)14        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });15  }16  return to;17};18var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);19var wsServer_exports = {};20__export(wsServer_exports, {21  WSServer: () => WSServer,22  perMessageDeflate: () => perMessageDeflate23});24module.exports = __toCommonJS(wsServer_exports);25var import_network = require("./network");26var import_utilsBundle = require("../../utilsBundle");27var import_debugLogger = require("./debugLogger");28let lastConnectionId = 0;29const kConnectionSymbol = Symbol("kConnection");30const perMessageDeflate = {31  serverNoContextTakeover: true,32  zlibDeflateOptions: {33    level: 334  },35  zlibInflateOptions: {36    chunkSize: 10 * 102437  },38  threshold: 10 * 102439};40class WSServer {41  constructor(delegate) {42    this._delegate = delegate;43  }44  async listen(port = 0, hostname, path) {45    import_debugLogger.debugLogger.log("server", `Server started at ${/* @__PURE__ */ new Date()}`);46    const server = (0, import_network.createHttpServer)(this._delegate.onRequest);47    server.on("error", (error) => import_debugLogger.debugLogger.log("server", String(error)));48    this.server = server;49    const wsEndpoint = await new Promise((resolve, reject) => {50      server.listen(port, hostname, () => {51        const address = server.address();52        if (!address) {53          reject(new Error("Could not bind server socket"));54          return;55        }56        const wsEndpoint2 = typeof address === "string" ? `${address}${path}` : `ws://${hostname || "localhost"}:${address.port}${path}`;57        resolve(wsEndpoint2);58      }).on("error", reject);59    });60    import_debugLogger.debugLogger.log("server", "Listening at " + wsEndpoint);61    this._wsServer = new import_utilsBundle.wsServer({62      noServer: true,63      perMessageDeflate64    });65    this._wsServer.on("headers", (headers) => this._delegate.onHeaders(headers));66    server.on("upgrade", (request, socket, head) => {67      const pathname = new URL("http://localhost" + request.url).pathname;68      if (pathname !== path) {69        socket.write(`HTTP/${request.httpVersion} 400 Bad Request\r70\r71`);72        socket.destroy();73        return;74      }75      const upgradeResult = this._delegate.onUpgrade(request, socket);76      if (upgradeResult) {77        socket.write(upgradeResult.error);78        socket.destroy();79        return;80      }81      this._wsServer.handleUpgrade(request, socket, head, (ws) => this._wsServer.emit("connection", ws, request));82    });83    this._wsServer.on("connection", (ws, request) => {84      import_debugLogger.debugLogger.log("server", "Connected client ws.extension=" + ws.extensions);85      const url = new URL("http://localhost" + (request.url || ""));86      const id = String(++lastConnectionId);87      import_debugLogger.debugLogger.log("server", `[${id}] serving connection: ${request.url}`);88      const connection = this._delegate.onConnection(request, url, ws, id);89      ws[kConnectionSymbol] = connection;90    });91    return wsEndpoint;92  }93  async close() {94    const server = this._wsServer;95    if (!server)96      return;97    import_debugLogger.debugLogger.log("server", "closing websocket server");98    const waitForClose = new Promise((f) => server.close(f));99    await Promise.all(Array.from(server.clients).map(async (ws) => {100      const connection = ws[kConnectionSymbol];101      if (connection)102        await connection.close();103      try {104        ws.terminate();105      } catch (e) {106      }107    }));108    await waitForClose;109    import_debugLogger.debugLogger.log("server", "closing http server");110    if (this.server)111      await new Promise((f) => this.server.close(f));112    this._wsServer = void 0;113    this.server = void 0;114    import_debugLogger.debugLogger.log("server", "closed server");115  }116}117// Annotate the CommonJS export names for ESM import in node:1180 && (module.exports = {119  WSServer,120  perMessageDeflate121});122 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai