mirror of
https://github.com/lancedb/lancedb.git
synced 2026-01-13 07:12:57 +00:00
* Sets `"useCodeBlocks": true` * Adds a post-processing script `nodejs/typedoc_post_process.js` that puts the parameter description on the same line as the parameter name, like it is in our Python docs. This makes the text hierarchy clearer in those sections and also makes the sections shorter.
148 lines
2.4 KiB
Markdown
148 lines
2.4 KiB
Markdown
[**@lancedb/lancedb**](../../../README.md) • **Docs**
|
|
|
|
***
|
|
|
|
[@lancedb/lancedb](../../../globals.md) / [embedding](../README.md) / 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()
|
|
|
|
```ts
|
|
new EmbeddingFunctionRegistry(): EmbeddingFunctionRegistry
|
|
```
|
|
|
|
#### Returns
|
|
|
|
[`EmbeddingFunctionRegistry`](EmbeddingFunctionRegistry.md)
|
|
|
|
## Methods
|
|
|
|
### functionToMetadata()
|
|
|
|
```ts
|
|
functionToMetadata(conf): Record<string, any>
|
|
```
|
|
|
|
#### Parameters
|
|
|
|
* **conf**: [`EmbeddingFunctionConfig`](../interfaces/EmbeddingFunctionConfig.md)
|
|
|
|
#### Returns
|
|
|
|
`Record`<`string`, `any`>
|
|
|
|
***
|
|
|
|
### get()
|
|
|
|
```ts
|
|
get<T>(name): undefined | EmbeddingFunctionCreate<T>
|
|
```
|
|
|
|
Fetch an embedding function by name
|
|
|
|
#### Type Parameters
|
|
|
|
• **T** *extends* [`EmbeddingFunction`](EmbeddingFunction.md)<`unknown`, `FunctionOptions`>
|
|
|
|
#### Parameters
|
|
|
|
* **name**: `string`
|
|
The name of the function
|
|
|
|
#### Returns
|
|
|
|
`undefined` \| `EmbeddingFunctionCreate`<`T`>
|
|
|
|
***
|
|
|
|
### getTableMetadata()
|
|
|
|
```ts
|
|
getTableMetadata(functions): Map<string, string>
|
|
```
|
|
|
|
#### Parameters
|
|
|
|
* **functions**: [`EmbeddingFunctionConfig`](../interfaces/EmbeddingFunctionConfig.md)[]
|
|
|
|
#### Returns
|
|
|
|
`Map`<`string`, `string`>
|
|
|
|
***
|
|
|
|
### length()
|
|
|
|
```ts
|
|
length(): number
|
|
```
|
|
|
|
Get the number of registered functions
|
|
|
|
#### Returns
|
|
|
|
`number`
|
|
|
|
***
|
|
|
|
### register()
|
|
|
|
```ts
|
|
register<T>(this, alias?): (ctor) => any
|
|
```
|
|
|
|
Register an embedding function
|
|
|
|
#### Type Parameters
|
|
|
|
• **T** *extends* `EmbeddingFunctionConstructor`<[`EmbeddingFunction`](EmbeddingFunction.md)<`any`, `FunctionOptions`>> = `EmbeddingFunctionConstructor`<[`EmbeddingFunction`](EmbeddingFunction.md)<`any`, `FunctionOptions`>>
|
|
|
|
#### Parameters
|
|
|
|
* **this**: [`EmbeddingFunctionRegistry`](EmbeddingFunctionRegistry.md)
|
|
|
|
* **alias?**: `string`
|
|
|
|
#### Returns
|
|
|
|
`Function`
|
|
|
|
##### Parameters
|
|
|
|
* **ctor**: `T`
|
|
|
|
##### Returns
|
|
|
|
`any`
|
|
|
|
#### Throws
|
|
|
|
Error if the function is already registered
|
|
|
|
***
|
|
|
|
### reset()
|
|
|
|
```ts
|
|
reset(this): void
|
|
```
|
|
|
|
reset the registry to the initial state
|
|
|
|
#### Parameters
|
|
|
|
* **this**: [`EmbeddingFunctionRegistry`](EmbeddingFunctionRegistry.md)
|
|
|
|
#### Returns
|
|
|
|
`void`
|