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
container.js495 linesDownload Raw Back to lib
1'use strict'2 3let Comment = require('./comment')4let Declaration = require('./declaration')5let Node = require('./node')6let { isClean, my } = require('./symbols')7 8let AtRule, parse, Root, Rule9 10function cleanSource(nodes) {11  let stack = nodes.slice()12  while (stack.length > 0) {13    let node = stack.pop()14    delete node.source15    if (node.nodes) {16      node.nodes = node.nodes.slice()17      for (let i of node.nodes) stack.push(i)18    }19  }20  return nodes.slice()21}22 23function markTreeDirty(node) {24  let stack = [node]25  while (stack.length > 0) {26    let next = stack.pop()27    next[isClean] = false28    if (next.proxyOf.nodes) {29      for (let i of next.proxyOf.nodes) stack.push(i)30    }31  }32}33 34class Container extends Node {35  get first() {36    if (!this.proxyOf.nodes) return undefined37    return this.proxyOf.nodes[0]38  }39 40  get last() {41    if (!this.proxyOf.nodes) return undefined42    return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]43  }44 45  append(...children) {46    for (let child of children) {47      let nodes = this.normalize(child, this.last)48      for (let node of nodes) this.proxyOf.nodes.push(node)49    }50 51    this.markDirty()52 53    return this54  }55 56  cleanRaws(keepBetween) {57    let stack = [this]58    while (stack.length > 0) {59      let node = stack.pop()60      if (node !== this && node.cleanRaws !== Container.prototype.cleanRaws) {61        // Subclass with own logic; let it handle its subtree62        node.cleanRaws(keepBetween)63        continue64      }65      Node.prototype.cleanRaws.call(node, keepBetween)66      if (node.nodes) {67        for (let child of node.nodes) stack.push(child)68      }69    }70  }71 72  each(callback) {73    if (!this.proxyOf.nodes) return undefined74    let iterator = this.getIterator()75 76    let index, result77    while (this.indexes[iterator] < this.proxyOf.nodes.length) {78      index = this.indexes[iterator]79      result = callback(this.proxyOf.nodes[index], index)80      if (result === false) break81 82      this.indexes[iterator] += 183    }84 85    delete this.indexes[iterator]86    return result87  }88 89  every(condition) {90    return this.nodes.every(condition)91  }92 93  getIterator() {94    if (!this.lastEach) this.lastEach = 095    if (!this.indexes) this.indexes = {}96 97    this.lastEach += 198    let iterator = this.lastEach99    this.indexes[iterator] = 0100 101    return iterator102  }103 104  getProxyProcessor() {105    return {106      get(node, prop) {107        if (prop === 'proxyOf') {108          return node109        } else if (!node[prop]) {110          return node[prop]111        } else if (112          prop === 'each' ||113          (typeof prop === 'string' && prop.startsWith('walk'))114        ) {115          return (...args) => {116            return node[prop](117              ...args.map(i => {118                if (typeof i === 'function') {119                  return (child, index) => i(child.toProxy(), index)120                } else {121                  return i122                }123              })124            )125          }126        } else if (prop === 'every' || prop === 'some') {127          return cb => {128            return node[prop]((child, ...other) =>129              cb(child.toProxy(), ...other)130            )131          }132        } else if (prop === 'root') {133          return () => node.root().toProxy()134        } else if (prop === 'nodes') {135          return node.nodes.map(i => i.toProxy())136        } else if (prop === 'first' || prop === 'last') {137          return node[prop].toProxy()138        } else {139          return node[prop]140        }141      },142 143      set(node, prop, value) {144        if (node[prop] === value) return true145        node[prop] = value146        if (prop === 'name' || prop === 'params' || prop === 'selector') {147          node.markDirty()148        }149        return true150      }151    }152  }153 154  index(child) {155    if (typeof child === 'number') return child156    if (child.proxyOf) child = child.proxyOf157    return this.proxyOf.nodes.indexOf(child)158  }159 160  insertAfter(exist, add) {161    let existIndex = this.index(exist)162    let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse()163    existIndex = this.index(exist)164    for (let node of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node)165 166    let index167    for (let id in this.indexes) {168      index = this.indexes[id]169      if (existIndex < index) {170        this.indexes[id] = index + nodes.length171      }172    }173 174    this.markDirty()175 176    return this177  }178 179  insertBefore(exist, add) {180    let existIndex = this.index(exist)181    let type = existIndex === 0 ? 'prepend' : false182    let nodes = this.normalize(183      add,184      this.proxyOf.nodes[existIndex],185      type186    ).reverse()187    existIndex = this.index(exist)188    for (let node of nodes) this.proxyOf.nodes.splice(existIndex, 0, node)189 190    let index191    for (let id in this.indexes) {192      index = this.indexes[id]193      if (existIndex <= index) {194        this.indexes[id] = index + nodes.length195      }196    }197 198    this.markDirty()199 200    return this201  }202 203  normalize(nodes, sample) {204    if (typeof nodes === 'string') {205      nodes = cleanSource(parse(nodes).nodes)206    } else if (typeof nodes === 'undefined') {207      nodes = []208    } else if (Array.isArray(nodes)) {209      nodes = nodes.slice(0)210      for (let i of nodes) {211        if (i.parent) i.parent.removeChild(i, 'ignore')212      }213    } else if (nodes.type === 'root' && this.type !== 'document') {214      nodes = nodes.nodes.slice(0)215      for (let i of nodes) {216        if (i.parent) i.parent.removeChild(i, 'ignore')217      }218    } else if (nodes.type) {219      nodes = [nodes]220    } else if (nodes.prop) {221      if (typeof nodes.value === 'undefined') {222        throw new Error('Value field is missed in node creation')223      } else if (typeof nodes.value !== 'string') {224        nodes.value = String(nodes.value)225      }226      nodes = [new Declaration(nodes)]227    } else if (nodes.selector || nodes.selectors) {228      nodes = [new Rule(nodes)]229    } else if (nodes.name) {230      nodes = [new AtRule(nodes)]231    } else if (nodes.text) {232      nodes = [new Comment(nodes)]233    } else {234      throw new Error('Unknown node type in node creation')235    }236 237    let processed = nodes.map(i => {238      /* c8 ignore next */239      if (!i[my]) Container.rebuild(i)240      i = i.proxyOf241      if (i.parent) i.parent.removeChild(i)242      if (i[isClean]) markTreeDirty(i)243 244      if (!i.raws) i.raws = {}245      if (typeof i.raws.before === 'undefined') {246        if (sample && typeof sample.raws.before !== 'undefined') {247          i.raws.before = sample.raws.before.replace(/\S/g, '')248        }249      }250      i.parent = this.proxyOf251      return i252    })253 254    return processed255  }256 257  prepend(...children) {258    children = children.reverse()259    for (let child of children) {260      let nodes = this.normalize(child, this.first, 'prepend').reverse()261      for (let node of nodes) this.proxyOf.nodes.unshift(node)262      for (let id in this.indexes) {263        this.indexes[id] = this.indexes[id] + nodes.length264      }265    }266 267    this.markDirty()268 269    return this270  }271 272  push(child) {273    child.parent = this274    this.proxyOf.nodes.push(child)275    return this276  }277 278  removeAll() {279    for (let node of this.proxyOf.nodes) node.parent = undefined280    this.proxyOf.nodes = []281 282    this.markDirty()283 284    return this285  }286 287  removeChild(child) {288    child = this.index(child)289    this.proxyOf.nodes[child].parent = undefined290    this.proxyOf.nodes.splice(child, 1)291 292    let index293    for (let id in this.indexes) {294      index = this.indexes[id]295      if (index >= child) {296        this.indexes[id] = index - 1297      }298    }299 300    this.markDirty()301 302    return this303  }304 305  replaceValues(pattern, opts, callback) {306    if (!callback) {307      callback = opts308      opts = {}309    }310 311    this.walkDecls(decl => {312      if (opts.props && !opts.props.includes(decl.prop)) return313      if (opts.fast && !decl.value.includes(opts.fast)) return314 315      decl.value = decl.value.replace(pattern, callback)316    })317 318    this.markDirty()319 320    return this321  }322 323  some(condition) {324    return this.nodes.some(condition)325  }326 327  walk(callback) {328    if (!this.proxyOf.nodes) return undefined329 330    // An explicit stack instead of recursive `each()` calls to survive331    // deeply nested trees. Each frame keeps a live `indexes` slot, so332    // insertion and removal during the walk behave like `each()`: the333    // slot stays at the current child until its subtree is finished.334    let stack = [{ iterator: this.getIterator(), node: this.proxyOf }]335 336    while (stack.length > 0) {337      let { iterator, node } = stack[stack.length - 1]338      let index = node.indexes[iterator]339 340      if (index >= node.proxyOf.nodes.length) {341        delete node.indexes[iterator]342        stack.pop()343        let parent = stack[stack.length - 1]344        // Finish the parent’s step for the child subtree we just left345        if (parent) parent.node.indexes[parent.iterator] += 1346        continue347      }348 349      let child = node.proxyOf.nodes[index]350      let result351      try {352        result = callback(child, index)353      } catch (e) {354        throw child.addToError(e)355      }356      if (result === false) {357        for (let opened of stack) {358          delete opened.node.indexes[opened.iterator]359        }360        return false361      }362      if (child.walk && child.proxyOf.nodes) {363        stack.push({ iterator: child.getIterator(), node: child })364      } else {365        node.indexes[iterator] += 1366      }367    }368 369    return undefined370  }371 372  walkAtRules(name, callback) {373    if (!callback) {374      callback = name375      return this.walk((child, i) => {376        if (child.type === 'atrule') {377          return callback(child, i)378        }379      })380    }381    if (name instanceof RegExp) {382      return this.walk((child, i) => {383        if (child.type === 'atrule' && name.test(child.name)) {384          return callback(child, i)385        }386      })387    }388    return this.walk((child, i) => {389      if (child.type === 'atrule' && child.name === name) {390        return callback(child, i)391      }392    })393  }394 395  walkComments(callback) {396    return this.walk((child, i) => {397      if (child.type === 'comment') {398        return callback(child, i)399      }400    })401  }402 403  walkDecls(prop, callback) {404    if (!callback) {405      callback = prop406      return this.walk((child, i) => {407        if (child.type === 'decl') {408          return callback(child, i)409        }410      })411    }412    if (prop instanceof RegExp) {413      return this.walk((child, i) => {414        if (child.type === 'decl' && prop.test(child.prop)) {415          return callback(child, i)416        }417      })418    }419    return this.walk((child, i) => {420      if (child.type === 'decl' && child.prop === prop) {421        return callback(child, i)422      }423    })424  }425 426  walkRules(selector, callback) {427    if (!callback) {428      callback = selector429 430      return this.walk((child, i) => {431        if (child.type === 'rule') {432          return callback(child, i)433        }434      })435    }436    if (selector instanceof RegExp) {437      return this.walk((child, i) => {438        if (child.type === 'rule' && selector.test(child.selector)) {439          return callback(child, i)440        }441      })442    }443    return this.walk((child, i) => {444      if (child.type === 'rule' && child.selector === selector) {445        return callback(child, i)446      }447    })448  }449}450 451Container.registerParse = dependant => {452  parse = dependant453}454 455Container.registerRule = dependant => {456  Rule = dependant457}458 459Container.registerAtRule = dependant => {460  AtRule = dependant461}462 463Container.registerRoot = dependant => {464  Root = dependant465}466 467module.exports = Container468Container.default = Container469 470/* c8 ignore start */471Container.rebuild = node => {472  let stack = [node]473  while (stack.length > 0) {474    let next = stack.pop()475    if (next.type === 'atrule') {476      Object.setPrototypeOf(next, AtRule.prototype)477    } else if (next.type === 'rule') {478      Object.setPrototypeOf(next, Rule.prototype)479    } else if (next.type === 'decl') {480      Object.setPrototypeOf(next, Declaration.prototype)481    } else if (next.type === 'comment') {482      Object.setPrototypeOf(next, Comment.prototype)483    } else if (next.type === 'root') {484      Object.setPrototypeOf(next, Root.prototype)485    }486 487    next[my] = true488 489    if (next.nodes) {490      for (let child of next.nodes) stack.push(child)491    }492  }493}494/* c8 ignore stop */495 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai