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
template.js402 linesDownload Raw Back to dom
1/** @import { Effect, EffectNodes, TemplateNode } from '#client' */2/** @import { TemplateStructure } from './types' */3import { hydrate_next, hydrate_node, hydrating, set_hydrate_node } from './hydration.js';4import {5	create_text,6	get_first_child,7	get_next_sibling,8	is_firefox,9	create_element,10	create_fragment,11	create_comment,12	set_attribute,13	merge_text_nodes14} from './operations.js';15import { create_fragment_from_html } from './reconciler.js';16import { active_effect } from '../runtime.js';17import {18	NAMESPACE_MATHML,19	NAMESPACE_SVG,20	TEMPLATE_FRAGMENT,21	TEMPLATE_USE_IMPORT_NODE,22	TEMPLATE_USE_MATHML,23	TEMPLATE_USE_SVG24} from '../../../constants.js';25import {26	COMMENT_NODE,27	DOCUMENT_FRAGMENT_NODE,28	IS_XHTML,29	REACTION_RAN,30	TEXT_NODE31} from '#client/constants';32 33const TEMPLATE_TAG = IS_XHTML ? 'template' : 'TEMPLATE';34const SCRIPT_TAG = IS_XHTML ? 'script' : 'SCRIPT';35 36/**37 * @param {TemplateNode} start38 * @param {TemplateNode | null} end39 */40export function assign_nodes(start, end) {41	var effect = /** @type {Effect} */ (active_effect);42	if (effect.nodes === null) {43		effect.nodes = { start, end, a: null, t: null };44	}45}46 47/**48 * @param {string} content49 * @param {number} flags50 * @returns {() => Node | Node[]}51 */52/*#__NO_SIDE_EFFECTS__*/53export function from_html(content, flags) {54	var is_fragment = (flags & TEMPLATE_FRAGMENT) !== 0;55	var use_import_node = (flags & TEMPLATE_USE_IMPORT_NODE) !== 0;56 57	/** @type {Node} */58	var node;59 60	/**61	 * Whether or not the first item is a text/element node. If not, we need to62	 * create an additional comment node to act as `effect.nodes.start`63	 */64	var has_start = !content.startsWith('<!>');65 66	return () => {67		if (hydrating) {68			assign_nodes(hydrate_node, null);69			return hydrate_node;70		}71 72		if (node === undefined) {73			node = create_fragment_from_html(has_start ? content : '<!>' + content);74			if (!is_fragment) node = /** @type {TemplateNode} */ (get_first_child(node));75		}76 77		var clone = /** @type {TemplateNode} */ (78			use_import_node || is_firefox ? document.importNode(node, true) : node.cloneNode(true)79		);80 81		if (is_fragment) {82			var start = /** @type {TemplateNode} */ (get_first_child(clone));83			var end = /** @type {TemplateNode} */ (clone.lastChild);84 85			assign_nodes(start, end);86		} else {87			assign_nodes(clone, clone);88		}89 90		return clone;91	};92}93 94/**95 * @param {string} content96 * @param {number} flags97 * @param {'svg' | 'math'} ns98 * @returns {() => Node | Node[]}99 */100/*#__NO_SIDE_EFFECTS__*/101function from_namespace(content, flags, ns = 'svg') {102	/**103	 * Whether or not the first item is a text/element node. If not, we need to104	 * create an additional comment node to act as `effect.nodes.start`105	 */106	var has_start = !content.startsWith('<!>');107 108	var is_fragment = (flags & TEMPLATE_FRAGMENT) !== 0;109	var wrapped = `<${ns}>${has_start ? content : '<!>' + content}</${ns}>`;110 111	/** @type {Element | DocumentFragment} */112	var node;113 114	return () => {115		if (hydrating) {116			assign_nodes(hydrate_node, null);117			return hydrate_node;118		}119 120		if (!node) {121			var fragment = /** @type {DocumentFragment} */ (create_fragment_from_html(wrapped));122			var root = /** @type {Element} */ (get_first_child(fragment));123 124			if (is_fragment) {125				node = document.createDocumentFragment();126				while (get_first_child(root)) {127					node.appendChild(/** @type {TemplateNode} */ (get_first_child(root)));128				}129			} else {130				node = /** @type {Element} */ (get_first_child(root));131			}132		}133 134		var clone = /** @type {TemplateNode} */ (node.cloneNode(true));135 136		if (is_fragment) {137			var start = /** @type {TemplateNode} */ (get_first_child(clone));138			var end = /** @type {TemplateNode} */ (clone.lastChild);139 140			assign_nodes(start, end);141		} else {142			assign_nodes(clone, clone);143		}144 145		return clone;146	};147}148 149/**150 * @param {string} content151 * @param {number} flags152 */153/*#__NO_SIDE_EFFECTS__*/154export function from_svg(content, flags) {155	return from_namespace(content, flags, 'svg');156}157 158/**159 * @param {string} content160 * @param {number} flags161 */162/*#__NO_SIDE_EFFECTS__*/163export function from_mathml(content, flags) {164	return from_namespace(content, flags, 'math');165}166 167/**168 * @param {TemplateStructure[]} structure169 * @param {typeof NAMESPACE_SVG | typeof NAMESPACE_MATHML | undefined} [ns]170 */171function fragment_from_tree(structure, ns) {172	var fragment = create_fragment();173 174	for (var item of structure) {175		if (typeof item === 'string') {176			fragment.append(create_text(item));177			continue;178		}179 180		// if `preserveComments === true`, comments are represented as `['// <data>']`181		if (item === undefined || item[0][0] === '/') {182			fragment.append(create_comment(item ? item[0].slice(3) : ''));183			continue;184		}185 186		const [name, attributes, ...children] = item;187 188		const namespace = name === 'svg' ? NAMESPACE_SVG : name === 'math' ? NAMESPACE_MATHML : ns;189 190		var element = create_element(name, namespace, attributes?.is);191 192		for (var key in attributes) {193			set_attribute(element, key, attributes[key]);194		}195 196		if (children.length > 0) {197			var target =198				element.nodeName === TEMPLATE_TAG199					? /** @type {HTMLTemplateElement} */ (element).content200					: element;201 202			target.append(203				fragment_from_tree(children, element.nodeName === 'foreignObject' ? undefined : namespace)204			);205		}206 207		fragment.append(element);208	}209 210	return fragment;211}212 213/**214 * @param {TemplateStructure[]} structure215 * @param {number} flags216 * @returns {() => Node | Node[]}217 */218/*#__NO_SIDE_EFFECTS__*/219export function from_tree(structure, flags) {220	var is_fragment = (flags & TEMPLATE_FRAGMENT) !== 0;221	var use_import_node = (flags & TEMPLATE_USE_IMPORT_NODE) !== 0;222 223	/** @type {Node} */224	var node;225 226	return () => {227		if (hydrating) {228			assign_nodes(hydrate_node, null);229			return hydrate_node;230		}231 232		if (node === undefined) {233			const ns =234				(flags & TEMPLATE_USE_SVG) !== 0235					? NAMESPACE_SVG236					: (flags & TEMPLATE_USE_MATHML) !== 0237						? NAMESPACE_MATHML238						: undefined;239 240			node = fragment_from_tree(structure, ns);241			if (!is_fragment) node = /** @type {TemplateNode} */ (get_first_child(node));242		}243 244		var clone = /** @type {TemplateNode} */ (245			use_import_node || is_firefox ? document.importNode(node, true) : node.cloneNode(true)246		);247 248		if (is_fragment) {249			var start = /** @type {TemplateNode} */ (get_first_child(clone));250			var end = /** @type {TemplateNode} */ (clone.lastChild);251 252			assign_nodes(start, end);253		} else {254			assign_nodes(clone, clone);255		}256 257		return clone;258	};259}260 261/**262 * @param {() => Element | DocumentFragment} fn263 */264export function with_script(fn) {265	return () => run_scripts(fn());266}267 268/**269 * Creating a document fragment from HTML that contains script tags will not execute270 * the scripts. We need to replace the script tags with new ones so that they are executed.271 * @param {Element | DocumentFragment} node272 * @returns {Node | Node[]}273 */274function run_scripts(node) {275	// scripts were SSR'd, in which case they will run276	if (hydrating) return node;277 278	const is_fragment = node.nodeType === DOCUMENT_FRAGMENT_NODE;279	const scripts =280		/** @type {HTMLElement} */ (node).nodeName === SCRIPT_TAG281			? [/** @type {HTMLScriptElement} */ (node)]282			: node.querySelectorAll('script');283 284	const effect = /** @type {Effect & { nodes: EffectNodes }} */ (active_effect);285 286	for (const script of scripts) {287		const clone = create_element('script');288		for (var attribute of script.attributes) {289			clone.setAttribute(attribute.name, attribute.value);290		}291 292		clone.textContent = script.textContent;293 294		// The script has changed - if it's at the edges, the effect now points at dead nodes295		if (is_fragment ? node.firstChild === script : node === script) {296			effect.nodes.start = clone;297		}298		if (is_fragment ? node.lastChild === script : node === script) {299			effect.nodes.end = clone;300		}301 302		script.replaceWith(clone);303	}304	return node;305}306 307/**308 * Don't mark this as side-effect-free, hydration needs to walk all nodes309 * @param {any} value310 */311export function text(value = '') {312	if (!hydrating) {313		var t = create_text(value + '');314		assign_nodes(t, t);315		return t;316	}317 318	var node = hydrate_node;319 320	if (node.nodeType !== TEXT_NODE) {321		// if an {expression} is empty during SSR, we need to insert an empty text node322		node.before((node = create_text()));323		set_hydrate_node(node);324	} else {325		merge_text_nodes(/** @type {Text} */ (node));326	}327 328	assign_nodes(node, node);329	return node;330}331 332/**333 * @returns {TemplateNode | DocumentFragment}334 */335export function comment() {336	// we're not delegating to `template` here for performance reasons337	if (hydrating) {338		assign_nodes(hydrate_node, null);339		return hydrate_node;340	}341 342	var frag = document.createDocumentFragment();343	var start = document.createComment('');344	var anchor = create_text();345	frag.append(start, anchor);346 347	assign_nodes(start, anchor);348 349	return frag;350}351 352/**353 * Assign the created (or in hydration mode, traversed) dom elements to the current block354 * and insert the elements into the dom (in client mode).355 * @param {Text | Comment | Element} anchor356 * @param {DocumentFragment | Element} dom357 */358export function append(anchor, dom) {359	if (hydrating) {360		var effect = /** @type {Effect & { nodes: EffectNodes }} */ (active_effect);361 362		// When hydrating and outer component and an inner component is async, i.e. blocked on a promise,363		// then by the time the inner resolves we have already advanced to the end of the hydrated nodes364		// of the parent component. Check for defined for that reason to avoid rewinding the parent's end marker.365		if ((effect.f & REACTION_RAN) === 0 || effect.nodes.end === null) {366			effect.nodes.end = hydrate_node;367		}368 369		hydrate_next();370		return;371	}372 373	if (anchor === null) {374		// edge case — void `<svelte:element>` with content375		return;376	}377 378	anchor.before(/** @type {Node} */ (dom));379}380 381/**382 * Create (or hydrate) an unique UID for the component instance.383 */384export function props_id() {385	if (386		hydrating &&387		hydrate_node &&388		hydrate_node.nodeType === COMMENT_NODE &&389		hydrate_node.textContent?.startsWith(`$`)390	) {391		const id = hydrate_node.textContent.substring(1);392		hydrate_next();393		return id;394	}395 396	// @ts-expect-error This way we ensure the id is unique even across Svelte runtimes397	(window.__svelte ??= {}).uid ??= 1;398 399	// @ts-expect-error400	return `c${window.__svelte.uid++}`;401}402 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai