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
index.js338 linesDownload Raw Back to lib
1/**2 * @import {ElementData, Element, Nodes, RootContent, Root} from 'hast'3 * @import {DefaultTreeAdapterMap, Token} from 'parse5'4 * @import {Schema} from 'property-information'5 * @import {Point, Position} from 'unist'6 * @import {VFile} from 'vfile'7 * @import {Options} from 'hast-util-from-parse5'8 */9 10/**11 * @typedef State12 *   Info passed around about the current state.13 * @property {VFile | undefined} file14 *   Corresponding file.15 * @property {boolean} location16 *   Whether location info was found.17 * @property {Schema} schema18 *   Current schema.19 * @property {boolean | undefined} verbose20 *   Add extra positional info.21 */22 23import {ok as assert} from 'devlop'24import {h, s} from 'hastscript'25import {find, html, svg} from 'property-information'26import {location} from 'vfile-location'27import {webNamespaces} from 'web-namespaces'28 29const own = {}.hasOwnProperty30/** @type {unknown} */31// type-coverage:ignore-next-line32const proto = Object.prototype33 34/**35 * Transform a `parse5` AST to hast.36 *37 * @param {DefaultTreeAdapterMap['node']} tree38 *   `parse5` tree to transform.39 * @param {Options | null | undefined} [options]40 *   Configuration (optional).41 * @returns {Nodes}42 *   hast tree.43 */44export function fromParse5(tree, options) {45  const settings = options || {}46 47  return one(48    {49      file: settings.file || undefined,50      location: false,51      schema: settings.space === 'svg' ? svg : html,52      verbose: settings.verbose || false53    },54    tree55  )56}57 58/**59 * Transform a node.60 *61 * @param {State} state62 *   Info passed around about the current state.63 * @param {DefaultTreeAdapterMap['node']} node64 *   p5 node.65 * @returns {Nodes}66 *   hast node.67 */68function one(state, node) {69  /** @type {Nodes} */70  let result71 72  switch (node.nodeName) {73    case '#comment': {74      const reference = /** @type {DefaultTreeAdapterMap['commentNode']} */ (75        node76      )77      result = {type: 'comment', value: reference.data}78      patch(state, reference, result)79      return result80    }81 82    case '#document':83    case '#document-fragment': {84      const reference =85        /** @type {DefaultTreeAdapterMap['document'] | DefaultTreeAdapterMap['documentFragment']} */ (86          node87        )88      const quirksMode =89        'mode' in reference90          ? reference.mode === 'quirks' || reference.mode === 'limited-quirks'91          : false92 93      result = {94        type: 'root',95        children: all(state, node.childNodes),96        data: {quirksMode}97      }98 99      if (state.file && state.location) {100        const document = String(state.file)101        const loc = location(document)102        const start = loc.toPoint(0)103        const end = loc.toPoint(document.length)104        // Always defined as we give valid input.105        assert(start, 'expected `start`')106        assert(end, 'expected `end`')107        result.position = {start, end}108      }109 110      return result111    }112 113    case '#documentType': {114      const reference = /** @type {DefaultTreeAdapterMap['documentType']} */ (115        node116      )117      result = {type: 'doctype'}118      patch(state, reference, result)119      return result120    }121 122    case '#text': {123      const reference = /** @type {DefaultTreeAdapterMap['textNode']} */ (node)124      result = {type: 'text', value: reference.value}125      patch(state, reference, result)126      return result127    }128 129    // Element.130    default: {131      const reference = /** @type {DefaultTreeAdapterMap['element']} */ (node)132      result = element(state, reference)133      return result134    }135  }136}137 138/**139 * Transform children.140 *141 * @param {State} state142 *   Info passed around about the current state.143 * @param {Array<DefaultTreeAdapterMap['node']>} nodes144 *   Nodes.145 * @returns {Array<RootContent>}146 *   hast nodes.147 */148function all(state, nodes) {149  let index = -1150  /** @type {Array<RootContent>} */151  const results = []152 153  while (++index < nodes.length) {154    // Assume no roots in `nodes`.155    const result = /** @type {RootContent} */ (one(state, nodes[index]))156    results.push(result)157  }158 159  return results160}161 162/**163 * Transform an element.164 *165 * @param {State} state166 *   Info passed around about the current state.167 * @param {DefaultTreeAdapterMap['element']} node168 *   `parse5` node to transform.169 * @returns {Element}170 *   hast node.171 */172function element(state, node) {173  const schema = state.schema174 175  state.schema = node.namespaceURI === webNamespaces.svg ? svg : html176 177  // Props.178  let index = -1179  /** @type {Record<string, string>} */180  const properties = {}181 182  while (++index < node.attrs.length) {183    const attribute = node.attrs[index]184    const name =185      (attribute.prefix ? attribute.prefix + ':' : '') + attribute.name186    if (!own.call(proto, name)) {187      properties[name] = attribute.value188    }189  }190 191  // Build.192  const x = state.schema.space === 'svg' ? s : h193  const result = x(node.tagName, properties, all(state, node.childNodes))194  patch(state, node, result)195 196  // Switch content.197  if (result.tagName === 'template') {198    const reference = /** @type {DefaultTreeAdapterMap['template']} */ (node)199    const pos = reference.sourceCodeLocation200    const startTag = pos && pos.startTag && position(pos.startTag)201    const endTag = pos && pos.endTag && position(pos.endTag)202 203    // Root in, root out.204    const content = /** @type {Root} */ (one(state, reference.content))205 206    if (startTag && endTag && state.file) {207      content.position = {start: startTag.end, end: endTag.start}208    }209 210    result.content = content211  }212 213  state.schema = schema214 215  return result216}217 218/**219 * Patch positional info from `from` onto `to`.220 *221 * @param {State} state222 *   Info passed around about the current state.223 * @param {DefaultTreeAdapterMap['node']} from224 *   p5 node.225 * @param {Nodes} to226 *   hast node.227 * @returns {undefined}228 *   Nothing.229 */230function patch(state, from, to) {231  if ('sourceCodeLocation' in from && from.sourceCodeLocation && state.file) {232    const position = createLocation(state, to, from.sourceCodeLocation)233 234    if (position) {235      state.location = true236      to.position = position237    }238  }239}240 241/**242 * Create clean positional information.243 *244 * @param {State} state245 *   Info passed around about the current state.246 * @param {Nodes} node247 *   hast node.248 * @param {Token.ElementLocation} location249 *   p5 location info.250 * @returns {Position | undefined}251 *   Position, or nothing.252 */253function createLocation(state, node, location) {254  const result = position(location)255 256  if (node.type === 'element') {257    const tail = node.children[node.children.length - 1]258 259    // Bug for unclosed with children.260    // See: <https://github.com/inikulin/parse5/issues/109>.261    if (262      result &&263      !location.endTag &&264      tail &&265      tail.position &&266      tail.position.end267    ) {268      result.end = Object.assign({}, tail.position.end)269    }270 271    if (state.verbose) {272      /** @type {Record<string, Position | undefined>} */273      const properties = {}274      /** @type {string} */275      let key276 277      if (location.attrs) {278        for (key in location.attrs) {279          if (own.call(location.attrs, key)) {280            properties[find(state.schema, key).property] = position(281              location.attrs[key]282            )283          }284        }285      }286 287      assert(location.startTag, 'a start tag should exist')288      const opening = position(location.startTag)289      const closing = location.endTag ? position(location.endTag) : undefined290      /** @type {ElementData['position']} */291      const data = {opening}292      if (closing) data.closing = closing293      data.properties = properties294 295      node.data = {position: data}296    }297  }298 299  return result300}301 302/**303 * Turn a p5 location into a position.304 *305 * @param {Token.Location} loc306 *   Location.307 * @returns {Position | undefined}308 *   Position or nothing.309 */310function position(loc) {311  const start = point({312    line: loc.startLine,313    column: loc.startCol,314    offset: loc.startOffset315  })316  const end = point({317    line: loc.endLine,318    column: loc.endCol,319    offset: loc.endOffset320  })321 322  // @ts-expect-error: we do use `undefined` for points if one or the other323  // exists.324  return start || end ? {start, end} : undefined325}326 327/**328 * Filter out invalid points.329 *330 * @param {Point} point331 *   Point with potentially `undefined` values.332 * @returns {Point | undefined}333 *   Point or nothing.334 */335function point(point) {336  return point.line && point.column ? point : undefined337}338 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai