Compare commits

...

13 Commits

Author SHA1 Message Date
sweep-ai[bot] cb1bce5ef5 Merge main into sweep/add-metadata-support 2023-08-24 06:19:56 +00:00
sweep-ai[bot] 1a71d7da6d Merge main into sweep/add-metadata-support 2023-08-24 06:19:28 +00:00
sweep-ai[bot] 3bcbbb6138 Merge main into sweep/add-metadata-support 2023-08-23 06:42:43 +00:00
sweep-ai[bot] 455924800d Merge main into sweep/add-metadata-support 2023-08-23 06:41:42 +00:00
sweep-ai[bot] bb0d37256e Merge main into sweep/add-metadata-support 2023-08-23 06:29:08 +00:00
sweep-ai[bot] ea9769a9ea Merge main into sweep/add-metadata-support 2023-08-23 05:44:19 +00:00
sweep-ai[bot] 933a275c2f Merge main into sweep/add-metadata-support 2023-08-23 05:30:46 +00:00
sweep-ai[bot] 165ac566a4 Merge main into sweep/add-metadata-support 2023-08-20 01:25:07 +00:00
sweep-ai[bot] 4c524fd945 Merge main into sweep/add-metadata-support 2023-08-20 01:23:09 +00:00
sweep-ai[bot] f00fb628b1 Modified the load and save methods to correctl 2023-08-18 12:14:51 +00:00
sweep-ai[bot] 0e306fcadb Added metadata to the return objects of getDocumen 2023-08-18 12:10:45 +00:00
sweep-ai[bot] d0b18d53a8 Added metadata handling to save function in Simple 2023-08-18 12:10:22 +00:00
sweep-ai[bot] a783a2f6ad Added metadata handling to load function in Simple 2023-08-18 12:09:42 +00:00
2 changed files with 29 additions and 0 deletions
@@ -15,6 +15,22 @@ export interface StorageContext {
docStore: BaseDocumentStore;
indexStore: BaseIndexStore;
vectorStore: VectorStore;
async getDocuments(key: string): Promise<Document[]> {
const documents = await this.docStore.getDocuments(key);
return documents.map((document) => ({
...document,
metadata: document.metadata,
}));
}
async getNodes(key: string): Promise<Node[]> {
const nodes = await this.docStore.getNodes(key);
return nodes.map((node) => ({
...node,
metadata: node.metadata,
}));
}
}
type BuilderParams = {
@@ -16,6 +16,19 @@ type SaveDict = Record<string, any>;
export class SimpleDocumentStore extends KVDocumentStore {
private kvStore: SimpleKVStore;
async load(key: string, metadata: Record<string, any>): Promise<Document | null> {
const document = await super.load(key, metadata);
return document;
}
async save(key: string, document: Document): Promise<void> {
const data = {
...document,
metadata: document.metadata,
};
await super.save(key, data);
}
constructor(kvStore?: SimpleKVStore, namespace?: string) {
kvStore = kvStore || new SimpleKVStore();
namespace = namespace || DEFAULT_NAMESPACE;