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 { Source, Replacement } from './private.js' */2import { MappedCode } from '../utils/mapped_code.js';3 4/**5 * @param {string} code_slice6 * @param {number} offset7 * @param {Source} opts8 * @returns {Source}9 */10export function slice_source(code_slice, offset, { file_basename, filename, get_location }) {11 return {12 source: code_slice,13 get_location: (index) => get_location(index + offset),14 file_basename,15 filename16 };17}18 19/**20 * @param {RegExp} re21 * @param {(...match: any[]) => Promise<MappedCode>} get_replacement22 * @param {string} source23 */24function calculate_replacements(re, get_replacement, source) {25 /**26 * @type {Array<Promise<Replacement>>}27 */28 const replacements = [];29 source.replace(re, (...match) => {30 replacements.push(31 get_replacement(...match).then((replacement) => {32 const matched_string = match[0];33 const offset = match[match.length - 2];34 return { offset, length: matched_string.length, replacement };35 })36 );37 return '';38 });39 return Promise.all(replacements);40}41 42/**43 * @param {Replacement[]} replacements44 * @param {Source} source45 * @returns {MappedCode}46 */47function perform_replacements(replacements, source) {48 const out = new MappedCode();49 let last_end = 0;50 for (const { offset, length, replacement } of replacements) {51 const unchanged_prefix = MappedCode.from_source(52 slice_source(source.source.slice(last_end, offset), last_end, source)53 );54 out.concat(unchanged_prefix).concat(replacement);55 last_end = offset + length;56 }57 const unchanged_suffix = MappedCode.from_source(58 slice_source(source.source.slice(last_end), last_end, source)59 );60 return out.concat(unchanged_suffix);61}62 63/**64 * @param {RegExp} regex65 * @param {(...match: any[]) => Promise<MappedCode>} get_replacement66 * @param {Source} location67 * @returns {Promise<MappedCode>}68 */69export async function replace_in_code(regex, get_replacement, location) {70 const replacements = await calculate_replacements(regex, get_replacement, location.source);71 return perform_replacements(replacements, location);72}73 