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
defineEnvironment.ts117 linesDownload Raw Back to src
1import {_htmlGroupBuilders, _mathmlGroupBuilders} from "./defineFunction";2 3import type Parser from "./Parser";4import type {AnyParseNode} from "./parseNode";5import type {ArgType, Mode} from "./types";6import type {NodeType} from "./parseNode";7import type {HtmlBuilder, MathMLBuilder} from "./defineFunction";8 9/**10 * The context contains the following properties:11 *  - mode: current parsing mode.12 *  - envName: the name of the environment, one of the listed names.13 *  - parser: the parser object.14 */15type EnvContext = {16    mode: Mode;17    envName: string;18    parser: Parser;19};20 21/**22 *  - context: information and references provided by the parser23 *  - args: an array of arguments passed to \begin{name}24 *  - optArgs: an array of optional arguments passed to \begin{name}25 */26type EnvHandler = (27    context: EnvContext,28    args: AnyParseNode[],29    optArgs: (AnyParseNode | null | undefined)[],30) => AnyParseNode;31 32/**33 *  - numArgs: (default 0) The number of arguments after the \begin{name} function.34 *  - argTypes: (optional) Just like for a function35 *  - allowedInText: (default false) Whether or not the environment is allowed36 *                   inside text mode (not enforced yet).37 *  - numOptionalArgs: (default 0) Just like for a function38 */39type EnvProps = {40    numArgs: number;41};42 43/**44 * Final environment spec for use at parse time.45 * This is almost identical to `EnvDefSpec`, except it46 * 1. includes the function handler47 * 2. requires all arguments except argType48 * It is generated by `defineEnvironment()` below.49 */50export type EnvSpec<NODETYPE extends NodeType> = {51    type: NODETYPE;52    // Need to use the type to avoid error. See NOTES below.53    numArgs: number;54    argTypes?: ArgType[];55    allowedInText: boolean;56    numOptionalArgs: number;57    handler: EnvHandler;58};59 60/**61 * All registered environments.62 * `environments.js` exports this same dictionary again and makes it public.63 * `Parser.js` requires this dictionary via `environments.js`.64 */65export const _environments: Record<string, EnvSpec<NodeType>> = {};66 67type EnvDefSpec<NODETYPE extends NodeType> = {68    // Unique string to differentiate parse nodes.69    type: NODETYPE;70 71    // List of functions which use the give handler, htmlBuilder,72    // and mathmlBuilder.73    names: Array<string>;74 75    // Properties that control how the environments are parsed.76    props: EnvProps;77    handler: EnvHandler;78 79    // This function returns an object representing the DOM structure to be80    // created when rendering the defined LaTeX function.81    htmlBuilder: HtmlBuilder<NODETYPE>;82 83    // This function returns an object representing the MathML structure to be84    // created when rendering the defined LaTeX function.85    mathmlBuilder: MathMLBuilder<NODETYPE>;86};87 88export default function defineEnvironment<NODETYPE extends NodeType>({89    type,90    names,91    props,92    handler,93    htmlBuilder,94    mathmlBuilder,95}: EnvDefSpec<NODETYPE>) {96    // Set default values of environments.97    const data = {98        type,99        numArgs: props.numArgs || 0,100        allowedInText: false,101        numOptionalArgs: 0,102        handler,103    };104    for (let i = 0; i < names.length; ++i) {105        // TODO: The value type of _environments should be a type union of all106        // possible `EnvSpec<>` possibilities instead of `EnvSpec<*>`, which is107        // an existential type.108        _environments[names[i]] = data;109    }110    if (htmlBuilder) {111        _htmlGroupBuilders[type] = htmlBuilder;112    }113    if (mathmlBuilder) {114        _mathmlGroupBuilders[type] = mathmlBuilder;115    }116}117 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai