From ff02ebd4b203aa4035886580724b4154b7330801 Mon Sep 17 00:00:00 2001 From: "Gilad S." <7817232+giladgd@users.noreply.github.com> Date: Thu, 31 Oct 2024 02:25:30 +0200 Subject: [PATCH] chore: update modules (#376) --- .eslintrc.json | 166 -- .github/workflows/build.yml | 2 - .github/workflows/test.yml | 6 +- .releaserc.ts | 2 + .../getElectronExampleAppDownloadLink.ts | 8 +- .vitepress/config.ts | 20 +- .vitepress/config/BlogPageInfoPlugin.ts | 17 +- .vitepress/config/apiReferenceSidebar.ts | 13 +- .vitepress/theme/index.ts | 1 + .vitepress/utils/getCommandHtmlDoc.ts | 10 +- .../utils/htmlEscapeWithCodeMarkdown.ts | 2 +- .vitepress/utils/parseCmakeListsTxtOptions.ts | 2 +- eslint.config.js | 206 ++ package-lock.json | 2229 +++++++++-------- package.json | 64 +- packages/create-node-llama-cpp/src/cli.ts | 1 + src/ChatWrapper.ts | 2 +- src/bindings/Llama.ts | 7 +- src/bindings/types.ts | 2 +- src/bindings/utils/clearAllLocalBuilds.ts | 4 +- src/bindings/utils/compileLLamaCpp.ts | 4 +- .../utils/detectAvailableComputeLayers.ts | 1 - .../utils/getGpuTypesToUseForOption.ts | 2 +- src/bindings/utils/testCmakeBinary.ts | 2 +- src/chatWrappers/FunctionaryChatWrapper.ts | 1 + src/chatWrappers/GemmaChatWrapper.ts | 2 +- ...hatModelFunctionsDocumentationGenerator.ts | 4 +- src/chatWrappers/utils/chunkChatItems.ts | 2 +- ...plateEquivalentToSpecializedChatWrapper.ts | 2 +- src/chatWrappers/utils/resolveChatWrapper.ts | 2 +- src/cli/commands/ChatCommand.ts | 3 +- src/cli/commands/CompleteCommand.ts | 3 +- src/cli/commands/InfillCommand.ts | 3 +- src/cli/utils/ConsoleInteraction.ts | 2 +- src/cli/utils/consolePromptQuestion.ts | 1 - src/cli/utils/interactivelyAskForModel.ts | 11 +- src/evaluator/LlamaChat/LlamaChat.ts | 7 +- ...KeepFirstSystemChatContextShiftStrategy.ts | 2 +- .../LlamaChatSession/LlamaChatSession.ts | 3 +- src/evaluator/LlamaCompletion.ts | 5 +- .../firstInFirstOutStrategy.ts | 2 +- .../maximumParallelismStrategy.ts | 2 +- src/evaluator/LlamaModel/LlamaModel.ts | 1 - .../LlamaModel/utils/TokenAttributes.ts | 2 +- src/gguf/fileReaders/GgufFileReader.ts | 2 +- .../GgufInsightsConfigurationResolver.ts | 6 +- src/gguf/insights/utils/scoreLevels.ts | 2 +- src/gguf/readGgufFileInfo.ts | 2 +- src/utils/LlamaText.ts | 2 +- src/utils/StopGenerationDetector.ts | 2 +- src/utils/ThreadsSplitter.ts | 4 +- src/utils/createModelDownloader.ts | 2 +- src/utils/gbnfJson/terminals/GbnfNumber.ts | 2 +- src/utils/gbnfJson/terminals/GbnfObjectMap.ts | 4 +- src/utils/gbnfJson/terminals/GbnfOr.ts | 8 +- src/utils/gbnfJson/types.ts | 2 +- src/utils/hashString.ts | 2 +- src/utils/spawnCommand.ts | 2 +- src/utils/transformPromisable.ts | 7 +- src/utils/waitForLockfileRelease.ts | 1 - .../electron-typescript-react/.eslintrc.json | 160 -- .../electron/index.ts | 2 +- .../eslint.config.js | 194 ++ .../electron-typescript-react/package.json | 39 +- .../electron-typescript-react/src/App/App.tsx | 10 +- .../components/ChatHistory/ChatHistory.tsx | 3 +- .../src/App/components/Header/Header.tsx | 6 +- .../src/App/components/InputRow/InputRow.tsx | 2 +- .../src/icons/AbortIconSVG.tsx | 2 +- .../src/icons/AddMessageIconSVG.tsx | 2 +- .../src/icons/CheckIconSVG.tsx | 2 +- .../src/icons/CopyIconSVG.tsx | 2 +- .../src/icons/DeleteIconSVG.tsx | 2 +- .../src/icons/DownloadIconSVG.tsx | 2 +- .../src/icons/LoadFileIconSVG.tsx | 2 +- .../src/icons/SearchIconSVG.tsx | 2 +- .../src/icons/StarIconSVG.tsx | 2 +- templates/node-typescript/.eslintrc.json | 153 -- templates/node-typescript/eslint.config.js | 181 ++ templates/node-typescript/package.json | 23 +- .../functionaryModelGpuLayersOptions.test.ts | 3 +- .../stableCodeModelGpuLayersOptions.test.ts | 3 +- test/standalone/utils/ThreadsSplitter.test.ts | 14 +- 83 files changed, 1970 insertions(+), 1724 deletions(-) delete mode 100644 .eslintrc.json create mode 100644 eslint.config.js delete mode 100644 templates/electron-typescript-react/.eslintrc.json create mode 100644 templates/electron-typescript-react/eslint.config.js delete mode 100644 templates/node-typescript/.eslintrc.json create mode 100644 templates/node-typescript/eslint.config.js diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index a974ecd3..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,166 +0,0 @@ -{ - "root": true, - "env": { - "node": true, - "browser": false, - "es6": true - }, - "ignorePatterns": [ - "/dist", - "/llama", - "/docs-site", - "/packages/create-node-llama-cpp/dist", - "/packages/@node-llama-cpp/*/dist" - ], - "extends": [ - "eslint:recommended", - "plugin:jsdoc/recommended" - ], - "globals": { - "Atomics": "readonly", - "SharedArrayBuffer": "readonly" - }, - "parserOptions": { - "ecmaVersion": 2023, - "sourceType": "module" - }, - "overrides": [{ - "files": ["**.ts"], - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "plugin:jsdoc/recommended-typescript" - ], - "parser": "@typescript-eslint/parser", - "plugins": [ - "@typescript-eslint", - "import", - "jsdoc", - "n" - ], - "rules": { - "@typescript-eslint/explicit-module-boundary-types": ["off"], - "@typescript-eslint/ban-ts-comment": ["off"], - "@typescript-eslint/no-explicit-any": ["off"], - "semi": ["off"], - "@typescript-eslint/semi": ["warn", "always"], - "@typescript-eslint/no-inferrable-types": ["off"], - "@typescript-eslint/member-ordering": ["warn", { - "default": ["field", "constructor", "method", "signature"], - "typeLiterals": [] - }], - "@typescript-eslint/parameter-properties": ["warn", { - "allow": [] - }], - "@typescript-eslint/explicit-member-accessibility": ["warn"], - "@typescript-eslint/member-delimiter-style": ["warn", { - "multiline": { - "delimiter": "comma", - "requireLast": false - }, - "singleline": { - "delimiter": "comma", - "requireLast": false - }, - "multilineDetection": "brackets" - }], - "jsdoc/require-param": ["off"], - "jsdoc/check-param-names": ["warn", { - "checkDestructured": false - }], - "jsdoc/require-returns": ["off"], - "jsdoc/require-jsdoc": ["off"], - "jsdoc/require-yields": ["off"], - "jsdoc/require-param-description": ["off"] - } - }, { - "files": ["test/**/**.ts"], - "rules": { - "max-len": ["off"] - } - }], - "plugins": [ - "@typescript-eslint", - "import", - "jsdoc", - "n" - ], - "settings": { - "import/parsers": { - "@typescript-eslint/parser": [".ts"] - }, - "jsdoc": { - "exemptDestructuredRootsFromChecks": true, - "tagNamePreference": { - "hidden": "hidden" - } - } - }, - "rules": { - "indent": ["warn", 4, { - "SwitchCase": 1, - "FunctionDeclaration": { - "parameters": "first" - } - }], - "eqeqeq": ["off"], - "no-undef": "off", - "quotes": ["warn", "double", { "avoidEscape": true }], - "no-unused-vars": ["warn", { - "args": "none", - "ignoreRestSiblings": true, - "varsIgnorePattern": "^set" - }], - "no-prototype-builtins": ["off"], - "object-curly-spacing": ["warn", "never"], - "semi": ["warn", "always"], - "no-undefined": ["off"], - "array-bracket-newline": ["error", "consistent"], - "brace-style": ["error", "1tbs", { - "allowSingleLine": false - }], - "comma-spacing": ["error", { - "before": false, - "after": true - }], - "comma-style": ["error", "last"], - "comma-dangle": ["error", "never"], - "no-var": ["error"], - "import/order": ["error", { - "groups": ["builtin", "external","internal", "parent", "sibling", "index", "type", "object", "unknown"], - "warnOnUnassignedImports": true - }], - "n/file-extension-in-import": ["error", "always"], - "newline-per-chained-call": ["error", { - "ignoreChainWithDepth": 2 - }], - "no-confusing-arrow": ["error"], - "no-const-assign": ["error"], - "no-duplicate-imports": ["error", { - "includeExports": true - }], - "camelcase": ["warn", { - "allow": ["\\d+_\\d+"] - }], - "jsx-quotes": ["warn"], - "yoda": ["error", "never", { - "exceptRange": true - }], - "no-eval": ["error"], - "array-callback-return": ["error"], - "no-empty": ["error", { - "allowEmptyCatch": true - }], - "keyword-spacing": ["warn"], - "space-infix-ops": ["warn"], - "spaced-comment": ["warn", "always", { - "markers": ["/"] - }], - "eol-last": ["warn", "always"], - "max-len": ["warn", { - "code": 140, - "tabWidth": 4, - "ignoreStrings": true - }] - } -} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2814133f..8c5270ea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -711,7 +711,6 @@ jobs: export DOCS_PACKAGE_VERSION="$(cat ./docsVersion.txt)" echo "Package version: $DOCS_PACKAGE_VERSION" - git apply --ignore-whitespace ./scripts/patches/vitepress+1.3.4.patch npm run docs:build - name: Upload docs to GitHub Pages uses: actions/upload-pages-artifact@v3 @@ -792,7 +791,6 @@ jobs: export DOCS_PACKAGE_VERSION="$(cat ./docsVersion.txt)" echo "Package version: $DOCS_PACKAGE_VERSION" - git apply --ignore-whitespace ./scripts/patches/vitepress+1.3.4.patch npm run docs:build - name: Upload docs to GitHub Pages uses: actions/upload-pages-artifact@v3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f8f7f3cc..a29ffda6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: - name: Install modules run: npm ci - name: ESLint - run: npx eslint --ext .js --ext .ts . + run: npx eslint - name: TypeScript validity run: npm run test:typescript @@ -44,6 +44,4 @@ jobs: CI: true run: node ./dist/cli/cli.js source download --release latest --skipBuild --noBundle --noUsageExample --updateBinariesReleaseMetadataAndSaveGitBundle - name: Compile docs - run: | - git apply --ignore-whitespace ./scripts/patches/vitepress+1.3.4.patch - npm run docs:build + run: npm run docs:build diff --git a/.releaserc.ts b/.releaserc.ts index c79c05ef..1510c20b 100644 --- a/.releaserc.ts +++ b/.releaserc.ts @@ -26,9 +26,11 @@ const homepageUrlWithoutTrailingSlash = homepageUrl.endsWith("/") ? homepageUrl.slice(0, -1) : homepageUrl; +/* eslint-disable @stylistic/max-len */ const newFooterTemplate = defaultFooterTemplate + "\n---\n\n" + `Shipped with \`llama.cpp\` release [\`${binariesSourceRelease.split("`").join("")}\`](https://github.com/${defaultLlamaCppGitHubRepo}/releases/tag/${encodeURIComponent(binariesSourceRelease)})\n\n` + `> To use the latest \`llama.cpp\` release available, run \`npx -n ${cliBinName} source download --release latest\`. ([learn more](${homepageUrlWithoutTrailingSlash}/guide/building-from-source#download-new-release))\n`; +/* eslint-enable @stylistic/max-len */ const githubPluginConfig = { discussionCategoryName: "Releases" as string | boolean diff --git a/.vitepress/components/HomePage/utils/getElectronExampleAppDownloadLink.ts b/.vitepress/components/HomePage/utils/getElectronExampleAppDownloadLink.ts index 14c1a19d..2ed9d073 100644 --- a/.vitepress/components/HomePage/utils/getElectronExampleAppDownloadLink.ts +++ b/.vitepress/components/HomePage/utils/getElectronExampleAppDownloadLink.ts @@ -35,7 +35,7 @@ export async function getElectronExampleAppDownloadLink() { const isMacOs = platformInfo?.platform != null ? platformInfo.platform === "macOS" - : (navigator.userAgent.includes("Mac OS X") || navigator.userAgent.includes("Macintosh")) + : (navigator.userAgent.includes("Mac OS X") || navigator.userAgent.includes("Macintosh")); const isWindows = platformInfo?.platform != null ? platformInfo.platform === "Windows" : navigator.userAgent.includes("Windows"); @@ -73,17 +73,17 @@ export async function getElectronExampleAppDownloadLink() { relevantAssets = assets .filter((asset) => asset.name.includes(".macOS.")) .filter(filterByArchitecture) - .filter((asset) => asset.name.endsWith(".dmg")) + .filter((asset) => asset.name.endsWith(".dmg")); } else if (isWindows) { relevantAssets = assets .filter((asset) => asset.name.includes(".Windows.")) .filter(filterByArchitecture) - .filter((asset) => asset.name.endsWith(".exe")) + .filter((asset) => asset.name.endsWith(".exe")); } else if (isLinux) { relevantAssets = assets .filter((asset) => asset.name.includes(".Linux.")) .filter(filterByArchitecture) - .filter((asset) => asset.name.endsWith(".AppImage")) + .filter((asset) => asset.name.endsWith(".AppImage")); } if (relevantAssets.length > 0 && relevantAssets[0]!.browser_download_url != null) diff --git a/.vitepress/config.ts b/.vitepress/config.ts index b51b0940..433fa506 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -1,22 +1,22 @@ -import {createContentLoader, defineConfig, HeadConfig} from "vitepress"; import path from "path"; import {createRequire} from "node:module"; import process from "process"; -import fs from "fs-extra"; import {fileURLToPath} from "url"; +import fs from "fs-extra"; +import {createContentLoader, defineConfig, HeadConfig} from "vitepress"; import {transformerTwoslash} from "@shikijs/vitepress-twoslash"; import ts from "typescript"; import envVar from "env-var"; import {Feed} from "feed"; import {rehype} from "rehype"; -import {Element as HastElement, Parent} from "hast"; import sharp from "sharp"; import {GitChangelog, GitChangelogMarkdownSection} from "@nolebase/vitepress-plugin-git-changelog/vite"; import {buildEndGenerateOpenGraphImages} from "@nolebase/vitepress-plugin-og-image/vitepress"; -import {Resvg, initWasm as initResvgWasm, ResvgRenderOptions} from "@resvg/resvg-wasm"; +import {Resvg, initWasm as initResvgWasm, type ResvgRenderOptions} from "@resvg/resvg-wasm"; import {BlogPageInfoPlugin} from "./config/BlogPageInfoPlugin.js"; import {getApiReferenceSidebar} from "./config/apiReferenceSidebar.js"; import {ensureLocalImage} from "./utils/ensureLocalImage.js"; +import type {Element as HastElement, Parent} from "hast"; import type {Node as UnistNode} from "unist"; import type {ShikiTransformer} from "shiki"; @@ -34,7 +34,7 @@ const packageVersion = env.get("DOCS_PACKAGE_VERSION") .default(packageJson.version) .asString(); -const hostname = "https://node-llama-cpp.withcat.ai/" +const hostname = "https://node-llama-cpp.withcat.ai/"; const buildDate = new Date(); const socialPosterLink = hostname + "social.poster.jpg"; @@ -178,7 +178,7 @@ export default defineConfig({ "window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}gtag('js',new Date());" + "gtag('config','G-Q2SWE5Z1ST');" ], - ["style", {}], + ["style", {}] ], async transformHead({pageData, head}) { if (pageData.filePath === "index.md") { @@ -263,7 +263,7 @@ export default defineConfig({ pageData.frontmatter.editLink = false; pageData.frontmatter.lastUpdated = false; pageData.frontmatter.aside = false; - pageData.frontmatter.outline = false + pageData.frontmatter.outline = false; pageData.frontmatter.nolebase = { gitChangelog: false }; @@ -507,7 +507,7 @@ export default defineConfig({ "inter-latin-ext-400-normal.woff2", "inter-latin-ext-500-normal.woff2", "inter-latin-ext-600-normal.woff2", - "inter-latin-ext-700-normal.woff2", + "inter-latin-ext-700-normal.woff2" ]; return await Promise.all( @@ -532,7 +532,7 @@ export default defineConfig({ const innerSvgImages = loadInnerSvgImages(); async function renderSvg(svgPath: string, destPngPath: string, options: ResvgRenderOptions) { - console.info(`Rendering "${svgPath}" to "${destPngPath}"`) + console.info(`Rendering "${svgPath}" to "${destPngPath}"`); const svgContent = await fs.readFile(svgPath, "utf8"); const svgImages = await innerSvgImages; @@ -665,7 +665,7 @@ export default defineConfig({ author: { name: typeof packageJson.author === "string" ? packageJson.author - : (packageJson.author as undefined | { name?: string })?.name + : (packageJson.author as undefined | {name?: string})?.name }, hub: "https://pubsubhubbub.appspot.com/" }); diff --git a/.vitepress/config/BlogPageInfoPlugin.ts b/.vitepress/config/BlogPageInfoPlugin.ts index 93046434..7e875d1c 100644 --- a/.vitepress/config/BlogPageInfoPlugin.ts +++ b/.vitepress/config/BlogPageInfoPlugin.ts @@ -1,6 +1,5 @@ -import {MarkdownEnv, Plugin} from "vitepress"; import path from "path"; -import {htmlEscape} from "../utils/htmlEscape.js"; +import {MarkdownEnv, Plugin} from "vitepress"; import {getMarkdownRenderer} from "../utils/getMarkdownRenderer.js"; import {renderHtmlTag} from "../utils/renderHtmlTag.js"; import {ensureLocalImage, resolveImageBuffers, relativeToAbsoluteImageUrls} from "../utils/ensureLocalImage.js"; @@ -8,7 +7,7 @@ import {ensureLocalImage, resolveImageBuffers, relativeToAbsoluteImageUrls} from export function BlogPageInfoPlugin({ include }: { - include(id: string): boolean, + include(id: string): boolean }): Plugin { const refIdToUrlPath = new Map(); let root = ""; @@ -84,12 +83,13 @@ export function BlogPageInfoPlugin({ const frontmatterCode = code.slice(0, frontmatterEndIndex); const markdownCode = code.slice(frontmatterEndIndex); + const frontmatterDate = new Date(frontmatter.date); let newCode = frontmatterCode + ( "# " + frontmatter.title + "\n\n" + [ "", '