Merge branch 'dev' of https://github.com/continuedev/continue into dev
This commit is contained in:
commit
df63182de3
2 changed files with 50 additions and 19 deletions
|
|
@ -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 filepath = results.compute[0].path;
|
||||
const folderName = path.basename(path.dirname(filepath));
|
||||
|
||||
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<Chunk[]> {
|
||||
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<void>((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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ You can configure Azure OpenAI service through the UI, or you can configure it m
|
|||
"apiBase": "<YOUR_DEPLOYMENT_BASE>",
|
||||
"engine": "<YOUR_ENGINE>",
|
||||
"apiVersion": "<YOUR_API_VERSION>",
|
||||
"apiType": "azure",
|
||||
"apiType": "openai",
|
||||
"apiKey": "<MY_API_KEY>"
|
||||
}]
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue