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

Returns

Record<string, any>


get()

get<T>(name): undefined | EmbeddingFunctionCreate<T>

Fetch an embedding function by name

Type Parameters

β€’ T extends EmbeddingFunction<unknown, FunctionOptions>

Parameters

  • name: string The name of the function

Returns

undefined | EmbeddingFunctionCreate<T>


getTableMetadata()

getTableMetadata(functions): Map<string, string>

Parameters

Returns

Map<string, string>


getVar()

getVar(name): undefined | string

Get a variable.

Parameters

  • name: string

Returns

undefined | string

See

setVar


length()

length(): number

Get the number of registered functions

Returns

number


register()

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

Register an embedding function

Type Parameters

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

Parameters

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

Returns

void


setVar()

setVar(name, value): void

Set a variable. These can be accessed in the embedding function configuration using the syntax $var:variable_name. If they are not set, an error will be thrown letting you know which key is unset. If you want to supply a default value, you can add an additional part in the configuration like so: $var:variable_name:default_value. Default values can be used for runtime configurations that are not sensitive, such as whether to use a GPU for inference.

The name must not contain colons. The default value can contain colons.

Parameters

  • name: string

  • value: string

Returns

void