bugfix(node): make WriteMode optional when specifying embeddings (#336)

This commit is contained in:
gsilvestrin
2023-07-24 11:26:43 -07:00
committed by GitHub
parent 8325979bb8
commit 80a32be121
3 changed files with 84 additions and 31 deletions

View File

@@ -26,3 +26,9 @@ export interface EmbeddingFunction<T> {
*/
embed: (data: T[]) => Promise<number[][]>
}
export function isEmbeddingFunction<T> (value: any): value is EmbeddingFunction<T> {
return Object.keys(value).length === 2 &&
typeof value.sourceColumn === 'string' &&
typeof value.embed === 'function'
}