Merge branch 'preview' of https://github.com/continuedev/continue into preview

This commit is contained in:
Nate Sesti 2024-03-14 18:29:05 -07:00
commit e49a3fa584
3 changed files with 41 additions and 17 deletions

View file

@ -184,6 +184,28 @@ export const Dart = {
endOfLine: [";"],
};
// Solidity
export const Solidity = {
stopWords: [
"contract",
"event",
"modifier",
"function",
"constructor",
"for",
"require",
"emit",
"interface",
"error",
"library",
"struct",
"enum",
"type",
],
comment: "//",
endOfLine: [";"],
};
export const LANGUAGES: { [extension: string]: AutocompleteLanguageInfo } = {
ts: Typescript,
js: Typescript,
@ -219,4 +241,5 @@ export const LANGUAGES: { [extension: string]: AutocompleteLanguageInfo } = {
r: R,
R: R,
dart: Dart,
sol: Solidity,
};

View file

@ -2,7 +2,6 @@ import { Database, open } from "sqlite";
import sqlite3 from "sqlite3";
import { Chunk } from "../..";
import { getDocsSqlitePath, getLanceDbPath } from "../../util/paths";
import { SqliteDb } from "../refreshIndex";
import { downloadPreIndexedDocs } from "./preIndexed";
import { default as configs } from "./preIndexedDocs";
@ -21,12 +20,23 @@ interface LanceDbDocsRow {
[key: string]: any;
}
async function createDocsTable(db: Database<sqlite3.Database>) {
db.exec(`CREATE TABLE IF NOT EXISTS docs (
let dbDocs:Database;
async function getDBDocs() {
if (!dbDocs) {
dbDocs = await open({
filename: getDocsSqlitePath(),
driver: sqlite3.Database,
});
dbDocs.exec(`CREATE TABLE IF NOT EXISTS docs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title STRING NOT NULL,
baseUrl STRING NOT NULL UNIQUE
)`);
}
return dbDocs;
}
export async function retrieveDocs(
@ -37,8 +47,7 @@ export async function retrieveDocs(
nested: boolean = false,
): Promise<Chunk[]> {
const lancedb = await import("vectordb");
const db = await SqliteDb.get();
await createDocsTable(db);
const db = await getDBDocs();
const lance = await lancedb.connect(getLanceDbPath());
const downloadDocs = async () => {
@ -116,11 +125,7 @@ export async function addDocs(
}
// Only after add it to SQLite
const db = await open({
filename: getDocsSqlitePath(),
driver: sqlite3.Database,
});
await createDocsTable(db);
const db = await getDBDocs();
await db.run(
`INSERT INTO docs (title, baseUrl) VALUES (?, ?)`,
title,
@ -131,11 +136,7 @@ export async function addDocs(
export async function listDocs(): Promise<
{ title: string; baseUrl: string }[]
> {
const db = await open({
filename: getDocsSqlitePath(),
driver: sqlite3.Database,
});
await createDocsTable(db);
const docs = await db.all(`SELECT title, baseUrl FROM docs`);
const db = await getDBDocs();
const docs = db.all(`SELECT title, baseUrl FROM docs`);
return docs;
}

View file

@ -175,7 +175,7 @@ const MentionList = forwardRef((props: MentionListProps, ref) => {
useEffect(() => {
const items = [...props.items];
if (subMenuTitle === "Search documentation") {
if (subMenuTitle === "Type to search docs") {
items.push({
title: "Add Docs",
type: "action",