From 3844208a3b9b3daaff085daad8ab933f27fcb5f3 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 13 Aug 2024 10:27:28 -0700 Subject: [PATCH 1/3] feat: improve chunking desc on large projects --- core/indexing/chunk/ChunkCodebaseIndex.ts | 67 +++++++++++++++++------ 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/core/indexing/chunk/ChunkCodebaseIndex.ts b/core/indexing/chunk/ChunkCodebaseIndex.ts index 0e866b3bf..4fbc10266 100644 --- a/core/indexing/chunk/ChunkCodebaseIndex.ts +++ b/core/indexing/chunk/ChunkCodebaseIndex.ts @@ -2,7 +2,6 @@ import { RunResult } from "sqlite3"; import { IContinueServerClient } from "../../continueServer/interface.js"; import { Chunk, IndexTag, IndexingProgressUpdate } from "../../index.js"; import { getBasename } from "../../util/index.js"; -import { getLanguageForFile } from "../../util/treeSitter.js"; import { DatabaseConnection, SqliteDb, tagToString } from "../refreshIndex.js"; import { IndexResultType, @@ -12,6 +11,7 @@ import { type CodebaseIndex, } from "../types.js"; import { chunkDocument, shouldChunk } from "./chunk.js"; +import * as path from "path"; export class ChunkCodebaseIndex implements CodebaseIndex { relativeExpectedTime: number = 1; @@ -61,8 +61,11 @@ export class ChunkCodebaseIndex implements CodebaseIndex { let accumulatedProgress = 0; if (results.compute.length > 0) { + const folderPath = results.compute[0].path; + const folderName = path.basename(path.dirname(folderPath)); + yield { - desc: `Chunking ${results.compute.length} ${this.formatListPlurality("file", results.compute.length)}`, + desc: `Chunking files in ${folderName}`, status: "indexing", progress: accumulatedProgress, }; @@ -171,11 +174,17 @@ export class ChunkCodebaseIndex implements CodebaseIndex { } private async computeChunks(paths: PathAndCacheKey[]): Promise { - const chunkLists = await Promise.all(paths.map(p => this.packToChunks(p))); + const chunkLists = await Promise.all( + paths.map((p) => this.packToChunks(p)), + ); return chunkLists.flat(); } - private async insertChunks(db: DatabaseConnection, tagString: string, chunks: Chunk[]) { + private async insertChunks( + db: DatabaseConnection, + tagString: string, + chunks: Chunk[], + ) { await new Promise((resolve, reject) => { db.db.serialize(() => { db.db.exec("BEGIN", (err: Error | null) => { @@ -183,23 +192,45 @@ export class ChunkCodebaseIndex implements CodebaseIndex { reject(new Error("error creating transaction", { cause: err })); } }); - const chunksSQL = "INSERT INTO chunks (cacheKey, path, idx, startLine, endLine, content) VALUES (?, ?, ?, ?, ?, ?)"; - chunks.map(c => { - db.db.run(chunksSQL, [c.digest, c.filepath, c.index, c.startLine, c.endLine, c.content], (result: RunResult, err: Error) => { - if (err) { - reject(new Error("error inserting into chunks table", { cause: err })); - } - }); - const chunkTagsSQL = "INSERT INTO chunk_tags (chunkId, tag) VALUES (last_insert_rowid(), ?)"; - db.db.run(chunkTagsSQL, [ tagString ], (result: RunResult, err: Error) => { - if (err) { - reject(new Error("error inserting into chunk_tags table", { cause: err })); - } - }); + const chunksSQL = + "INSERT INTO chunks (cacheKey, path, idx, startLine, endLine, content) VALUES (?, ?, ?, ?, ?, ?)"; + chunks.map((c) => { + db.db.run( + chunksSQL, + [c.digest, c.filepath, c.index, c.startLine, c.endLine, c.content], + (result: RunResult, err: Error) => { + if (err) { + reject( + new Error("error inserting into chunks table", { + cause: err, + }), + ); + } + }, + ); + const chunkTagsSQL = + "INSERT INTO chunk_tags (chunkId, tag) VALUES (last_insert_rowid(), ?)"; + db.db.run( + chunkTagsSQL, + [tagString], + (result: RunResult, err: Error) => { + if (err) { + reject( + new Error("error inserting into chunk_tags table", { + cause: err, + }), + ); + } + }, + ); }); db.db.exec("COMMIT", (err: Error | null) => { if (err) { - reject(new Error("error while committing insert chunks transaction", { cause: err })); + reject( + new Error("error while committing insert chunks transaction", { + cause: err, + }), + ); } else { resolve(); } From 333ba5d6da53576a45a9d5b16163c710aa2ec7cb Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 13 Aug 2024 10:30:54 -0700 Subject: [PATCH 2/3] Update ChunkCodebaseIndex.ts --- core/indexing/chunk/ChunkCodebaseIndex.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/indexing/chunk/ChunkCodebaseIndex.ts b/core/indexing/chunk/ChunkCodebaseIndex.ts index 4fbc10266..498e5144e 100644 --- a/core/indexing/chunk/ChunkCodebaseIndex.ts +++ b/core/indexing/chunk/ChunkCodebaseIndex.ts @@ -61,8 +61,8 @@ export class ChunkCodebaseIndex implements CodebaseIndex { let accumulatedProgress = 0; if (results.compute.length > 0) { - const folderPath = results.compute[0].path; - const folderName = path.basename(path.dirname(folderPath)); + const filepath = results.compute[0].path; + const folderName = path.basename(path.dirname(filepath)); yield { desc: `Chunking files in ${folderName}`, From 7c738e887486211d86b2e71b8d47a0e14d863172 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 13 Aug 2024 10:47:10 -0700 Subject: [PATCH 3/3] Update azure.md --- docs/docs/reference/Model Providers/azure.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/reference/Model Providers/azure.md b/docs/docs/reference/Model Providers/azure.md index 1f1518c92..7142b7718 100644 --- a/docs/docs/reference/Model Providers/azure.md +++ b/docs/docs/reference/Model Providers/azure.md @@ -20,7 +20,7 @@ You can configure Azure OpenAI service through the UI, or you can configure it m "apiBase": "", "engine": "", "apiVersion": "", - "apiType": "azure", + "apiType": "openai", "apiKey": "" }] ```