Skip to content

Commit

Permalink
fix deploy errors - even though we dont use indexeddb or langchain/op…
Browse files Browse the repository at this point in the history
…enai atm
  • Loading branch information
xiankai committed Aug 13, 2023
1 parent ab27f98 commit b864155
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/components/RecipientList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const RecipientList = <T extends string>(
props: RecipientListProps<T>
) => {
const handle_click = (item: T) => () => props.select_item(item);
const handle_delete = props.delete_item ? props.delete_item : () => {};

return (
<ul className="menu">
Expand All @@ -31,7 +32,7 @@ export const RecipientList = <T extends string>(
{props.delete_item && (
<span
className="btn btn-link btn-sm text-white"
onClick={() => props.delete_item(item)}
onClick={() => handle_delete(item)}
>
<i className="icon icon-cross"></i>
Delete
Expand Down
16 changes: 16 additions & 0 deletions src/datasources/indexeddb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,22 @@ export default class IndexedDBDatasource implements AsyncBaseDatasource {
return date_bucket || [];
}

async retrieveFirstBucketFromStorage(
recipient: string,
source: string
): Promise<ChatLogFormat[]> {
// 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<ChatLogFormat[]> {
// 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,
Expand Down
29 changes: 23 additions & 6 deletions src/datasources/vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export default class VectorDatasource implements AsyncBaseDatasource {
// }
// );
}
deleteBucketFromStorage(recipient: string, source: string): Promise<void> {
throw new Error("Method not implemented.");
}

addToIndex(index: Index, terms: string[]): void {
throw new Error("Method not implemented.");
Expand All @@ -50,12 +53,26 @@ export default class VectorDatasource implements AsyncBaseDatasource {
}
retrieveBucketFromStorage(
recipient: string,
source: string,
date: DateBucketReference
): Promise<ChatLogFormat[]> {
throw new Error("Method not implemented.");
}
retrieveFirstBucketFromStorage(
recipient: string,
source: string
): Promise<ChatLogFormat[]> {
throw new Error("Method not implemented.");
}
retrieveLastBucketFromStorage(
recipient: string,
source: string
): Promise<ChatLogFormat[]> {
throw new Error("Method not implemented.");
}
retrieveMessageFromStorage(
recipient: string,
source: string,
date: DateBucketReference,
message_id: number
): Promise<ChatLogFormat> {
Expand All @@ -77,11 +94,11 @@ export default class VectorDatasource implements AsyncBaseDatasource {
}
}

async bulkAddToStorage(
bulkAddToStorage(
recipient: Recipient,
source: string,
messages: ChatLogFormat[],
tokenizer?: (message: string) => Promise<string[]>, // replace with embedding function
progress_tracker?: (callback: () => number) => void
tokenizer?: (message: string) => Promise<string[]> // replace with embedding function
) {
const docs: Document[] = messages.map((message) => ({
pageContent: message[ChatLogFormatMessage],
Expand All @@ -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;
}
}

0 comments on commit b864155

Please sign in to comment.