Skip to content
Snippets Groups Projects
Commit 45163630 authored by Yi Ding's avatar Yi Ding
Browse files

make persistence optional

parent ce61f966
No related branches found
No related tags found
No related merge requests found
......@@ -141,7 +141,12 @@ export class VectorStoreIndex extends BaseIndex<IndexDict> {
vectorStore.add(embeddingResults);
throw new Error("not implemented");
const indexDict = new IndexDict();
for (const { node } of embeddingResults) {
indexDict.addNode(node);
}
return indexDict;
}
static async fromDocuments(
......
......@@ -32,21 +32,24 @@ export async function storageContextFromDefaults({
persistDir,
fs,
}: BuilderParams): Promise<StorageContext> {
persistDir = persistDir || DEFAULT_PERSIST_DIR;
fs = fs || DEFAULT_FS;
docStore =
docStore ||
(await SimpleDocumentStore.fromPersistDir(
persistDir,
DEFAULT_NAMESPACE,
fs
));
indexStore =
indexStore || (await SimpleIndexStore.fromPersistDir(persistDir, fs));
vectorStore =
vectorStore || (await SimpleVectorStore.fromPersistDir(persistDir, fs));
if (!persistDir) {
docStore = docStore || new SimpleDocumentStore();
indexStore = indexStore || new SimpleIndexStore();
vectorStore = vectorStore || new SimpleVectorStore();
} else {
fs = fs || DEFAULT_FS;
docStore =
docStore ||
(await SimpleDocumentStore.fromPersistDir(
persistDir,
DEFAULT_NAMESPACE,
fs
));
indexStore =
indexStore || (await SimpleIndexStore.fromPersistDir(persistDir, fs));
vectorStore =
vectorStore || (await SimpleVectorStore.fromPersistDir(persistDir, fs));
}
return {
docStore,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment