From 0bce1dc9c2e94e12e484fe8457dde5d6bc1d8f2f Mon Sep 17 00:00:00 2001 From: Maxx Rodriguez Date: Tue, 13 Aug 2024 17:24:52 -0700 Subject: [PATCH 1/2] - added copyTokenizers to util - added workerpools to be copied over from core - import and execute copyTokenizers in prepackage-cross-plat --- .../vscode/scripts/prepackage-cross-platform.js | 4 ++++ extensions/vscode/scripts/utils.js | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/extensions/vscode/scripts/prepackage-cross-platform.js b/extensions/vscode/scripts/prepackage-cross-platform.js index 59089dd62..018ea70c2 100644 --- a/extensions/vscode/scripts/prepackage-cross-platform.js +++ b/extensions/vscode/scripts/prepackage-cross-platform.js @@ -24,6 +24,7 @@ const { copySqliteBinary, installNodeModuleInTempDirAndCopyToCurrent, downloadSqliteBinary, + copyTokenizers, } = require("./utils"); // Clear folders that will be packaged to ensure clean slate @@ -104,6 +105,9 @@ async function package(target, os, arch, exe) { // *** onnxruntime-node *** await copyOnnxRuntimeFromNodeModules(target); + // copy llama tokenizers to out + copyTokenizers(); + // *** Install @lancedb binary *** const lancePackageToInstall = { "darwin-arm64": "@lancedb/vectordb-darwin-arm64", diff --git a/extensions/vscode/scripts/utils.js b/extensions/vscode/scripts/utils.js index b0d7def7d..6a129bc61 100644 --- a/extensions/vscode/scripts/utils.js +++ b/extensions/vscode/scripts/utils.js @@ -39,6 +39,20 @@ function copyConfigSchema() { fs.writeFileSync("continue_rc_schema.json", JSON.stringify(schema, null, 2)); } +function copyTokenizers() { + fs.copyFileSync( + path.join(__dirname, "../../../core/llm/llamaTokenizerWorkerPool.mjs"), + path.join(__dirname, "../out/llamaTokenizerWorkerPool.mjs"), + ); + console.log("[info] Copied llamaTokenizerWorkerPool"); + + fs.copyFileSync( + path.join(__dirname, "../../../core/llm/llamaTokenizer.mjs"), + path.join(__dirname, "../out/llamaTokenizer.mjs"), + ); + console.log("[info] Copied llamaTokenizer"); +} + function installNodeModules() { // Make sure we are in the right directory if (!process.cwd().endsWith("vscode")) { @@ -242,6 +256,7 @@ async function copyNodeModules() { "@esbuild", "@lancedb", "@vscode/ripgrep", + "workerpool" ]; fs.mkdirSync("out/node_modules", { recursive: true }); @@ -497,4 +512,5 @@ module.exports = { installNodeModuleInTempDirAndCopyToCurrent, downloadSqliteBinary, downloadRipgrepBinary, + copyTokenizers }; From 0b6522f13499ef8dace93be50e205fc6b45a1763 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Thu, 15 Aug 2024 17:39:22 -0700 Subject: [PATCH 2/2] fix lancedb indexing bug --- core/indexing/LanceDbIndex.ts | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/core/indexing/LanceDbIndex.ts b/core/indexing/LanceDbIndex.ts index 12f8b1668..13a07c54d 100644 --- a/core/indexing/LanceDbIndex.ts +++ b/core/indexing/LanceDbIndex.ts @@ -216,7 +216,7 @@ export class LanceDbIndex implements CodebaseIndex { let needToCreateTable = !existingTables.includes(tableName); const addComputedLanceDbRows = async ( - pathAndCacheKey: PathAndCacheKey, + pathAndCacheKeys: PathAndCacheKey[], computedRows: LanceDbRow[], ) => { // Create table if needed, add computed rows @@ -236,7 +236,7 @@ export class LanceDbIndex implements CodebaseIndex { } // Mark item complete - await markComplete([pathAndCacheKey], IndexResultType.Compute); + await markComplete(pathAndCacheKeys, IndexResultType.Compute); }; // Check remote cache @@ -285,7 +285,7 @@ export class LanceDbIndex implements CodebaseIndex { ); } - await addComputedLanceDbRows({ cacheKey, path }, rows); + await addComputedLanceDbRows([{ cacheKey, path }], rows); } // Remove items that don't need to be recomputed @@ -307,18 +307,7 @@ export class LanceDbIndex implements CodebaseIndex { const dbRows = await this.computeRows(results.compute); await this.insertRows(sqlite, dbRows); - await Promise.all( - results.compute.map((result) => { - addComputedLanceDbRows( - result, - dbRows.filter( - (row) => - row.path === result.path && row.cachekey === result.cacheKey, - ), - ); - }), - ); - await markComplete(results.compute, IndexResultType.Compute); + await addComputedLanceDbRows(results.compute, dbRows); let accumulatedProgress = 0; // Add tag - retrieve the computed info from lance sqlite cache