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/** @import { ComponentType, SvelteComponent, Component } from 'svelte' */2/** @import { Csp, RenderOutput } from '#server' */3/** @import { Store } from '#shared' */4export { FILENAME, HMR } from '../../constants.js';5import { attr, clsx, to_class, to_style } from '../shared/attributes.js';6import { is_promise, noop } from '../shared/utils.js';7import { subscribe_to_store } from '../../store/utils.js';8import {9 UNINITIALIZED,10 ELEMENT_PRESERVE_ATTRIBUTE_CASE,11 ELEMENT_IS_NAMESPACED,12 ELEMENT_IS_INPUT13} from '../../constants.js';14import { escape_html } from '../../escaping.js';15import { DEV } from 'esm-env';16import { EMPTY_COMMENT, BLOCK_OPEN, BLOCK_OPEN_ELSE } from './hydration.js';17import { validate_store } from '../shared/validate.js';18import {19 is_boolean_attribute,20 is_raw_text_element,21 is_void,22 REGEX_VALID_TAG_NAME23} from '../../utils.js';24import { Renderer } from './renderer.js';25import * as e from './errors.js';26import { ssr_context } from './context.js';27 28// https://html.spec.whatwg.org/multipage/syntax.html#attributes-229// https://infra.spec.whatwg.org/#noncharacter30const INVALID_ATTR_NAME_CHAR_REGEX =31 /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;32 33/**34 * @param {Renderer} renderer35 * @param {string} tag36 * @param {() => void} attributes_fn37 * @param {() => void} children_fn38 * @returns {void}39 */40export function element(renderer, tag, attributes_fn = noop, children_fn = noop) {41 renderer.push('<!---->');42 43 if (tag) {44 if (!REGEX_VALID_TAG_NAME.test(tag)) {45 e.dynamic_element_invalid_tag(tag);46 }47 renderer.push(`<${tag}`);48 attributes_fn();49 renderer.push(`>`);50 51 if (!is_void(tag)) {52 children_fn();53 if (!is_raw_text_element(tag)) {54 renderer.push(EMPTY_COMMENT);55 }56 renderer.push(`</${tag}>`);57 }58 }59 60 renderer.push('<!---->');61}62 63/**64 * Only available on the server and when compiling with the `server` option.65 * Takes a component and returns an object with `body` and `head` properties on it, which you can use to populate the HTML when server-rendering your app.66 * @template {Record<string, any>} Props67 * @param {Component<Props> | ComponentType<SvelteComponent<Props>>} component68 * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp; transformError?: (error: unknown) => unknown }} [options]69 * @returns {RenderOutput}70 */71export function render(component, options = {}) {72 if (options.csp?.hash && options.csp.nonce) {73 e.invalid_csp();74 }75 return Renderer.render(/** @type {Component<Props>} */ (component), options);76}77 78/**79 * @param {string} hash80 * @param {Renderer} renderer81 * @param {(renderer: Renderer) => Promise<void> | void} fn82 * @returns {void}83 */84export function head(hash, renderer, fn) {85 renderer.head((renderer) => {86 renderer.push(`<!--${hash}-->`);87 renderer.child(fn);88 renderer.push(EMPTY_COMMENT);89 });90}91 92/**93 * @param {Renderer} renderer94 * @param {boolean} is_html95 * @param {Record<string, string>} props96 * @param {() => void} component97 * @param {boolean} dynamic98 * @returns {void}99 */100export function css_props(renderer, is_html, props, component, dynamic = false) {101 const styles = style_object_to_string(props);102 103 if (is_html) {104 renderer.push(`<svelte-css-wrapper style="display: contents; ${styles}">`);105 } else {106 renderer.push(`<g style="${styles}">`);107 }108 109 component();110 111 if (!dynamic) {112 renderer.push('<!---->');113 }114 115 if (is_html) {116 renderer.push('</svelte-css-wrapper>');117 } else {118 renderer.push('</g>');119 }120}121 122/**123 * @param {Record<string, unknown>} attrs124 * @param {string} [css_hash]125 * @param {Record<string, boolean>} [classes]126 * @param {Record<string, string>} [styles]127 * @param {number} [flags]128 * @returns {string}129 */130export function attributes(attrs, css_hash, classes, styles, flags = 0) {131 if (styles) {132 attrs.style = to_style(attrs.style, styles);133 }134 135 if (attrs.class) {136 attrs.class = clsx(attrs.class);137 }138 139 if (css_hash || classes) {140 attrs.class = to_class(attrs.class, css_hash, classes);141 }142 143 let attr_str = '';144 let name;145 146 const is_html = (flags & ELEMENT_IS_NAMESPACED) === 0;147 const lowercase = (flags & ELEMENT_PRESERVE_ATTRIBUTE_CASE) === 0;148 const is_input = (flags & ELEMENT_IS_INPUT) !== 0;149 150 for (name of Object.keys(attrs)) {151 // omit functions, internal svelte properties and invalid attribute names152 if (typeof attrs[name] === 'function') continue;153 if (name[0] === '$' && name[1] === '$') continue; // faster than name.startsWith('$$')154 if (name === '' || INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;155 156 var value = attrs[name];157 var lower = name.toLowerCase();158 159 if (lowercase) name = lower;160 161 // omit event handler attributes162 if (lower.length > 2 && lower.startsWith('on')) continue;163 164 if (is_input) {165 if (name === 'defaultvalue' || name === 'defaultchecked') {166 name = name === 'defaultvalue' ? 'value' : 'checked';167 if (attrs[name]) continue;168 }169 }170 171 attr_str += attr(name, value, is_html && is_boolean_attribute(name));172 }173 174 return attr_str;175}176 177/**178 * @param {Record<string, unknown>[]} props179 * @returns {Record<string, unknown>}180 */181export function spread_props(props) {182 /** @type {Record<string, unknown>} */183 const merged_props = {};184 let key;185 186 for (let i = 0; i < props.length; i++) {187 const obj = props[i];188 if (obj == null) continue;189 for (key of Object.keys(obj)) {190 const desc = Object.getOwnPropertyDescriptor(obj, key);191 if (desc) {192 Object.defineProperty(merged_props, key, desc);193 } else {194 merged_props[key] = obj[key];195 }196 }197 }198 return merged_props;199}200 201/**202 * @param {unknown} value203 * @returns {string}204 */205export function stringify(value) {206 return typeof value === 'string' ? value : value == null ? '' : value + '';207}208 209/** @param {Record<string, string>} style_object */210function style_object_to_string(style_object) {211 return Object.keys(style_object)212 .filter(/** @param {any} key */ (key) => style_object[key] != null && style_object[key] !== '')213 .map(/** @param {any} key */ (key) => `${key}: ${escape_html(style_object[key], true)};`)214 .join(' ');215}216 217/**218 * @param {any} value219 * @param {string | undefined} [hash]220 * @param {Record<string, boolean>} [directives]221 */222export function attr_class(value, hash, directives) {223 var result = to_class(value, hash, directives);224 return result ? ` class="${escape_html(result, true)}"` : '';225}226 227/**228 * @param {any} value229 * @param {Record<string,any>|[Record<string,any>,Record<string,any>]} [directives]230 */231export function attr_style(value, directives) {232 var result = to_style(value, directives);233 return result ? ` style="${escape_html(result, true)}"` : '';234}235 236/**237 * @template V238 * @param {Record<string, [any, any, any]>} store_values239 * @param {string} store_name240 * @param {Store<V> | null | undefined} store241 * @returns {V}242 */243export function store_get(store_values, store_name, store) {244 if (DEV) {245 validate_store(store, store_name.slice(1));246 }247 248 // it could be that someone eagerly updates the store in the instance script, so249 // we should only reuse the store value in the template250 if (store_name in store_values && store_values[store_name][0] === store) {251 return store_values[store_name][2];252 }253 254 store_values[store_name]?.[1](); // if store was switched, unsubscribe from old store255 store_values[store_name] = [store, null, undefined];256 const unsub = subscribe_to_store(257 store,258 /** @param {any} v */ (v) => (store_values[store_name][2] = v)259 );260 store_values[store_name][1] = unsub;261 return store_values[store_name][2];262}263 264/**265 * Sets the new value of a store and returns that value.266 * @template V267 * @param {Store<V>} store268 * @param {V} value269 * @returns {V}270 */271export function store_set(store, value) {272 store.set(value);273 return value;274}275 276/**277 * Updates a store with a new value.278 * @template V279 * @param {Record<string, [any, any, any]>} store_values280 * @param {string} store_name281 * @param {Store<V>} store282 * @param {any} expression283 */284export function store_mutate(store_values, store_name, store, expression) {285 store_set(store, store_get(store_values, store_name, store));286 return expression;287}288 289/**290 * @param {Record<string, [any, any, any]>} store_values291 * @param {string} store_name292 * @param {Store<number>} store293 * @param {1 | -1} [d]294 * @returns {number}295 */296export function update_store(store_values, store_name, store, d = 1) {297 let store_value = store_get(store_values, store_name, store);298 store.set(store_value + d);299 return store_value;300}301 302/**303 * @param {Record<string, [any, any, any]>} store_values304 * @param {string} store_name305 * @param {Store<number>} store306 * @param {1 | -1} [d]307 * @returns {number}308 */309export function update_store_pre(store_values, store_name, store, d = 1) {310 const value = store_get(store_values, store_name, store) + d;311 store.set(value);312 return value;313}314 315/** @param {Record<string, [any, any, any]>} store_values */316export function unsubscribe_stores(store_values) {317 for (const store_name of Object.keys(store_values)) {318 store_values[store_name][1]();319 }320}321 322/**323 * @param {Renderer} renderer324 * @param {Record<string, any>} $$props325 * @param {string} name326 * @param {Record<string, unknown>} slot_props327 * @param {null | (() => void)} fallback_fn328 * @returns {void}329 */330export function slot(renderer, $$props, name, slot_props, fallback_fn) {331 var slot_fn = $$props.$$slots?.[name];332 // Interop: Can use snippets to fill slots333 if (slot_fn === true) {334 slot_fn = $$props[name === 'default' ? 'children' : name];335 }336 337 if (slot_fn !== undefined) {338 slot_fn(renderer, slot_props);339 } else {340 fallback_fn?.();341 }342}343 344/**345 * @param {Record<string, unknown>} props346 * @param {string[]} rest347 * @returns {Record<string, unknown>}348 */349export function rest_props(props, rest) {350 /** @type {Record<string, unknown>} */351 const rest_props = {};352 let key;353 for (key of Object.keys(props)) {354 if (!rest.includes(key)) {355 rest_props[key] = props[key];356 }357 }358 return rest_props;359}360 361/**362 * @param {Record<string, unknown>} props363 * @returns {Record<string, unknown>}364 */365export function sanitize_props(props) {366 const { children, $$slots, ...sanitized } = props;367 return sanitized;368}369 370/**371 * @param {Record<string, any>} props372 * @returns {Record<string, boolean>}373 */374export function sanitize_slots(props) {375 /** @type {Record<string, boolean>} */376 const sanitized = {};377 if (props.children) sanitized.default = true;378 for (const key of Object.keys(props.$$slots || {})) {379 sanitized[key] = true;380 }381 return sanitized;382}383 384/**385 * Legacy mode: If the prop has a fallback and is bound in the386 * parent component, propagate the fallback value upwards.387 * @param {Record<string, unknown>} props_parent388 * @param {Record<string, unknown>} props_now389 */390export function bind_props(props_parent, props_now) {391 for (const key of Object.keys(props_now)) {392 const initial_value = props_parent[key];393 const value = props_now[key];394 if (395 initial_value === undefined &&396 value !== undefined &&397 Object.getOwnPropertyDescriptor(props_parent, key)?.set398 ) {399 props_parent[key] = value;400 }401 }402}403 404/**405 * @template V406 * @param {Renderer} renderer407 * @param {Promise<V>} promise408 * @param {null | (() => void)} pending_fn409 * @param {(value: V) => void} then_fn410 * @returns {void}411 */412function await_block(renderer, promise, pending_fn, then_fn) {413 if (is_promise(promise)) {414 renderer.push(BLOCK_OPEN);415 promise.then(null, noop);416 if (pending_fn !== null) {417 pending_fn();418 }419 } else if (then_fn !== null) {420 renderer.push(BLOCK_OPEN_ELSE);421 then_fn(promise);422 }423}424 425export { await_block as await };426 427/** @param {any} array_like_or_iterator */428export function ensure_array_like(array_like_or_iterator) {429 if (array_like_or_iterator) {430 return array_like_or_iterator.length !== undefined431 ? array_like_or_iterator432 : Array.from(array_like_or_iterator);433 }434 return [];435}436 437/**438 * @template V439 * @param {() => V} get_value440 */441export function once(get_value) {442 let value = /** @type {V} */ (UNINITIALIZED);443 return () => {444 if (value === UNINITIALIZED) {445 value = get_value();446 }447 return value;448 };449}450 451/**452 * Create an unique ID453 * @param {Renderer} renderer454 * @returns {string}455 */456export function props_id(renderer) {457 const uid = renderer.global.uid();458 renderer.push('<!--$' + uid + '-->');459 return uid;460}461 462export { attr, clsx };463 464export { html } from './blocks/html.js';465 466export { save } from './context.js';467 468export { push_element, pop_element, validate_snippet_args } from './dev.js';469 470export { snapshot } from '../shared/clone.js';471 472export { fallback, to_array, exclude_from_object } from '../shared/utils.js';473 474export {475 invalid_default_snippet,476 validate_dynamic_element_tag,477 validate_void_dynamic_element,478 prevent_snippet_stringification479} from '../shared/validate.js';480 481export { escape_html as escape };482 483/**484 * @template T485 * @param {()=>T} fn486 * @returns {(new_value?: T) => (T | void)}487 */488export function derived(fn) {489 // deriveds created during render are memoized,490 // deriveds created outside (e.g. SvelteKit `page` stuff) are not491 const get_value = ssr_context === null ? fn : once(fn);492 493 /** @type {T | undefined} */494 let updated_value;495 496 return function (new_value) {497 if (arguments.length === 0) {498 return updated_value ?? get_value();499 }500 501 updated_value = new_value;502 return updated_value;503 };504}505 506/**507 * @template {number | bigint} T508 * @param {(value?: T) => T} derived509 * @param {1 | -1} [d]510 * @returns {T}511 */512export function update_derived(derived, d = 1) {513 const value = derived();514 let increase = typeof value === 'bigint' ? BigInt(d) : d;515 // for some reason TS is mad even if T is always number or bigint516 derived(value + /** @type {*} */ (increase));517 return value;518}519 520/**521 * @template {number | bigint} T522 * @param {(value?: T) => T} derived523 * @param {1 | -1} [d]524 * @returns {T}525 */526export function update_derived_pre(derived, d = 1) {527 const old_value = derived();528 let increase = typeof old_value === 'bigint' ? BigInt(d) : d;529 // for some reason TS is mad even if T is always number or bigint530 const value = old_value + /** @type {*} */ (increase);531 derived(value);532 return value;533}534 535/**536 * @template T537 * @param {()=>T} fn538 */539export function async_derived(fn) {540 return Promise.resolve(fn()).then((value) => {541 return () => value;542 });543}544 