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
create-h.js366 linesDownload Raw Back to lib
1/**2 * @import {Element, Nodes, RootContent, Root} from 'hast'3 * @import {Info, Schema} from 'property-information'4 */5 6/**7 * @typedef {Array<Nodes | PrimitiveChild>} ArrayChildNested8 *   List of children (deep).9 */10 11/**12 * @typedef {Array<ArrayChildNested | Nodes | PrimitiveChild>} ArrayChild13 *   List of children.14 */15 16/**17 * @typedef {Array<number | string>} ArrayValue18 *   List of property values for space- or comma separated values (such as `className`).19 */20 21/**22 * @typedef {ArrayChild | Nodes | PrimitiveChild} Child23 *   Acceptable child value.24 */25 26/**27 * @typedef {number | string | null | undefined} PrimitiveChild28 *   Primitive children, either ignored (nullish), or turned into text nodes.29 */30 31/**32 * @typedef {boolean | number | string | null | undefined} PrimitiveValue33 *   Primitive property value.34 */35 36/**37 * @typedef {Record<string, PropertyValue | Style>} Properties38 *   Acceptable value for element properties.39 */40 41/**42 * @typedef {ArrayValue | PrimitiveValue} PropertyValue43 *   Primitive value or list value.44 */45 46/**47 * @typedef {Element | Root} Result48 *   Result from a `h` (or `s`) call.49 */50 51/**52 * @typedef {number | string} StyleValue53 *   Value for a CSS style field.54 */55 56/**57 * @typedef {Record<string, StyleValue>} Style58 *   Supported value of a `style` prop.59 */60 61import {parse as parseCommas} from 'comma-separated-tokens'62import {parseSelector} from 'hast-util-parse-selector'63import {find, normalize} from 'property-information'64import {parse as parseSpaces} from 'space-separated-tokens'65 66/**67 * @param {Schema} schema68 *   Schema to use.69 * @param {string} defaultTagName70 *   Default tag name.71 * @param {ReadonlyArray<string> | undefined} [caseSensitive]72 *   Case-sensitive tag names (default: `undefined`).73 * @returns74 *   `h`.75 */76export function createH(schema, defaultTagName, caseSensitive) {77  const adjust = caseSensitive ? createAdjustMap(caseSensitive) : undefined78 79  /**80   * Hyperscript compatible DSL for creating virtual hast trees.81   *82   * @overload83   * @param {null | undefined} [selector]84   * @param {...Child} children85   * @returns {Root}86   *87   * @overload88   * @param {string} selector89   * @param {Properties} properties90   * @param {...Child} children91   * @returns {Element}92   *93   * @overload94   * @param {string} selector95   * @param {...Child} children96   * @returns {Element}97   *98   * @param {string | null | undefined} [selector]99   *   Selector.100   * @param {Child | Properties | null | undefined} [properties]101   *   Properties (or first child) (default: `undefined`).102   * @param {...Child} children103   *   Children.104   * @returns {Result}105   *   Result.106   */107  function h(selector, properties, ...children) {108    /** @type {Result} */109    let node110 111    if (selector === null || selector === undefined) {112      node = {type: 'root', children: []}113      // Properties are not supported for roots.114      const child = /** @type {Child} */ (properties)115      children.unshift(child)116    } else {117      node = parseSelector(selector, defaultTagName)118      // Normalize the name.119      const lower = node.tagName.toLowerCase()120      const adjusted = adjust ? adjust.get(lower) : undefined121      node.tagName = adjusted || lower122 123      // Handle properties.124      if (isChild(properties)) {125        children.unshift(properties)126      } else {127        for (const [key, value] of Object.entries(properties)) {128          addProperty(schema, node.properties, key, value)129        }130      }131    }132 133    // Handle children.134    for (const child of children) {135      addChild(node.children, child)136    }137 138    if (node.type === 'element' && node.tagName === 'template') {139      node.content = {type: 'root', children: node.children}140      node.children = []141    }142 143    return node144  }145 146  return h147}148 149/**150 * Check if something is properties or a child.151 *152 * @param {Child | Properties} value153 *   Value to check.154 * @returns {value is Child}155 *   Whether `value` is definitely a child.156 */157function isChild(value) {158  // Never properties if not an object.159  if (value === null || typeof value !== 'object' || Array.isArray(value)) {160    return true161  }162 163  // Never node without `type`; that’s the main discriminator.164  if (typeof value.type !== 'string') return false165 166  // Slower check: never property value if object or array with167  // non-number/strings.168  const record = /** @type {Record<string, unknown>} */ (value)169  const keys = Object.keys(value)170 171  for (const key of keys) {172    const value = record[key]173 174    if (value && typeof value === 'object') {175      if (!Array.isArray(value)) return true176 177      const list = /** @type {ReadonlyArray<unknown>} */ (value)178 179      for (const item of list) {180        if (typeof item !== 'number' && typeof item !== 'string') {181          return true182        }183      }184    }185  }186 187  // Also see empty `children` as a node.188  if ('children' in value && Array.isArray(value.children)) {189    return true190  }191 192  // Default to properties, someone can always pass an empty object,193  // put `data: {}` in a node,194  // or wrap it in an array.195  return false196}197 198/**199 * @param {Schema} schema200 *   Schema.201 * @param {Properties} properties202 *   Properties object.203 * @param {string} key204 *   Property name.205 * @param {PropertyValue | Style} value206 *   Property value.207 * @returns {undefined}208 *   Nothing.209 */210function addProperty(schema, properties, key, value) {211  const info = find(schema, key)212  /** @type {PropertyValue} */213  let result214 215  // Ignore nullish and NaN values.216  if (value === null || value === undefined) return217 218  if (typeof value === 'number') {219    // Ignore NaN.220    if (Number.isNaN(value)) return221 222    result = value223  }224  // Booleans.225  else if (typeof value === 'boolean') {226    result = value227  }228  // Handle list values.229  else if (typeof value === 'string') {230    if (info.spaceSeparated) {231      result = parseSpaces(value)232    } else if (info.commaSeparated) {233      result = parseCommas(value)234    } else if (info.commaOrSpaceSeparated) {235      result = parseSpaces(parseCommas(value).join(' '))236    } else {237      result = parsePrimitive(info, info.property, value)238    }239  } else if (Array.isArray(value)) {240    result = [...value]241  } else {242    result = info.property === 'style' ? style(value) : String(value)243  }244 245  if (Array.isArray(result)) {246    /** @type {Array<number | string>} */247    const finalResult = []248 249    for (const item of result) {250      // Assume no booleans in array.251      finalResult.push(252        /** @type {number | string} */ (253          parsePrimitive(info, info.property, item)254        )255      )256    }257 258    result = finalResult259  }260 261  // Class names (which can be added both on the `selector` and here).262  if (info.property === 'className' && Array.isArray(properties.className)) {263    // Assume no booleans in `className`.264    result = properties.className.concat(265      /** @type {Array<number | string> | number | string} */ (result)266    )267  }268 269  properties[info.property] = result270}271 272/**273 * @param {Array<RootContent>} nodes274 *   Children.275 * @param {Child} value276 *   Child.277 * @returns {undefined}278 *   Nothing.279 */280function addChild(nodes, value) {281  if (value === null || value === undefined) {282    // Empty.283  } else if (typeof value === 'number' || typeof value === 'string') {284    nodes.push({type: 'text', value: String(value)})285  } else if (Array.isArray(value)) {286    for (const child of value) {287      addChild(nodes, child)288    }289  } else if (typeof value === 'object' && 'type' in value) {290    if (value.type === 'root') {291      addChild(nodes, value.children)292    } else {293      nodes.push(value)294    }295  } else {296    throw new Error('Expected node, nodes, or string, got `' + value + '`')297  }298}299 300/**301 * Parse a single primitives.302 *303 * @param {Info} info304 *   Property information.305 * @param {string} name306 *   Property name.307 * @param {PrimitiveValue} value308 *   Property value.309 * @returns {PrimitiveValue}310 *   Property value.311 */312function parsePrimitive(info, name, value) {313  if (typeof value === 'string') {314    if (info.number && value && !Number.isNaN(Number(value))) {315      return Number(value)316    }317 318    if (319      (info.boolean || info.overloadedBoolean) &&320      (value === '' || normalize(value) === normalize(name))321    ) {322      return true323    }324  }325 326  return value327}328 329/**330 * Serialize a `style` object as a string.331 *332 * @param {Style} styles333 *   Style object.334 * @returns {string}335 *   CSS string.336 */337function style(styles) {338  /** @type {Array<string>} */339  const result = []340 341  for (const [key, value] of Object.entries(styles)) {342    result.push([key, value].join(': '))343  }344 345  return result.join('; ')346}347 348/**349 * Create a map to adjust casing.350 *351 * @param {ReadonlyArray<string>} values352 *   List of properly cased keys.353 * @returns {Map<string, string>}354 *   Map of lowercase keys to uppercase keys.355 */356function createAdjustMap(values) {357  /** @type {Map<string, string>} */358  const result = new Map()359 360  for (const value of values) {361    result.set(value.toLowerCase(), value)362  }363 364  return result365}366 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai