From b86415576008923c8786b97a8df32fe268a44075 Mon Sep 17 00:00:00 2001 From: Chia Kang Jin Date: Sun, 13 Aug 2023 12:59:42 +0900 Subject: [PATCH] fix deploy errors - even though we dont use indexeddb or langchain/openai atm --- src/components/RecipientList.tsx | 3 ++- src/datasources/indexeddb.ts | 16 ++++++++++++++++ src/datasources/vector.ts | 29 +++++++++++++++++++++++------ 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/components/RecipientList.tsx b/src/components/RecipientList.tsx index 2063741..43935be 100644 --- a/src/components/RecipientList.tsx +++ b/src/components/RecipientList.tsx @@ -11,6 +11,7 @@ export const RecipientList = ( props: RecipientListProps ) => { const handle_click = (item: T) => () => props.select_item(item); + const handle_delete = props.delete_item ? props.delete_item : () => {}; return (
    @@ -31,7 +32,7 @@ export const RecipientList = ( {props.delete_item && ( props.delete_item(item)} + onClick={() => handle_delete(item)} > Delete diff --git a/src/datasources/indexeddb.ts b/src/datasources/indexeddb.ts index 032813a..ead8bc8 100644 --- a/src/datasources/indexeddb.ts +++ b/src/datasources/indexeddb.ts @@ -142,6 +142,22 @@ export default class IndexedDBDatasource implements AsyncBaseDatasource { return date_bucket || []; } + async retrieveFirstBucketFromStorage( + recipient: string, + source: string + ): Promise { + // Cannot implement as all recipient/source/dates are stored as a single key with no ordering capability + throw new Error("Method not implemented."); + } + + async retrieveLastBucketFromStorage( + recipient: string, + source: string + ): Promise { + // Cannot implement as all recipient/source/dates are stored as a single key with no ordering capability + throw new Error("Method not implemented."); + } + async retrieveMessageFromStorage( recipient: Recipient, source: Source, diff --git a/src/datasources/vector.ts b/src/datasources/vector.ts index 0a89d6e..9847d7c 100644 --- a/src/datasources/vector.ts +++ b/src/datasources/vector.ts @@ -33,6 +33,9 @@ export default class VectorDatasource implements AsyncBaseDatasource { // } // ); } + deleteBucketFromStorage(recipient: string, source: string): Promise { + throw new Error("Method not implemented."); + } addToIndex(index: Index, terms: string[]): void { throw new Error("Method not implemented."); @@ -50,12 +53,26 @@ export default class VectorDatasource implements AsyncBaseDatasource { } retrieveBucketFromStorage( recipient: string, + source: string, date: DateBucketReference ): Promise { throw new Error("Method not implemented."); } + retrieveFirstBucketFromStorage( + recipient: string, + source: string + ): Promise { + throw new Error("Method not implemented."); + } + retrieveLastBucketFromStorage( + recipient: string, + source: string + ): Promise { + throw new Error("Method not implemented."); + } retrieveMessageFromStorage( recipient: string, + source: string, date: DateBucketReference, message_id: number ): Promise { @@ -77,11 +94,11 @@ export default class VectorDatasource implements AsyncBaseDatasource { } } - async bulkAddToStorage( + bulkAddToStorage( recipient: Recipient, + source: string, messages: ChatLogFormat[], - tokenizer?: (message: string) => Promise, // replace with embedding function - progress_tracker?: (callback: () => number) => void + tokenizer?: (message: string) => Promise // replace with embedding function ) { const docs: Document[] = messages.map((message) => ({ pageContent: message[ChatLogFormatMessage], @@ -91,8 +108,8 @@ export default class VectorDatasource implements AsyncBaseDatasource { }, })); - await this.db.addDocuments(docs); - console.log(this.db.memoryVectors); - this.db.similaritySearch("haha").then(console.log); + let progress = 0; + this.db.addDocuments(docs).then(() => (progress = messages.length)); + return () => progress; } }