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
1import { createParser } from "eventsource-parser";2class ErrorEvent extends Event {3 /**4 * Constructs a new `ErrorEvent` instance. This is typically not called directly,5 * but rather emitted by the `EventSource` object when an error occurs.6 *7 * @param type - The type of the event (should be "error")8 * @param errorEventInitDict - Optional properties to include in the error event9 */10 constructor(type, errorEventInitDict) {11 var _a, _b;12 super(type), this.code = (_a = errorEventInitDict == null ? void 0 : errorEventInitDict.code) != null ? _a : void 0, this.message = (_b = errorEventInitDict == null ? void 0 : errorEventInitDict.message) != null ? _b : void 0;13 }14 /**15 * Node.js "hides" the `message` and `code` properties of the `ErrorEvent` instance,16 * when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,17 * we explicitly include the properties in the `inspect` method.18 *19 * This is automatically called by Node.js when you `console.log` an instance of this class.20 *21 * @param _depth - The current depth22 * @param options - The options passed to `util.inspect`23 * @param inspect - The inspect function to use (prevents having to import it from `util`)24 * @returns A string representation of the error25 */26 [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {27 return inspect(inspectableError(this), options);28 }29 /**30 * Deno "hides" the `message` and `code` properties of the `ErrorEvent` instance,31 * when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,32 * we explicitly include the properties in the `inspect` method.33 *34 * This is automatically called by Deno when you `console.log` an instance of this class.35 *36 * @param inspect - The inspect function to use (prevents having to import it from `util`)37 * @param options - The options passed to `Deno.inspect`38 * @returns A string representation of the error39 */40 [Symbol.for("Deno.customInspect")](inspect, options) {41 return inspect(inspectableError(this), options);42 }43}44function syntaxError(message) {45 const DomException = globalThis.DOMException;46 return typeof DomException == "function" ? new DomException(message, "SyntaxError") : new SyntaxError(message);47}48function flattenError(err) {49 return err instanceof Error ? "errors" in err && Array.isArray(err.errors) ? err.errors.map(flattenError).join(", ") : "cause" in err && err.cause instanceof Error ? `${err}: ${flattenError(err.cause)}` : err.message : `${err}`;50}51function inspectableError(err) {52 return {53 type: err.type,54 message: err.message,55 code: err.code,56 defaultPrevented: err.defaultPrevented,57 cancelable: err.cancelable,58 timeStamp: err.timeStamp59 };60}61var __typeError = (msg) => {62 throw TypeError(msg);63}, __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg), __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value), __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value), __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method), _readyState, _url, _redirectUrl, _withCredentials, _fetch, _reconnectInterval, _reconnectTimer, _lastEventId, _controller, _parser, _onError, _onMessage, _onOpen, _EventSource_instances, connect_fn, _onFetchResponse, _onFetchError, getRequestOptions_fn, _onEvent, _onRetryChange, failConnection_fn, scheduleReconnect_fn, _reconnect;64class EventSource extends EventTarget {65 constructor(url, eventSourceInitDict) {66 var _a, _b;67 super(), __privateAdd(this, _EventSource_instances), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, __privateAdd(this, _readyState), __privateAdd(this, _url), __privateAdd(this, _redirectUrl), __privateAdd(this, _withCredentials), __privateAdd(this, _fetch), __privateAdd(this, _reconnectInterval), __privateAdd(this, _reconnectTimer), __privateAdd(this, _lastEventId, null), __privateAdd(this, _controller), __privateAdd(this, _parser), __privateAdd(this, _onError, null), __privateAdd(this, _onMessage, null), __privateAdd(this, _onOpen, null), __privateAdd(this, _onFetchResponse, async (response) => {68 var _a2;69 __privateGet(this, _parser).reset();70 const { body, redirected, status, headers } = response;71 if (status === 204) {72 __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();73 return;74 }75 if (redirected ? __privateSet(this, _redirectUrl, new URL(response.url)) : __privateSet(this, _redirectUrl, void 0), status !== 200) {76 __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, `Non-200 status code (${status})`, status);77 return;78 }79 if (!(headers.get("content-type") || "").startsWith("text/event-stream")) {80 __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, 'Invalid content type, expected "text/event-stream"', status);81 return;82 }83 if (__privateGet(this, _readyState) === this.CLOSED)84 return;85 __privateSet(this, _readyState, this.OPEN);86 const openEvent = new Event("open");87 if ((_a2 = __privateGet(this, _onOpen)) == null || _a2.call(this, openEvent), this.dispatchEvent(openEvent), typeof body != "object" || !body || !("getReader" in body)) {88 __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Invalid response body, expected a web ReadableStream", status), this.close();89 return;90 }91 const decoder = new TextDecoder(), reader = body.getReader();92 let open = !0;93 do {94 const { done, value } = await reader.read();95 value && __privateGet(this, _parser).feed(decoder.decode(value, { stream: !done })), done && (open = !1, __privateGet(this, _parser).reset(), __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this));96 } while (open);97 }), __privateAdd(this, _onFetchError, (err) => {98 __privateSet(this, _controller, void 0), !(err.name === "AbortError" || err.type === "aborted") && __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this, flattenError(err));99 }), __privateAdd(this, _onEvent, (event) => {100 typeof event.id == "string" && __privateSet(this, _lastEventId, event.id);101 const messageEvent = new MessageEvent(event.event || "message", {102 data: event.data,103 origin: __privateGet(this, _redirectUrl) ? __privateGet(this, _redirectUrl).origin : __privateGet(this, _url).origin,104 lastEventId: event.id || ""105 });106 __privateGet(this, _onMessage) && (!event.event || event.event === "message") && __privateGet(this, _onMessage).call(this, messageEvent), this.dispatchEvent(messageEvent);107 }), __privateAdd(this, _onRetryChange, (value) => {108 __privateSet(this, _reconnectInterval, value);109 }), __privateAdd(this, _reconnect, () => {110 __privateSet(this, _reconnectTimer, void 0), __privateGet(this, _readyState) === this.CONNECTING && __privateMethod(this, _EventSource_instances, connect_fn).call(this);111 });112 try {113 if (url instanceof URL)114 __privateSet(this, _url, url);115 else if (typeof url == "string")116 __privateSet(this, _url, new URL(url, getBaseURL()));117 else118 throw new Error("Invalid URL");119 } catch {120 throw syntaxError("An invalid or illegal string was specified");121 }122 __privateSet(this, _parser, createParser({123 onEvent: __privateGet(this, _onEvent),124 onRetry: __privateGet(this, _onRetryChange)125 })), __privateSet(this, _readyState, this.CONNECTING), __privateSet(this, _reconnectInterval, 3e3), __privateSet(this, _fetch, (_a = eventSourceInitDict == null ? void 0 : eventSourceInitDict.fetch) != null ? _a : globalThis.fetch), __privateSet(this, _withCredentials, (_b = eventSourceInitDict == null ? void 0 : eventSourceInitDict.withCredentials) != null ? _b : !1), __privateMethod(this, _EventSource_instances, connect_fn).call(this);126 }127 /**128 * Returns the state of this EventSource object's connection. It can have the values described below.129 *130 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)131 *132 * Note: typed as `number` instead of `0 | 1 | 2` for compatibility with the `EventSource` interface,133 * defined in the TypeScript `dom` library.134 *135 * @public136 */137 get readyState() {138 return __privateGet(this, _readyState);139 }140 /**141 * Returns the URL providing the event stream.142 *143 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)144 *145 * @public146 */147 get url() {148 return __privateGet(this, _url).href;149 }150 /**151 * Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.152 *153 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)154 */155 get withCredentials() {156 return __privateGet(this, _withCredentials);157 }158 /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */159 get onerror() {160 return __privateGet(this, _onError);161 }162 set onerror(value) {163 __privateSet(this, _onError, value);164 }165 /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */166 get onmessage() {167 return __privateGet(this, _onMessage);168 }169 set onmessage(value) {170 __privateSet(this, _onMessage, value);171 }172 /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */173 get onopen() {174 return __privateGet(this, _onOpen);175 }176 set onopen(value) {177 __privateSet(this, _onOpen, value);178 }179 addEventListener(type, listener, options) {180 const listen = listener;181 super.addEventListener(type, listen, options);182 }183 removeEventListener(type, listener, options) {184 const listen = listener;185 super.removeEventListener(type, listen, options);186 }187 /**188 * Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.189 *190 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)191 *192 * @public193 */194 close() {195 __privateGet(this, _reconnectTimer) && clearTimeout(__privateGet(this, _reconnectTimer)), __privateGet(this, _readyState) !== this.CLOSED && (__privateGet(this, _controller) && __privateGet(this, _controller).abort(), __privateSet(this, _readyState, this.CLOSED), __privateSet(this, _controller, void 0));196 }197}198_readyState = /* @__PURE__ */ new WeakMap(), _url = /* @__PURE__ */ new WeakMap(), _redirectUrl = /* @__PURE__ */ new WeakMap(), _withCredentials = /* @__PURE__ */ new WeakMap(), _fetch = /* @__PURE__ */ new WeakMap(), _reconnectInterval = /* @__PURE__ */ new WeakMap(), _reconnectTimer = /* @__PURE__ */ new WeakMap(), _lastEventId = /* @__PURE__ */ new WeakMap(), _controller = /* @__PURE__ */ new WeakMap(), _parser = /* @__PURE__ */ new WeakMap(), _onError = /* @__PURE__ */ new WeakMap(), _onMessage = /* @__PURE__ */ new WeakMap(), _onOpen = /* @__PURE__ */ new WeakMap(), _EventSource_instances = /* @__PURE__ */ new WeakSet(), /**199* Connect to the given URL and start receiving events200*201* @internal202*/203connect_fn = function() {204 __privateSet(this, _readyState, this.CONNECTING), __privateSet(this, _controller, new AbortController()), __privateGet(this, _fetch)(__privateGet(this, _url), __privateMethod(this, _EventSource_instances, getRequestOptions_fn).call(this)).then(__privateGet(this, _onFetchResponse)).catch(__privateGet(this, _onFetchError));205}, _onFetchResponse = /* @__PURE__ */ new WeakMap(), _onFetchError = /* @__PURE__ */ new WeakMap(), /**206* Get request options for the `fetch()` request207*208* @returns The request options209* @internal210*/211getRequestOptions_fn = function() {212 var _a;213 const init = {214 // [spec] Let `corsAttributeState` be `Anonymous`…215 // [spec] …will have their mode set to "cors"…216 mode: "cors",217 redirect: "follow",218 headers: { Accept: "text/event-stream", ...__privateGet(this, _lastEventId) ? { "Last-Event-ID": __privateGet(this, _lastEventId) } : void 0 },219 cache: "no-store",220 signal: (_a = __privateGet(this, _controller)) == null ? void 0 : _a.signal221 };222 return "window" in globalThis && (init.credentials = this.withCredentials ? "include" : "same-origin"), init;223}, _onEvent = /* @__PURE__ */ new WeakMap(), _onRetryChange = /* @__PURE__ */ new WeakMap(), /**224* Handles the process referred to in the EventSource specification as "failing a connection".225*226* @param error - The error causing the connection to fail227* @param code - The HTTP status code, if available228* @internal229*/230failConnection_fn = function(message, code) {231 var _a;232 __privateGet(this, _readyState) !== this.CLOSED && __privateSet(this, _readyState, this.CLOSED);233 const errorEvent = new ErrorEvent("error", { code, message });234 (_a = __privateGet(this, _onError)) == null || _a.call(this, errorEvent), this.dispatchEvent(errorEvent);235}, /**236* Schedules a reconnection attempt against the EventSource endpoint.237*238* @param message - The error causing the connection to fail239* @param code - The HTTP status code, if available240* @internal241*/242scheduleReconnect_fn = function(message, code) {243 var _a;244 if (__privateGet(this, _readyState) === this.CLOSED)245 return;246 __privateSet(this, _readyState, this.CONNECTING);247 const errorEvent = new ErrorEvent("error", { code, message });248 (_a = __privateGet(this, _onError)) == null || _a.call(this, errorEvent), this.dispatchEvent(errorEvent), __privateSet(this, _reconnectTimer, setTimeout(__privateGet(this, _reconnect), __privateGet(this, _reconnectInterval)));249}, _reconnect = /* @__PURE__ */ new WeakMap(), /**250* ReadyState representing an EventSource currently trying to connect251*252* @public253*/254EventSource.CONNECTING = 0, /**255* ReadyState representing an EventSource connection that is open (eg connected)256*257* @public258*/259EventSource.OPEN = 1, /**260* ReadyState representing an EventSource connection that is closed (eg disconnected)261*262* @public263*/264EventSource.CLOSED = 2;265function getBaseURL() {266 const doc = "document" in globalThis ? globalThis.document : void 0;267 return doc && typeof doc == "object" && "baseURI" in doc && typeof doc.baseURI == "string" ? doc.baseURI : void 0;268}269export {270 ErrorEvent,271 EventSource272};273//# sourceMappingURL=index.js.map274 