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.
03.1k
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 network_exports = {};20__export(network_exports, {21 RawHeaders: () => RawHeaders,22 Request: () => Request,23 Response: () => Response,24 Route: () => Route,25 RouteHandler: () => RouteHandler,26 WebSocket: () => WebSocket,27 WebSocketRoute: () => WebSocketRoute,28 WebSocketRouteHandler: () => WebSocketRouteHandler,29 validateHeaders: () => validateHeaders30});31module.exports = __toCommonJS(network_exports);32var import_channelOwner = require("./channelOwner");33var import_errors = require("./errors");34var import_events = require("./events");35var import_fetch = require("./fetch");36var import_frame = require("./frame");37var import_waiter = require("./waiter");38var import_worker = require("./worker");39var import_assert = require("../utils/isomorphic/assert");40var import_headers = require("../utils/isomorphic/headers");41var import_urlMatch = require("../utils/isomorphic/urlMatch");42var import_manualPromise = require("../utils/isomorphic/manualPromise");43var import_multimap = require("../utils/isomorphic/multimap");44var import_rtti = require("../utils/isomorphic/rtti");45var import_stackTrace = require("../utils/isomorphic/stackTrace");46var import_mimeType = require("../utils/isomorphic/mimeType");47class Request extends import_channelOwner.ChannelOwner {48 constructor(parent, type, guid, initializer) {49 super(parent, type, guid, initializer);50 this._redirectedFrom = null;51 this._redirectedTo = null;52 this._failureText = null;53 this._fallbackOverrides = {};54 this._hasResponse = false;55 this._redirectedFrom = Request.fromNullable(initializer.redirectedFrom);56 if (this._redirectedFrom)57 this._redirectedFrom._redirectedTo = this;58 this._provisionalHeaders = new RawHeaders(initializer.headers);59 this._timing = {60 startTime: 0,61 domainLookupStart: -1,62 domainLookupEnd: -1,63 connectStart: -1,64 secureConnectionStart: -1,65 connectEnd: -1,66 requestStart: -1,67 responseStart: -1,68 responseEnd: -169 };70 this._hasResponse = this._initializer.hasResponse;71 this._channel.on("response", () => this._hasResponse = true);72 }73 static from(request) {74 return request._object;75 }76 static fromNullable(request) {77 return request ? Request.from(request) : null;78 }79 url() {80 return this._fallbackOverrides.url || this._initializer.url;81 }82 resourceType() {83 return this._initializer.resourceType;84 }85 method() {86 return this._fallbackOverrides.method || this._initializer.method;87 }88 postData() {89 return (this._fallbackOverrides.postDataBuffer || this._initializer.postData)?.toString("utf-8") || null;90 }91 postDataBuffer() {92 return this._fallbackOverrides.postDataBuffer || this._initializer.postData || null;93 }94 postDataJSON() {95 const postData = this.postData();96 if (!postData)97 return null;98 const contentType = this.headers()["content-type"];99 if (contentType?.includes("application/x-www-form-urlencoded")) {100 const entries = {};101 const parsed = new URLSearchParams(postData);102 for (const [k, v] of parsed.entries())103 entries[k] = v;104 return entries;105 }106 try {107 return JSON.parse(postData);108 } catch (e) {109 throw new Error("POST data is not a valid JSON object: " + postData);110 }111 }112 /**113 * @deprecated114 */115 headers() {116 if (this._fallbackOverrides.headers)117 return RawHeaders._fromHeadersObjectLossy(this._fallbackOverrides.headers).headers();118 return this._provisionalHeaders.headers();119 }120 async _actualHeaders() {121 if (this._fallbackOverrides.headers)122 return RawHeaders._fromHeadersObjectLossy(this._fallbackOverrides.headers);123 if (!this._actualHeadersPromise) {124 this._actualHeadersPromise = this._wrapApiCall(async () => {125 return new RawHeaders((await this._channel.rawRequestHeaders()).headers);126 }, { internal: true });127 }128 return await this._actualHeadersPromise;129 }130 async allHeaders() {131 return (await this._actualHeaders()).headers();132 }133 async headersArray() {134 return (await this._actualHeaders()).headersArray();135 }136 async headerValue(name) {137 return (await this._actualHeaders()).get(name);138 }139 async response() {140 return Response.fromNullable((await this._channel.response()).response);141 }142 async _internalResponse() {143 return Response.fromNullable((await this._channel.response()).response);144 }145 frame() {146 if (!this._initializer.frame) {147 (0, import_assert.assert)(this.serviceWorker());148 throw new Error("Service Worker requests do not have an associated frame.");149 }150 const frame = import_frame.Frame.from(this._initializer.frame);151 if (!frame._page) {152 throw new Error([153 "Frame for this navigation request is not available, because the request",154 "was issued before the frame is created. You can check whether the request",155 "is a navigation request by calling isNavigationRequest() method."156 ].join("\n"));157 }158 return frame;159 }160 _safePage() {161 return import_frame.Frame.fromNullable(this._initializer.frame)?._page || null;162 }163 serviceWorker() {164 return this._initializer.serviceWorker ? import_worker.Worker.from(this._initializer.serviceWorker) : null;165 }166 isNavigationRequest() {167 return this._initializer.isNavigationRequest;168 }169 redirectedFrom() {170 return this._redirectedFrom;171 }172 redirectedTo() {173 return this._redirectedTo;174 }175 failure() {176 if (this._failureText === null)177 return null;178 return {179 errorText: this._failureText180 };181 }182 timing() {183 return this._timing;184 }185 async sizes() {186 const response = await this.response();187 if (!response)188 throw new Error("Unable to fetch sizes for failed request");189 return (await response._channel.sizes()).sizes;190 }191 _setResponseEndTiming(responseEndTiming) {192 this._timing.responseEnd = responseEndTiming;193 if (this._timing.responseStart === -1)194 this._timing.responseStart = responseEndTiming;195 }196 _finalRequest() {197 return this._redirectedTo ? this._redirectedTo._finalRequest() : this;198 }199 _applyFallbackOverrides(overrides) {200 if (overrides.url)201 this._fallbackOverrides.url = overrides.url;202 if (overrides.method)203 this._fallbackOverrides.method = overrides.method;204 if (overrides.headers)205 this._fallbackOverrides.headers = overrides.headers;206 if ((0, import_rtti.isString)(overrides.postData))207 this._fallbackOverrides.postDataBuffer = Buffer.from(overrides.postData, "utf-8");208 else if (overrides.postData instanceof Buffer)209 this._fallbackOverrides.postDataBuffer = overrides.postData;210 else if (overrides.postData)211 this._fallbackOverrides.postDataBuffer = Buffer.from(JSON.stringify(overrides.postData), "utf-8");212 }213 _fallbackOverridesForContinue() {214 return this._fallbackOverrides;215 }216 _targetClosedScope() {217 return this.serviceWorker()?._closedScope || this._safePage()?._closedOrCrashedScope || new import_manualPromise.LongStandingScope();218 }219}220class Route extends import_channelOwner.ChannelOwner {221 constructor(parent, type, guid, initializer) {222 super(parent, type, guid, initializer);223 this._handlingPromise = null;224 this._didThrow = false;225 }226 static from(route) {227 return route._object;228 }229 request() {230 return Request.from(this._initializer.request);231 }232 async _raceWithTargetClose(promise) {233 return await this.request()._targetClosedScope().safeRace(promise);234 }235 async _startHandling() {236 this._handlingPromise = new import_manualPromise.ManualPromise();237 return await this._handlingPromise;238 }239 async fallback(options = {}) {240 this._checkNotHandled();241 this.request()._applyFallbackOverrides(options);242 this._reportHandled(false);243 }244 async abort(errorCode) {245 await this._handleRoute(async () => {246 await this._raceWithTargetClose(this._channel.abort({ errorCode }));247 });248 }249 async _redirectNavigationRequest(url) {250 await this._handleRoute(async () => {251 await this._raceWithTargetClose(this._channel.redirectNavigationRequest({ url }));252 });253 }254 async fetch(options = {}) {255 return await this._wrapApiCall(async () => {256 return await this._context.request._innerFetch({ request: this.request(), data: options.postData, ...options });257 });258 }259 async fulfill(options = {}) {260 await this._handleRoute(async () => {261 await this._innerFulfill(options);262 });263 }264 async _handleRoute(callback) {265 this._checkNotHandled();266 try {267 await callback();268 this._reportHandled(true);269 } catch (e) {270 this._didThrow = true;271 throw e;272 }273 }274 async _innerFulfill(options = {}) {275 let fetchResponseUid;276 let { status: statusOption, headers: headersOption, body } = options;277 if (options.json !== void 0) {278 (0, import_assert.assert)(options.body === void 0, "Can specify either body or json parameters");279 body = JSON.stringify(options.json);280 }281 if (options.response instanceof import_fetch.APIResponse) {282 statusOption ??= options.response.status();283 headersOption ??= options.response.headers();284 if (body === void 0 && options.path === void 0) {285 if (options.response._request._connection === this._connection)286 fetchResponseUid = options.response._fetchUid();287 else288 body = await options.response.body();289 }290 }291 let isBase64 = false;292 let length = 0;293 if (options.path) {294 const buffer = await this._platform.fs().promises.readFile(options.path);295 body = buffer.toString("base64");296 isBase64 = true;297 length = buffer.length;298 } else if ((0, import_rtti.isString)(body)) {299 isBase64 = false;300 length = Buffer.byteLength(body);301 } else if (body) {302 length = body.length;303 body = body.toString("base64");304 isBase64 = true;305 }306 const headers = {};307 for (const header of Object.keys(headersOption || {}))308 headers[header.toLowerCase()] = String(headersOption[header]);309 if (options.contentType)310 headers["content-type"] = String(options.contentType);311 else if (options.json)312 headers["content-type"] = "application/json";313 else if (options.path)314 headers["content-type"] = (0, import_mimeType.getMimeTypeForPath)(options.path) || "application/octet-stream";315 if (length && !("content-length" in headers))316 headers["content-length"] = String(length);317 await this._raceWithTargetClose(this._channel.fulfill({318 status: statusOption || 200,319 headers: (0, import_headers.headersObjectToArray)(headers),320 body,321 isBase64,322 fetchResponseUid323 }));324 }325 async continue(options = {}) {326 await this._handleRoute(async () => {327 this.request()._applyFallbackOverrides(options);328 await this._innerContinue(329 false330 /* isFallback */331 );332 });333 }334 _checkNotHandled() {335 if (!this._handlingPromise)336 throw new Error("Route is already handled!");337 }338 _reportHandled(done) {339 const chain = this._handlingPromise;340 this._handlingPromise = null;341 chain.resolve(done);342 }343 async _innerContinue(isFallback) {344 const options = this.request()._fallbackOverridesForContinue();345 return await this._raceWithTargetClose(this._channel.continue({346 url: options.url,347 method: options.method,348 headers: options.headers ? (0, import_headers.headersObjectToArray)(options.headers) : void 0,349 postData: options.postDataBuffer,350 isFallback351 }));352 }353}354class WebSocketRoute extends import_channelOwner.ChannelOwner {355 constructor(parent, type, guid, initializer) {356 super(parent, type, guid, initializer);357 this._connected = false;358 this._server = {359 onMessage: (handler) => {360 this._onServerMessage = handler;361 },362 onClose: (handler) => {363 this._onServerClose = handler;364 },365 connectToServer: () => {366 throw new Error(`connectToServer must be called on the page-side WebSocketRoute`);367 },368 url: () => {369 return this._initializer.url;370 },371 close: async (options = {}) => {372 await this._channel.closeServer({ ...options, wasClean: true }).catch(() => {373 });374 },375 send: (message) => {376 if ((0, import_rtti.isString)(message))377 this._channel.sendToServer({ message, isBase64: false }).catch(() => {378 });379 else380 this._channel.sendToServer({ message: message.toString("base64"), isBase64: true }).catch(() => {381 });382 },383 async [Symbol.asyncDispose]() {384 await this.close();385 }386 };387 this._channel.on("messageFromPage", ({ message, isBase64 }) => {388 if (this._onPageMessage)389 this._onPageMessage(isBase64 ? Buffer.from(message, "base64") : message);390 else if (this._connected)391 this._channel.sendToServer({ message, isBase64 }).catch(() => {392 });393 });394 this._channel.on("messageFromServer", ({ message, isBase64 }) => {395 if (this._onServerMessage)396 this._onServerMessage(isBase64 ? Buffer.from(message, "base64") : message);397 else398 this._channel.sendToPage({ message, isBase64 }).catch(() => {399 });400 });401 this._channel.on("closePage", ({ code, reason, wasClean }) => {402 if (this._onPageClose)403 this._onPageClose(code, reason);404 else405 this._channel.closeServer({ code, reason, wasClean }).catch(() => {406 });407 });408 this._channel.on("closeServer", ({ code, reason, wasClean }) => {409 if (this._onServerClose)410 this._onServerClose(code, reason);411 else412 this._channel.closePage({ code, reason, wasClean }).catch(() => {413 });414 });415 }416 static from(route) {417 return route._object;418 }419 url() {420 return this._initializer.url;421 }422 async close(options = {}) {423 await this._channel.closePage({ ...options, wasClean: true }).catch(() => {424 });425 }426 connectToServer() {427 if (this._connected)428 throw new Error("Already connected to the server");429 this._connected = true;430 this._channel.connect().catch(() => {431 });432 return this._server;433 }434 send(message) {435 if ((0, import_rtti.isString)(message))436 this._channel.sendToPage({ message, isBase64: false }).catch(() => {437 });438 else439 this._channel.sendToPage({ message: message.toString("base64"), isBase64: true }).catch(() => {440 });441 }442 onMessage(handler) {443 this._onPageMessage = handler;444 }445 onClose(handler) {446 this._onPageClose = handler;447 }448 async [Symbol.asyncDispose]() {449 await this.close();450 }451 async _afterHandle() {452 if (this._connected)453 return;454 await this._channel.ensureOpened().catch(() => {455 });456 }457}458class WebSocketRouteHandler {459 constructor(baseURL, url, handler) {460 this._baseURL = baseURL;461 this.url = url;462 this.handler = handler;463 }464 static prepareInterceptionPatterns(handlers) {465 const patterns = [];466 let all = false;467 for (const handler of handlers) {468 if ((0, import_rtti.isString)(handler.url))469 patterns.push({ glob: handler.url });470 else if ((0, import_rtti.isRegExp)(handler.url))471 patterns.push({ regexSource: handler.url.source, regexFlags: handler.url.flags });472 else473 all = true;474 }475 if (all)476 return [{ glob: "**/*" }];477 return patterns;478 }479 matches(wsURL) {480 return (0, import_urlMatch.urlMatches)(this._baseURL, wsURL, this.url, true);481 }482 async handle(webSocketRoute) {483 const handler = this.handler;484 await handler(webSocketRoute);485 await webSocketRoute._afterHandle();486 }487}488class Response extends import_channelOwner.ChannelOwner {489 constructor(parent, type, guid, initializer) {490 super(parent, type, guid, initializer);491 this._finishedPromise = new import_manualPromise.ManualPromise();492 this._provisionalHeaders = new RawHeaders(initializer.headers);493 this._request = Request.from(this._initializer.request);494 Object.assign(this._request._timing, this._initializer.timing);495 }496 static from(response) {497 return response._object;498 }499 static fromNullable(response) {500 return response ? Response.from(response) : null;501 }502 url() {503 return this._initializer.url;504 }505 ok() {506 return this._initializer.status === 0 || this._initializer.status >= 200 && this._initializer.status <= 299;507 }508 status() {509 return this._initializer.status;510 }511 statusText() {512 return this._initializer.statusText;513 }514 fromServiceWorker() {515 return this._initializer.fromServiceWorker;516 }517 /**518 * @deprecated519 */520 headers() {521 return this._provisionalHeaders.headers();522 }523 async _actualHeaders() {524 if (!this._actualHeadersPromise) {525 this._actualHeadersPromise = (async () => {526 return new RawHeaders((await this._channel.rawResponseHeaders()).headers);527 })();528 }529 return await this._actualHeadersPromise;530 }531 async allHeaders() {532 return (await this._actualHeaders()).headers();533 }534 async headersArray() {535 return (await this._actualHeaders()).headersArray().slice();536 }537 async headerValue(name) {538 return (await this._actualHeaders()).get(name);539 }540 async headerValues(name) {541 return (await this._actualHeaders()).getAll(name);542 }543 async finished() {544 return await this.request()._targetClosedScope().race(this._finishedPromise);545 }546 async body() {547 return (await this._channel.body()).binary;548 }549 async text() {550 const content = await this.body();551 return content.toString("utf8");552 }553 async json() {554 const content = await this.text();555 return JSON.parse(content);556 }557 request() {558 return this._request;559 }560 frame() {561 return this._request.frame();562 }563 async serverAddr() {564 return (await this._channel.serverAddr()).value || null;565 }566 async securityDetails() {567 return (await this._channel.securityDetails()).value || null;568 }569}570class WebSocket extends import_channelOwner.ChannelOwner {571 static from(webSocket) {572 return webSocket._object;573 }574 constructor(parent, type, guid, initializer) {575 super(parent, type, guid, initializer);576 this._isClosed = false;577 this._page = parent;578 this._channel.on("frameSent", (event) => {579 if (event.opcode === 1)580 this.emit(import_events.Events.WebSocket.FrameSent, { payload: event.data });581 else if (event.opcode === 2)582 this.emit(import_events.Events.WebSocket.FrameSent, { payload: Buffer.from(event.data, "base64") });583 });584 this._channel.on("frameReceived", (event) => {585 if (event.opcode === 1)586 this.emit(import_events.Events.WebSocket.FrameReceived, { payload: event.data });587 else if (event.opcode === 2)588 this.emit(import_events.Events.WebSocket.FrameReceived, { payload: Buffer.from(event.data, "base64") });589 });590 this._channel.on("socketError", ({ error }) => this.emit(import_events.Events.WebSocket.Error, error));591 this._channel.on("close", () => {592 this._isClosed = true;593 this.emit(import_events.Events.WebSocket.Close, this);594 });595 }596 url() {597 return this._initializer.url;598 }599 isClosed() {600 return this._isClosed;601 }602 async waitForEvent(event, optionsOrPredicate = {}) {603 return await this._wrapApiCall(async () => {604 const timeout = this._page._timeoutSettings.timeout(typeof optionsOrPredicate === "function" ? {} : optionsOrPredicate);605 const predicate = typeof optionsOrPredicate === "function" ? optionsOrPredicate : optionsOrPredicate.predicate;606 const waiter = import_waiter.Waiter.createForEvent(this, event);607 waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);608 if (event !== import_events.Events.WebSocket.Error)609 waiter.rejectOnEvent(this, import_events.Events.WebSocket.Error, new Error("Socket error"));610 if (event !== import_events.Events.WebSocket.Close)611 waiter.rejectOnEvent(this, import_events.Events.WebSocket.Close, new Error("Socket closed"));612 waiter.rejectOnEvent(this._page, import_events.Events.Page.Close, () => this._page._closeErrorWithReason());613 const result = await waiter.waitForEvent(this, event, predicate);614 waiter.dispose();615 return result;616 });617 }618}619function validateHeaders(headers) {620 for (const key of Object.keys(headers)) {621 const value = headers[key];622 if (!Object.is(value, void 0) && !(0, import_rtti.isString)(value))623 throw new Error(`Expected value of header "${key}" to be String, but "${typeof value}" is found.`);624 }625}626class RouteHandler {627 constructor(platform, baseURL, url, handler, times = Number.MAX_SAFE_INTEGER) {628 this.handledCount = 0;629 this._ignoreException = false;630 this._activeInvocations = /* @__PURE__ */ new Set();631 this._baseURL = baseURL;632 this._times = times;633 this.url = url;634 this.handler = handler;635 this._savedZone = platform.zones.current().pop();636 }637 static prepareInterceptionPatterns(handlers) {638 const patterns = [];639 let all = false;640 for (const handler of handlers) {641 if ((0, import_rtti.isString)(handler.url))642 patterns.push({ glob: handler.url });643 else if ((0, import_rtti.isRegExp)(handler.url))644 patterns.push({ regexSource: handler.url.source, regexFlags: handler.url.flags });645 else646 all = true;647 }648 if (all)649 return [{ glob: "**/*" }];650 return patterns;651 }652 matches(requestURL) {653 return (0, import_urlMatch.urlMatches)(this._baseURL, requestURL, this.url);654 }655 async handle(route) {656 return await this._savedZone.run(async () => this._handleImpl(route));657 }658 async _handleImpl(route) {659 const handlerInvocation = { complete: new import_manualPromise.ManualPromise(), route };660 this._activeInvocations.add(handlerInvocation);661 try {662 return await this._handleInternal(route);663 } catch (e) {664 if (this._ignoreException)665 return false;666 if ((0, import_errors.isTargetClosedError)(e)) {667 (0, import_stackTrace.rewriteErrorMessage)(e, `"${e.message}" while running route callback.668Consider awaiting \`await page.unrouteAll({ behavior: 'ignoreErrors' })\`669before the end of the test to ignore remaining routes in flight.`);670 }671 throw e;672 } finally {673 handlerInvocation.complete.resolve();674 this._activeInvocations.delete(handlerInvocation);675 }676 }677 async stop(behavior) {678 if (behavior === "ignoreErrors") {679 this._ignoreException = true;680 } else {681 const promises = [];682 for (const activation of this._activeInvocations) {683 if (!activation.route._didThrow)684 promises.push(activation.complete);685 }686 await Promise.all(promises);687 }688 }689 async _handleInternal(route) {690 ++this.handledCount;691 const handledPromise = route._startHandling();692 const handler = this.handler;693 const [handled] = await Promise.all([694 handledPromise,695 handler(route, route.request())696 ]);697 return handled;698 }699 willExpire() {700 return this.handledCount + 1 >= this._times;701 }702}703class RawHeaders {704 constructor(headers) {705 this._headersMap = new import_multimap.MultiMap();706 this._headersArray = headers;707 for (const header of headers)708 this._headersMap.set(header.name.toLowerCase(), header.value);709 }710 static _fromHeadersObjectLossy(headers) {711 const headersArray = Object.entries(headers).map(([name, value]) => ({712 name,713 value714 })).filter((header) => header.value !== void 0);715 return new RawHeaders(headersArray);716 }717 get(name) {718 const values = this.getAll(name);719 if (!values || !values.length)720 return null;721 return values.join(name.toLowerCase() === "set-cookie" ? "\n" : ", ");722 }723 getAll(name) {724 return [...this._headersMap.get(name.toLowerCase())];725 }726 headers() {727 const result = {};728 for (const name of this._headersMap.keys())729 result[name] = this.get(name);730 return result;731 }732 headersArray() {733 return this._headersArray;734 }735}736// Annotate the CommonJS export names for ESM import in node:7370 && (module.exports = {738 RawHeaders,739 Request,740 Response,741 Route,742 RouteHandler,743 WebSocket,744 WebSocketRoute,745 WebSocketRouteHandler,746 validateHeaders747});748 