Skip to content

@lancedb/lancedb β€’ Docs


@lancedb/lancedb / embedding / EmbeddingFunctionRegistry

Class: EmbeddingFunctionRegistry

This is a singleton class used to register embedding functions and fetch them by name. It also handles serializing and deserializing. You can implement your own embedding function by subclassing EmbeddingFunction or TextEmbeddingFunction and registering it with the registry

Constructors

new EmbeddingFunctionRegistry()

new EmbeddingFunctionRegistry(): EmbeddingFunctionRegistry

Returns

EmbeddingFunctionRegistry

Methods

functionToMetadata()

functionToMetadata(conf): Record<string, any>

Parameters

β€’ conf: EmbeddingFunctionConfig

Returns

Record<string, any>


get()

get<T, Name>(name): Name extends "openai" ? EmbeddingFunctionCreate<OpenAIEmbeddingFunction> : undefined | EmbeddingFunctionCreate<T>

Fetch an embedding function by name

Type Parameters

β€’ T extends EmbeddingFunction<unknown, FunctionOptions>

β€’ Name extends string = ""

Parameters

β€’ name: Name extends "openai" ? "openai" : string

The name of the function

Returns

Name extends "openai" ? EmbeddingFunctionCreate<OpenAIEmbeddingFunction> : undefined | EmbeddingFunctionCreate<T>


getTableMetadata()

getTableMetadata(functions): Map<string, string>

Parameters

β€’ functions: EmbeddingFunctionConfig[]

Returns

Map<string, string>


register()

register<T>(this, alias?): (ctor) => any

Register an embedding function

Type Parameters

β€’ T extends EmbeddingFunctionConstructor<EmbeddingFunction<any, FunctionOptions>> = EmbeddingFunctionConstructor<EmbeddingFunction<any, FunctionOptions>>

Parameters

β€’ this: EmbeddingFunctionRegistry

β€’ alias?: string

Returns

Function

Parameters

β€’ ctor: T

Returns

any

Throws

Error if the function is already registered


reset()

reset(this): void

reset the registry to the initial state

Parameters

β€’ this: EmbeddingFunctionRegistry

Returns

void