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
csharp.js328 linesDownload Raw Back to codegen
1"use strict";2var __defProp = Object.defineProperty;3var __getOwnPropDesc = Object.getOwnPropertyDescriptor;4var __getOwnPropNames = Object.getOwnPropertyNames;5var __hasOwnProp = Object.prototype.hasOwnProperty;6var __export = (target, all) => {7  for (var name in all)8    __defProp(target, name, { get: all[name], enumerable: true });9};10var __copyProps = (to, from, except, desc) => {11  if (from && typeof from === "object" || typeof from === "function") {12    for (let key of __getOwnPropNames(from))13      if (!__hasOwnProp.call(to, key) && key !== except)14        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });15  }16  return to;17};18var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);19var csharp_exports = {};20__export(csharp_exports, {21  CSharpLanguageGenerator: () => CSharpLanguageGenerator22});23module.exports = __toCommonJS(csharp_exports);24var import_language = require("./language");25var import_utils = require("../../utils");26var import_deviceDescriptors = require("../deviceDescriptors");27class CSharpLanguageGenerator {28  constructor(mode) {29    this.groupName = ".NET C#";30    this.highlighter = "csharp";31    if (mode === "library") {32      this.name = "Library";33      this.id = "csharp";34    } else if (mode === "mstest") {35      this.name = "MSTest";36      this.id = "csharp-mstest";37    } else if (mode === "nunit") {38      this.name = "NUnit";39      this.id = "csharp-nunit";40    } else {41      throw new Error(`Unknown C# language mode: ${mode}`);42    }43    this._mode = mode;44  }45  generateAction(actionInContext) {46    const action = this._generateActionInner(actionInContext);47    if (action)48      return action;49    return "";50  }51  _generateActionInner(actionInContext) {52    const action = actionInContext.action;53    if (this._mode !== "library" && (action.name === "openPage" || action.name === "closePage"))54      return "";55    const pageAlias = this._formatPageAlias(actionInContext.frame.pageAlias);56    const formatter = new CSharpFormatter(this._mode === "library" ? 0 : 8);57    if (action.name === "openPage") {58      formatter.add(`var ${pageAlias} = await context.NewPageAsync();`);59      if (action.url && action.url !== "about:blank" && action.url !== "chrome://newtab/")60        formatter.add(`await ${pageAlias}.GotoAsync(${quote(action.url)});`);61      return formatter.format();62    }63    const locators = actionInContext.frame.framePath.map((selector) => `.${this._asLocator(selector)}.ContentFrame`);64    const subject = `${pageAlias}${locators.join("")}`;65    const signals = (0, import_language.toSignalMap)(action);66    if (signals.dialog) {67      formatter.add(`    void ${pageAlias}_Dialog${signals.dialog.dialogAlias}_EventHandler(object sender, IDialog dialog)68      {69          Console.WriteLine($"Dialog message: {dialog.Message}");70          dialog.DismissAsync();71          ${pageAlias}.Dialog -= ${pageAlias}_Dialog${signals.dialog.dialogAlias}_EventHandler;72      }73      ${pageAlias}.Dialog += ${pageAlias}_Dialog${signals.dialog.dialogAlias}_EventHandler;`);74    }75    const lines = [];76    lines.push(this._generateActionCall(subject, actionInContext));77    if (signals.download) {78      lines.unshift(`var download${signals.download.downloadAlias} = await ${pageAlias}.RunAndWaitForDownloadAsync(async () =>79{`);80      lines.push(`});`);81    }82    if (signals.popup) {83      lines.unshift(`var ${this._formatPageAlias(signals.popup.popupAlias)} = await ${pageAlias}.RunAndWaitForPopupAsync(async () =>84{`);85      lines.push(`});`);86    }87    for (const line of lines)88      formatter.add(line);89    return formatter.format();90  }91  _formatPageAlias(pageAlias) {92    if (this._mode === "library")93      return pageAlias;94    if (pageAlias === "page")95      return "Page";96    return pageAlias;97  }98  _generateActionCall(subject, actionInContext) {99    const action = actionInContext.action;100    switch (action.name) {101      case "openPage":102        throw Error("Not reached");103      case "closePage":104        return `await ${subject}.CloseAsync();`;105      case "click": {106        let method = "Click";107        if (action.clickCount === 2)108          method = "DblClick";109        const options = (0, import_language.toClickOptionsForSourceCode)(action);110        if (!Object.entries(options).length)111          return `await ${subject}.${this._asLocator(action.selector)}.${method}Async();`;112        const optionsString = formatObject(options, "    ");113        return `await ${subject}.${this._asLocator(action.selector)}.${method}Async(${optionsString});`;114      }115      case "hover": {116        const optionsString = action.position ? formatObject({ position: action.position }, "    ") : "";117        return `await ${subject}.${this._asLocator(action.selector)}.HoverAsync(${optionsString});`;118      }119      case "check":120        return `await ${subject}.${this._asLocator(action.selector)}.CheckAsync();`;121      case "uncheck":122        return `await ${subject}.${this._asLocator(action.selector)}.UncheckAsync();`;123      case "fill":124        return `await ${subject}.${this._asLocator(action.selector)}.FillAsync(${quote(action.text)});`;125      case "setInputFiles":126        return `await ${subject}.${this._asLocator(action.selector)}.SetInputFilesAsync(${formatObject(action.files)});`;127      case "press": {128        const modifiers = (0, import_language.toKeyboardModifiers)(action.modifiers);129        const shortcut = [...modifiers, action.key].join("+");130        return `await ${subject}.${this._asLocator(action.selector)}.PressAsync(${quote(shortcut)});`;131      }132      case "navigate":133        return `await ${subject}.GotoAsync(${quote(action.url)});`;134      case "select":135        return `await ${subject}.${this._asLocator(action.selector)}.SelectOptionAsync(${formatObject(action.options)});`;136      case "assertText":137        return `await Expect(${subject}.${this._asLocator(action.selector)}).${action.substring ? "ToContainTextAsync" : "ToHaveTextAsync"}(${quote(action.text)});`;138      case "assertChecked":139        return `await Expect(${subject}.${this._asLocator(action.selector)})${action.checked ? "" : ".Not"}.ToBeCheckedAsync();`;140      case "assertVisible":141        return `await Expect(${subject}.${this._asLocator(action.selector)}).ToBeVisibleAsync();`;142      case "assertValue": {143        const assertion = action.value ? `ToHaveValueAsync(${quote(action.value)})` : `ToBeEmptyAsync()`;144        return `await Expect(${subject}.${this._asLocator(action.selector)}).${assertion};`;145      }146      case "assertSnapshot":147        return `await Expect(${subject}.${this._asLocator(action.selector)}).ToMatchAriaSnapshotAsync(${quote(action.ariaSnapshot)});`;148    }149  }150  _asLocator(selector) {151    return (0, import_utils.asLocator)("csharp", selector);152  }153  generateHeader(options) {154    if (this._mode === "library")155      return this.generateStandaloneHeader(options);156    return this.generateTestRunnerHeader(options);157  }158  generateStandaloneHeader(options) {159    const formatter = new CSharpFormatter(0);160    formatter.add(`161      using Microsoft.Playwright;162      using System;163      using System.Threading.Tasks;164 165      using var playwright = await Playwright.CreateAsync();166      await using var browser = await playwright.${toPascal(options.browserName)}.LaunchAsync(${formatObject(options.launchOptions, "    ")});167      var context = await browser.NewContextAsync(${formatContextOptions(options.contextOptions, options.deviceName)});`);168    if (options.contextOptions.recordHar) {169      const url = options.contextOptions.recordHar.urlFilter;170      formatter.add(`      await context.RouteFromHARAsync(${quote(options.contextOptions.recordHar.path)}${url ? `, ${formatObject({ url }, "    ")}` : ""});`);171    }172    formatter.newLine();173    return formatter.format();174  }175  generateTestRunnerHeader(options) {176    const formatter = new CSharpFormatter(0);177    formatter.add(`178      using Microsoft.Playwright.${this._mode === "nunit" ? "NUnit" : "MSTest"};179      using Microsoft.Playwright;180 181      ${this._mode === "nunit" ? `[Parallelizable(ParallelScope.Self)]182      [TestFixture]` : "[TestClass]"}183      public class Tests : PageTest184      {`);185    const formattedContextOptions = formatContextOptions(options.contextOptions, options.deviceName);186    if (formattedContextOptions) {187      formatter.add(`public override BrowserNewContextOptions ContextOptions()188      {189          return ${formattedContextOptions};190      }`);191      formatter.newLine();192    }193    formatter.add(`    [${this._mode === "nunit" ? "Test" : "TestMethod"}]194    public async Task MyTest()195    {`);196    if (options.contextOptions.recordHar) {197      const url = options.contextOptions.recordHar.urlFilter;198      formatter.add(`    await Context.RouteFromHARAsync(${quote(options.contextOptions.recordHar.path)}${url ? `, ${formatObject({ url }, "    ")}` : ""});`);199    }200    return formatter.format();201  }202  generateFooter(saveStorage) {203    const offset = this._mode === "library" ? "" : "        ";204    let storageStateLine = saveStorage ? `205${offset}await context.StorageStateAsync(new()206${offset}{207${offset}    Path = ${quote(saveStorage)}208${offset}});209` : "";210    if (this._mode !== "library")211      storageStateLine += `    }212}213`;214    return storageStateLine;215  }216}217function formatObject(value, indent = "    ", name = "") {218  if (typeof value === "string") {219    if (["colorScheme", "modifiers", "button", "recordHarContent", "recordHarMode", "serviceWorkers"].includes(name))220      return `${getEnumName(name)}.${toPascal(value)}`;221    return quote(value);222  }223  if (Array.isArray(value))224    return `new[] { ${value.map((o) => formatObject(o, indent, name)).join(", ")} }`;225  if (typeof value === "object") {226    const keys = Object.keys(value).filter((key) => value[key] !== void 0).sort();227    if (!keys.length)228      return `new()`;229    const tokens = [];230    for (const key of keys) {231      const property = getPropertyName(key);232      tokens.push(`${property} = ${formatObject(value[key], indent, key)},`);233    }234    return `new()235{236${indent}${tokens.join(`237${indent}`)}238${indent}}`;239  }240  if (name === "latitude" || name === "longitude")241    return String(value) + "m";242  return String(value);243}244function getEnumName(value) {245  switch (value) {246    case "modifiers":247      return "KeyboardModifier";248    case "button":249      return "MouseButton";250    case "recordHarMode":251      return "HarMode";252    case "recordHarContent":253      return "HarContentPolicy";254    case "serviceWorkers":255      return "ServiceWorkerPolicy";256    default:257      return toPascal(value);258  }259}260function getPropertyName(key) {261  switch (key) {262    case "storageState":263      return "StorageStatePath";264    case "viewport":265      return "ViewportSize";266    default:267      return toPascal(key);268  }269}270function toPascal(value) {271  return value[0].toUpperCase() + value.slice(1);272}273function formatContextOptions(contextOptions, deviceName) {274  const options = { ...contextOptions };275  delete options.recordHar;276  const device = deviceName && import_deviceDescriptors.deviceDescriptors[deviceName];277  if (!device) {278    if (!Object.entries(options).length)279      return "";280    return formatObject(options, "    ");281  }282  if (!Object.entries((0, import_language.sanitizeDeviceOptions)(device, options)).length)283    return `playwright.Devices[${quote(deviceName)}]`;284  delete options["defaultBrowserType"];285  return formatObject(options, "    ");286}287class CSharpFormatter {288  constructor(offset = 0) {289    this._lines = [];290    this._baseIndent = " ".repeat(4);291    this._baseOffset = " ".repeat(offset);292  }293  prepend(text) {294    this._lines = text.trim().split("\n").map((line) => line.trim()).concat(this._lines);295  }296  add(text) {297    this._lines.push(...text.trim().split("\n").map((line) => line.trim()));298  }299  newLine() {300    this._lines.push("");301  }302  format() {303    let spaces = "";304    let previousLine = "";305    return this._lines.map((line) => {306      if (line === "")307        return line;308      if (line.startsWith("}") || line.startsWith("]") || line.includes("});") || line === ");")309        spaces = spaces.substring(this._baseIndent.length);310      const extraSpaces = /^(for|while|if).*\(.*\)$/.test(previousLine) ? this._baseIndent : "";311      previousLine = line;312      line = spaces + extraSpaces + line;313      if (line.endsWith("{") || line.endsWith("[") || line.endsWith("("))314        spaces += this._baseIndent;315      if (line.endsWith("));"))316        spaces = spaces.substring(this._baseIndent.length);317      return this._baseOffset + line;318    }).join("\n");319  }320}321function quote(text) {322  return (0, import_utils.escapeWithQuotes)(text, '"');323}324// Annotate the CommonJS export names for ESM import in node:3250 && (module.exports = {326  CSharpLanguageGenerator327});328 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai