✅ checkpoint with web-tree-sitter working

This commit is contained in:
Nate Sesti 2024-02-29 09:45:35 -05:00
parent a03d0b8cc3
commit 21c92103b3
12 changed files with 702 additions and 6214 deletions

View file

@ -6,8 +6,7 @@ import {
} from "../..";
import { getBasename } from "../../util";
import { getHighlightsThatFit, ILLMContextSizer } from "llm-code-highlighter/dist/index.continue";
import { countTokens } from "../../llm/countTokens";
// import { getHighlightsThatFit, ILLMContextSizer } from "llm-code-highlighter/dist/index.continue";
const HIGHLIGHTS_TOKEN_BUDGET = 2000;
@ -35,30 +34,31 @@ class CodeHighlightsContextProvider extends BaseContextProvider {
};
})
);
const contextSizer = {
fits(content: string): boolean {
return countTokens(content, "") < HIGHLIGHTS_TOKEN_BUDGET;
}
} as ILLMContextSizer
const repoMap = await getHighlightsThatFit(
contextSizer,
[],
allFiles
.filter((file) => file.content.length > 0)
.map((file) => {
return {
relPath: file.name,
code: file.content,
};
})
);
return [
{
content: repoMap ? repoMap : "",
name: "Code Highlights",
description: "Code highlights from open files",
},
];
// const contextSizer = {
// fits(content: string): boolean {
// return countTokens(content, "") < HIGHLIGHTS_TOKEN_BUDGET;
// }
// } as ILLMContextSizer
// const repoMap = await getHighlightsThatFit(
// contextSizer,
// [],
// allFiles
// .filter((file) => file.content.length > 0)
// .map((file) => {
// return {
// relPath: file.name,
// code: file.content,
// };
// })
// );
// return [
// {
// content: repoMap ? repoMap : "",
// name: "Code Highlights",
// description: "Code highlights from open files",
// },
// ];
return []
}
async load(): Promise<void> {}

View file

@ -6,7 +6,7 @@ import {
} from "../..";
import { getBasename } from "../../util";
import { getOutlines } from "llm-code-highlighter/dist/index.continue";
// import { getOutlines } from "llm-code-highlighter/dist/index.continue";
class CodeOutlineContextProvider extends BaseContextProvider {
static description: ContextProviderDescription = {
@ -32,23 +32,24 @@ class CodeOutlineContextProvider extends BaseContextProvider {
};
})
);
const outlines = await getOutlines(
allFiles
.filter((file) => file.content.length > 0)
.map((file) => {
return {
relPath: file.name,
code: file.content,
};
})
);
return [
{
content: outlines ? outlines : "",
name: "Code Outline",
description: "Definition lines only (from open files)",
},
];
// const outlines = await getOutlines(
// allFiles
// .filter((file) => file.content.length > 0)
// .map((file) => {
// return {
// relPath: file.name,
// code: file.content,
// };
// })
// );
// return [
// {
// content: outlines ? outlines : "",
// name: "Code Outline",
// description: "Definition lines only (from open files)",
// },
// ];
return []
}
async load(): Promise<void> {}

View file

@ -1,7 +1,5 @@
import { BaseContextProvider } from "..";
import { ContextProviderName } from "../..";
import CodeHighlightsContextProvider from "./CodeHighlightsContextProvider";
import CodeOutlineContextProvider from "./CodeOutlineContextProvider";
import CodebaseContextProvider from "./CodebaseContextProvider";
import DatabaseContextProvider from "./DatabaseContextProvider";
import DiffContextProvider from "./DiffContextProvider";
@ -33,8 +31,8 @@ const Providers: (typeof BaseContextProvider)[] = [
ProblemsContextProvider,
FolderContextProvider,
DocsContextProvider,
CodeHighlightsContextProvider,
CodeOutlineContextProvider,
// CodeHighlightsContextProvider,
// CodeOutlineContextProvider,
JiraIssuesContextProvider,
PostgresContextProvider,
DatabaseContextProvider,

1295
core/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -35,7 +35,6 @@
"https-proxy-agent": "^7.0.3",
"js-tiktoken": "^1.0.8",
"llama-tokenizer-js": "^1.1.3",
"llm-code-highlighter": "^0.0.13",
"node-fetch": "^3.3.2",
"node-html-markdown": "^1.3.0",
"ollama": "^0.4.6",
@ -49,7 +48,7 @@
"tree-sitter-wasms": "^0.1.6",
"uuid": "^9.0.1",
"vectordb": "^0.4.3",
"web-tree-sitter": "^0.20.8"
"web-tree-sitter": "^0.21.0"
},
"puppeteer": {
"chromium_revision": "119.0.6045.105"

View file

@ -1,5 +1,5 @@
import * as path from "path";
import Parser, { init, Language } from "web-tree-sitter";
const Parser = require("web-tree-sitter")
export const supportedLanguages: { [key: string]: string } = {
cpp: "cpp",
@ -68,7 +68,7 @@ export const supportedLanguages: { [key: string]: string } = {
};
export async function getParserForFile(filepath: string) {
await init();
await Parser.init();
const parser = new Parser();
const extension = path.extname(filepath).slice(1);
@ -87,7 +87,7 @@ export async function getParserForFile(filepath: string) {
"tree-sitter-wasms",
`tree-sitter-${supportedLanguages[extension]}.wasm`
);
const language = await Language.load(wasmPath);
const language = await Parser.Language.load(wasmPath);
parser.setLanguage(language);
return parser;
}

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -102,7 +102,6 @@
"https-proxy-agent": "^7.0.3",
"js-tiktoken": "^1.0.8",
"llama-tokenizer-js": "^1.1.3",
"llm-code-highlighter": "^0.0.13",
"node-fetch": "^3.3.2",
"node-html-markdown": "^1.3.0",
"ollama": "^0.4.6",
@ -116,7 +115,7 @@
"tree-sitter-wasms": "^0.1.6",
"uuid": "^9.0.1",
"vectordb": "^0.4.3",
"web-tree-sitter": "^0.20.8"
"web-tree-sitter": "^0.21.0"
},
"devDependencies": {
"@types/follow-redirects": "^1.14.4",

View file

@ -696,6 +696,11 @@
resolved "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz"
integrity sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==
"@lancedb/vectordb-darwin-arm64@*":
version "0.4.11"
resolved "https://registry.npmjs.org/@lancedb/vectordb-darwin-arm64/-/vectordb-darwin-arm64-0.4.11.tgz"
integrity sha512-JDOKmFnuJPFkA7ZmrzBJolROwSjWr7yMvAbi40uLBc25YbbVezodd30u2EFtIwWwtk1GqNYRZ49FZOElKYeC/Q==
"@lancedb/vectordb-darwin-arm64@0.4.10":
version "0.4.10"
resolved "https://registry.npmjs.org/@lancedb/vectordb-darwin-arm64/-/vectordb-darwin-arm64-0.4.10.tgz"
@ -2373,7 +2378,6 @@ core-util-is@1.0.2:
https-proxy-agent "^7.0.3"
js-tiktoken "^1.0.8"
llama-tokenizer-js "^1.1.3"
llm-code-highlighter "^0.0.13"
node-fetch "^3.3.2"
node-html-markdown "^1.3.0"
ollama "^0.4.6"
@ -2387,7 +2391,7 @@ core-util-is@1.0.2:
tree-sitter-wasms "^0.1.6"
uuid "^9.0.1"
vectordb "^0.4.3"
web-tree-sitter "^0.20.8"
web-tree-sitter "^0.21.0"
cors@^2.8.5:
version "2.8.5"

3
gui/package-lock.json generated
View file

@ -89,7 +89,6 @@
"https-proxy-agent": "^7.0.3",
"js-tiktoken": "^1.0.8",
"llama-tokenizer-js": "^1.1.3",
"llm-code-highlighter": "^0.0.13",
"node-fetch": "^3.3.2",
"node-html-markdown": "^1.3.0",
"ollama": "^0.4.6",
@ -103,7 +102,7 @@
"tree-sitter-wasms": "^0.1.6",
"uuid": "^9.0.1",
"vectordb": "^0.4.3",
"web-tree-sitter": "^0.20.8"
"web-tree-sitter": "^0.21.0"
},
"devDependencies": {
"@types/follow-redirects": "^1.14.4",

6
package-lock.json generated Normal file
View file

@ -0,0 +1,6 @@
{
"name": "continue",
"lockfileVersion": 3,
"requires": true,
"packages": {}
}