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
lazy-result.js627 linesDownload Raw Back to lib
1'use strict'2 3let Container = require('./container')4let Document = require('./document')5let MapGenerator = require('./map-generator')6let parse = require('./parse')7let Result = require('./result')8let Root = require('./root')9let stringify = require('./stringify')10let { isClean, my } = require('./symbols')11let warnOnce = require('./warn-once')12 13const TYPE_TO_CLASS_NAME = {14  atrule: 'AtRule',15  comment: 'Comment',16  decl: 'Declaration',17  document: 'Document',18  root: 'Root',19  rule: 'Rule'20}21 22const PLUGIN_PROPS = {23  AtRule: true,24  AtRuleExit: true,25  Comment: true,26  CommentExit: true,27  Declaration: true,28  DeclarationExit: true,29  Document: true,30  DocumentExit: true,31  Once: true,32  OnceExit: true,33  postcssPlugin: true,34  prepare: true,35  Root: true,36  RootExit: true,37  Rule: true,38  RuleExit: true39}40 41const NOT_VISITORS = {42  Once: true,43  postcssPlugin: true,44  prepare: true45}46 47const CHILDREN = 048 49function isPromise(obj) {50  return typeof obj === 'object' && typeof obj.then === 'function'51}52 53function getEvents(node) {54  let key = false55  let type = TYPE_TO_CLASS_NAME[node.type]56  if (node.type === 'decl') {57    key = node.prop.toLowerCase()58  } else if (node.type === 'atrule') {59    key = node.name.toLowerCase()60  }61 62  if (key && node.append) {63    return [64      type,65      type + '-' + key,66      CHILDREN,67      type + 'Exit',68      type + 'Exit-' + key69    ]70  } else if (key) {71    return [type, type + '-' + key, type + 'Exit', type + 'Exit-' + key]72  } else if (node.append) {73    return [type, CHILDREN, type + 'Exit']74  } else {75    return [type, type + 'Exit']76  }77}78 79function toStack(node) {80  let events81  if (node.type === 'document') {82    events = ['Document', CHILDREN, 'DocumentExit']83  } else if (node.type === 'root') {84    events = ['Root', CHILDREN, 'RootExit']85  } else {86    events = getEvents(node)87  }88 89  return {90    eventIndex: 0,91    events,92    iterator: 0,93    node,94    visitorIndex: 0,95    visitors: []96  }97}98 99function cleanMarks(node) {100  let stack = [node]101  while (stack.length > 0) {102    let next = stack.pop()103    next[isClean] = false104    if (next.nodes) {105      for (let i of next.nodes) stack.push(i)106    }107  }108  return node109}110 111let postcss = {}112 113class LazyResult {114  get content() {115    return this.stringify().content116  }117 118  get css() {119    return this.stringify().css120  }121 122  get map() {123    return this.stringify().map124  }125 126  get messages() {127    return this.sync().messages128  }129 130  get opts() {131    return this.result.opts132  }133 134  get processor() {135    return this.result.processor136  }137 138  get root() {139    return this.sync().root140  }141 142  get [Symbol.toStringTag]() {143    return 'LazyResult'144  }145 146  constructor(processor, css, opts) {147    this.stringified = false148    this.processed = false149 150    let root151    if (152      typeof css === 'object' &&153      css !== null &&154      (css.type === 'root' || css.type === 'document')155    ) {156      root = cleanMarks(css)157    } else if (css instanceof LazyResult || css instanceof Result) {158      root = cleanMarks(css.root)159      if (css.map) {160        if (typeof opts.map === 'undefined') opts.map = {}161        if (!opts.map.inline) opts.map.inline = false162        opts.map.prev = css.map163      }164    } else {165      let parser = parse166      if (opts.syntax) parser = opts.syntax.parse167      if (opts.parser) parser = opts.parser168      if (parser.parse) parser = parser.parse169 170      try {171        root = parser(css, opts)172      } catch (error) {173        this.processed = true174        this.error = error175      }176 177      if (root && !root[my]) {178        /* c8 ignore next 2 */179        Container.rebuild(root)180      }181    }182 183    this.result = new Result(processor, root, opts)184    this.helpers = { ...postcss, postcss, result: this.result }185    this.plugins = this.processor.plugins.map(plugin => {186      if (typeof plugin === 'object' && plugin.prepare) {187        return { ...plugin, ...plugin.prepare(this.result) }188      } else {189        return plugin190      }191    })192  }193 194  async() {195    if (this.error) return Promise.reject(this.error)196    if (this.processed) return Promise.resolve(this.result)197    if (!this.processing) {198      this.processing = this.runAsync()199    }200    return this.processing201  }202 203  catch(onRejected) {204    return this.async().catch(onRejected)205  }206 207  finally(onFinally) {208    return this.async().then(onFinally, onFinally)209  }210 211  getAsyncError() {212    throw new Error('Use process(css).then(cb) to work with async plugins')213  }214 215  handleError(error, node) {216    let plugin = this.result.lastPlugin217    try {218      if (node) node.addToError(error)219      this.error = error220      if (error.name === 'CssSyntaxError' && !error.plugin) {221        error.plugin = plugin.postcssPlugin222        error.setMessage()223      } else if (plugin.postcssVersion) {224        if (process.env.NODE_ENV !== 'production') {225          let pluginName = plugin.postcssPlugin226          let pluginVer = plugin.postcssVersion227          let runtimeVer = this.result.processor.version228          let a = pluginVer.split('.')229          let b = runtimeVer.split('.')230 231          if (a[0] !== b[0] || parseInt(a[1]) > parseInt(b[1])) {232            // eslint-disable-next-line no-console233            console.error(234              'Unknown error from PostCSS plugin. Your current PostCSS ' +235                'version is ' +236                runtimeVer +237                ', but ' +238                pluginName +239                ' uses ' +240                pluginVer +241                '. Perhaps this is the source of the error below.'242            )243          }244        }245      }246    } catch (err) {247      /* c8 ignore next 3 */248      // eslint-disable-next-line no-console249      if (console && console.error) console.error(err)250    }251    return error252  }253 254  prepareVisitors() {255    this.listeners = {}256    let add = (plugin, type, cb) => {257      if (!this.listeners[type]) this.listeners[type] = []258      this.listeners[type].push([plugin, cb])259    }260    for (let plugin of this.plugins) {261      if (typeof plugin === 'object') {262        for (let event in plugin) {263          if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {264            throw new Error(265              `Unknown event ${event} in ${plugin.postcssPlugin}. ` +266                `Try to update PostCSS (${this.processor.version} now).`267            )268          }269          if (!NOT_VISITORS[event]) {270            if (typeof plugin[event] === 'object') {271              for (let filter in plugin[event]) {272                if (filter === '*') {273                  add(plugin, event, plugin[event][filter])274                } else {275                  add(276                    plugin,277                    event + '-' + filter.toLowerCase(),278                    plugin[event][filter]279                  )280                }281              }282            } else if (typeof plugin[event] === 'function') {283              add(plugin, event, plugin[event])284            }285          }286        }287      }288    }289    this.hasListener = Object.keys(this.listeners).length > 0290  }291 292  async runAsync() {293    this.plugin = 0294    for (let i = 0; i < this.plugins.length; i++) {295      let plugin = this.plugins[i]296      let promise = this.runOnRoot(plugin)297      if (isPromise(promise)) {298        try {299          await promise300        } catch (error) {301          throw this.handleError(error)302        }303      }304    }305 306    this.prepareVisitors()307    if (this.hasListener) {308      let root = this.result.root309      while (!root[isClean]) {310        root[isClean] = true311        let stack = [toStack(root)]312        while (stack.length > 0) {313          let promise = this.visitTick(stack)314          if (isPromise(promise)) {315            try {316              await promise317            } catch (e) {318              let node = stack[stack.length - 1].node319              throw this.handleError(e, node)320            }321          }322        }323      }324 325      if (this.listeners.OnceExit) {326        for (let [plugin, visitor] of this.listeners.OnceExit) {327          this.result.lastPlugin = plugin328          try {329            if (root.type === 'document') {330              let roots = root.nodes.map(subRoot =>331                visitor(subRoot, this.helpers)332              )333 334              await Promise.all(roots)335            } else {336              await visitor(root, this.helpers)337            }338          } catch (e) {339            throw this.handleError(e)340          }341        }342      }343    }344 345    this.processed = true346    return this.stringify()347  }348 349  runOnRoot(plugin) {350    this.result.lastPlugin = plugin351    try {352      if (typeof plugin === 'object' && plugin.Once) {353        if (this.result.root.type === 'document') {354          let roots = this.result.root.nodes.map(root =>355            plugin.Once(root, this.helpers)356          )357 358          if (isPromise(roots[0])) {359            return Promise.all(roots)360          }361 362          return roots363        }364 365        return plugin.Once(this.result.root, this.helpers)366      } else if (typeof plugin === 'function') {367        return plugin(this.result.root, this.result)368      }369    } catch (error) {370      throw this.handleError(error)371    }372  }373 374  stringify() {375    if (this.error) throw this.error376    if (this.stringified) return this.result377    this.stringified = true378 379    this.sync()380 381    let opts = this.result.opts382    let str = stringify383    if (opts.syntax) str = opts.syntax.stringify384    if (opts.stringifier) str = opts.stringifier385    if (str.stringify) str = str.stringify386 387    let rootSource = this.result.root.source388    if (389      opts.map === undefined &&390      !(rootSource && rootSource.input && rootSource.input.map)391    ) {392      let result = ''393      str(this.result.root, i => {394        result += i395      })396      this.result.css = result397      return this.result398    }399 400    let map = new MapGenerator(str, this.result.root, this.result.opts)401    let data = map.generate()402    this.result.css = data[0]403    this.result.map = data[1]404 405    return this.result406  }407 408  sync() {409    if (this.error) throw this.error410    if (this.processed) return this.result411    this.processed = true412 413    if (this.processing) {414      throw this.getAsyncError()415    }416 417    for (let plugin of this.plugins) {418      let promise = this.runOnRoot(plugin)419      if (isPromise(promise)) {420        throw this.getAsyncError()421      }422    }423 424    this.prepareVisitors()425    if (this.hasListener) {426      let root = this.result.root427      while (!root[isClean]) {428        root[isClean] = true429        this.walkSync(root)430      }431      if (this.listeners.OnceExit) {432        if (root.type === 'document') {433          for (let subRoot of root.nodes) {434            this.visitSync(this.listeners.OnceExit, subRoot)435          }436        } else {437          this.visitSync(this.listeners.OnceExit, root)438        }439      }440    }441 442    return this.result443  }444 445  then(onFulfilled, onRejected) {446    if (process.env.NODE_ENV !== 'production') {447      if (!('from' in this.opts)) {448        warnOnce(449          'Without `from` option PostCSS could generate wrong source map ' +450            'and will not find Browserslist config. Set it to CSS file path ' +451            'or to `undefined` to prevent this warning.'452        )453      }454    }455    return this.async().then(onFulfilled, onRejected)456  }457 458  toString() {459    return this.css460  }461 462  visitSync(visitors, node) {463    for (let [plugin, visitor] of visitors) {464      this.result.lastPlugin = plugin465      let promise466      try {467        promise = visitor(node, this.helpers)468      } catch (e) {469        throw this.handleError(e, node.proxyOf)470      }471      if (node.type !== 'root' && node.type !== 'document' && !node.parent) {472        return true473      }474      if (isPromise(promise)) {475        throw this.getAsyncError()476      }477    }478  }479 480  visitTick(stack) {481    let visit = stack[stack.length - 1]482    let { node, visitors } = visit483 484    if (node.type !== 'root' && node.type !== 'document' && !node.parent) {485      stack.pop()486      return487    }488 489    if (visitors.length > 0 && visit.visitorIndex < visitors.length) {490      let [plugin, visitor] = visitors[visit.visitorIndex]491      visit.visitorIndex += 1492      if (visit.visitorIndex === visitors.length) {493        visit.visitors = []494        visit.visitorIndex = 0495      }496      this.result.lastPlugin = plugin497      try {498        return visitor(node.toProxy(), this.helpers)499      } catch (e) {500        throw this.handleError(e, node)501      }502    }503 504    if (visit.iterator !== 0) {505      let iterator = visit.iterator506      // Advance past the child we just finished visiting. Like507      // `Container#each`, the index is incremented only after a child has508      // been fully processed, so a node inserted right after the current509      // child is not skipped by the `existIndex < index` adjustment in510      // `Container#insertAfter()` (which would fire exit events too early).511      if (visit.descending) {512        visit.descending = false513        node.indexes[iterator] += 1514      }515      let child516      while ((child = node.nodes[node.indexes[iterator]])) {517        if (!child[isClean]) {518          child[isClean] = true519          visit.descending = true520          stack.push(toStack(child))521          return522        }523        node.indexes[iterator] += 1524      }525      visit.iterator = 0526      delete node.indexes[iterator]527    }528 529    let events = visit.events530    while (visit.eventIndex < events.length) {531      let event = events[visit.eventIndex]532      visit.eventIndex += 1533      if (event === CHILDREN) {534        if (node.nodes && node.nodes.length) {535          node[isClean] = true536          visit.iterator = node.getIterator()537        }538        return539      } else if (this.listeners[event]) {540        visit.visitors = this.listeners[event]541        return542      }543    }544    stack.pop()545  }546 547  walkSync(node) {548    // An explicit stack like in async `visitTick()` to survive deeply549    // nested trees. Unlike `visitTick()`, nodes are marked clean only550    // on entering, so a node dirtied by its own visitors is revisited551    // on the next pass.552    node[isClean] = true553    let stack = [{ eventIndex: 0, events: getEvents(node), iterator: 0, node }]554 555    while (stack.length > 0) {556      let visit = stack[stack.length - 1]557      let visitNode = visit.node558 559      if (visit.iterator !== 0) {560        let iterator = visit.iterator561        // Advance past the child we just finished visiting. Like562        // `Container#each`, the index is incremented only after a child has563        // been fully processed. Incrementing before (as this loop used to)564        // makes a node inserted right after the current child get skipped by565        // the `existIndex < index` adjustment in `Container#insertAfter()`,566        // which fires exit events before those new siblings are visited.567        if (visit.descending) {568          visit.descending = false569          visitNode.indexes[iterator] += 1570        }571        let child572        let descended = false573        while ((child = visitNode.nodes[visitNode.indexes[iterator]])) {574          if (!child[isClean]) {575            child[isClean] = true576            visit.descending = true577            stack.push({578              eventIndex: 0,579              events: getEvents(child),580              iterator: 0,581              node: child582            })583            descended = true584            break585          }586          visitNode.indexes[iterator] += 1587        }588        if (descended) continue589        visit.iterator = 0590        delete visitNode.indexes[iterator]591      }592 593      if (visit.eventIndex < visit.events.length) {594        let event = visit.events[visit.eventIndex]595        visit.eventIndex += 1596        if (event === CHILDREN) {597          if (visitNode.nodes && visitNode.nodes.length) {598            visit.iterator = visitNode.getIterator()599          }600        } else {601          let visitors = this.listeners[event]602          if (visitors) {603            if (this.visitSync(visitors, visitNode.toProxy())) stack.pop()604          }605        }606        continue607      }608 609      stack.pop()610    }611  }612 613  warnings() {614    return this.sync().warnings()615  }616}617 618LazyResult.registerPostcss = dependant => {619  postcss = dependant620}621 622module.exports = LazyResult623LazyResult.default = LazyResult624 625Root.registerLazyResult(LazyResult)626Document.registerLazyResult(LazyResult)627 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai