feat(nodejs): table.search functionality (#1341)

closes https://github.com/lancedb/lancedb/issues/1256
This commit is contained in:
Cory Grinstead
2024-06-04 14:04:03 -05:00
committed by GitHub
parent d9fb6457e1
commit 70f92f19a6
6 changed files with 163 additions and 10 deletions

View File

@@ -19,6 +19,7 @@ import {
FixedSizeList,
Float,
Float32,
type IntoVector,
isDataType,
isFixedSizeList,
isFloat,
@@ -169,9 +170,7 @@ export abstract class EmbeddingFunction<
/**
Compute the embeddings for a single query
*/
async computeQueryEmbeddings(
data: T,
): Promise<number[] | Float32Array | Float64Array> {
async computeQueryEmbeddings(data: T): Promise<IntoVector> {
return this.computeSourceEmbeddings([data]).then(
(embeddings) => embeddings[0],
);

View File

@@ -42,6 +42,7 @@ export class EmbeddingFunctionRegistry {
* Register an embedding function
* @param name The name of the function
* @param func The function to register
* @throws Error if the function is already registered
*/
register<T extends EmbeddingFunctionFactory = EmbeddingFunctionFactory>(
this: EmbeddingFunctionRegistry,
@@ -89,6 +90,9 @@ export class EmbeddingFunctionRegistry {
this.#functions.clear();
}
/**
* @ignore
*/
parseFunctions(
this: EmbeddingFunctionRegistry,
metadata: Map<string, string>,