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 { HydratableLookupEntry } from '#server' */2import { async_mode_flag } from '../flags/index.js';3import { get_render_context } from './render-context.js';4import * as e from './errors.js';5import * as devalue from 'devalue';6import { DEV } from 'esm-env';7import { get_user_code_location } from './dev.js';8 9/**10 * @template T11 * @param {string} key12 * @param {() => T} fn13 * @returns {T}14 */15export function hydratable(key, fn) {16 if (!async_mode_flag) {17 e.experimental_async_required('hydratable');18 }19 20 const { hydratable } = get_render_context();21 22 let entry = hydratable.lookup.get(key);23 24 if (entry !== undefined) {25 if (DEV) {26 const comparison = compare(key, entry, encode(key, fn()));27 comparison.catch(() => {});28 hydratable.comparisons.push(comparison);29 }30 31 return /** @type {T} */ (entry.value);32 }33 34 const value = fn();35 36 entry = encode(key, value, hydratable.unresolved_promises);37 hydratable.lookup.set(key, entry);38 39 return value;40}41 42/**43 * @param {string} key44 * @param {any} value45 * @param {Map<Promise<any>, string>} [unresolved]46 */47function encode(key, value, unresolved) {48 /** @type {HydratableLookupEntry} */49 const entry = { value, serialized: '' };50 51 if (DEV) {52 entry.stack = get_user_code_location();53 }54 55 let uid = 1;56 57 entry.serialized = devalue.uneval(entry.value, (value, uneval) => {58 if (is_promise(value)) {59 // we serialize promises as `"${i}"`, because it's impossible for that string60 // to occur 'naturally' (since the quote marks would have to be escaped)61 // this placeholder is returned synchronously from `uneval`, which includes it in the62 // serialized string. Later (at least one microtask from now), when `p.then` runs, it'll63 // be replaced.64 const placeholder = `"${uid++}"`;65 const p = value66 .then((v) => {67 entry.serialized = entry.serialized.replace(68 placeholder,69 // use the function form here to prevent any string replacement characters from being interpreted70 // in `v`, as it's potentially user-controlled and therefore potentially malicious.71 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_the_replacement72 () => `r(${uneval(v)})`73 );74 })75 .catch((devalue_error) =>76 e.hydratable_serialization_failed(77 key,78 serialization_stack(entry.stack, devalue_error?.stack)79 )80 );81 82 unresolved?.set(p, key);83 // prevent unhandled rejections from crashing the server, track which promises are still resolving when render is complete84 p.catch(() => {}).finally(() => unresolved?.delete(p));85 86 (entry.promises ??= []).push(p);87 return placeholder;88 }89 });90 91 return entry;92}93 94/**95 * @param {any} value96 * @returns {value is Promise<any>}97 */98function is_promise(value) {99 // we use this check rather than `instanceof Promise`100 // because it works cross-realm101 return Object.prototype.toString.call(value) === '[object Promise]';102}103 104/**105 * @param {string} key106 * @param {HydratableLookupEntry} a107 * @param {HydratableLookupEntry} b108 */109async function compare(key, a, b) {110 // note: these need to be loops (as opposed to Promise.all) because111 // additional promises can get pushed to them while we're awaiting112 // an earlier one113 for (const p of a?.promises ?? []) {114 await p;115 }116 117 for (const p of b?.promises ?? []) {118 await p;119 }120 121 if (a.serialized !== b.serialized) {122 const a_stack = /** @type {string} */ (a.stack);123 const b_stack = /** @type {string} */ (b.stack);124 125 const stack =126 a_stack === b_stack127 ? `Occurred at:\n${a_stack}`128 : `First occurrence at:\n${a_stack}\n\nSecond occurrence at:\n${b_stack}`;129 130 e.hydratable_clobbering(key, stack);131 }132}133 134/**135 * @param {string | undefined} root_stack136 * @param {string | undefined} uneval_stack137 */138function serialization_stack(root_stack, uneval_stack) {139 let out = '';140 if (root_stack) {141 out += root_stack + '\n';142 }143 if (uneval_stack) {144 out += 'Caused by:\n' + uneval_stack + '\n';145 }146 return out || '<missing stack trace>';147}148 