| 1 | [**@lancedb/lancedb**](../../../README.md) • **Docs** |
| 2 | |
| 3 | *** |
| 4 | |
| 5 | [@lancedb/lancedb](../../../globals.md) / [embedding](../README.md) / EmbeddingFunctionRegistry |
| 6 | |
| 7 | # Class: EmbeddingFunctionRegistry |
| 8 | |
| 9 | This is a singleton class used to register embedding functions |
| 10 | and fetch them by name. It also handles serializing and deserializing. |
| 11 | You can implement your own embedding function by subclassing EmbeddingFunction |
| 12 | or TextEmbeddingFunction and registering it with the registry |
| 13 | |
| 14 | ## Constructors |
| 15 | |
| 16 | ### new EmbeddingFunctionRegistry() |
| 17 | |
| 18 | > **new EmbeddingFunctionRegistry**(): [`EmbeddingFunctionRegistry`](EmbeddingFunctionRegistry.md) |
| 19 | |
| 20 | #### Returns |
| 21 | |
| 22 | [`EmbeddingFunctionRegistry`](EmbeddingFunctionRegistry.md) |
| 23 | |
| 24 | ## Methods |
| 25 | |
| 26 | ### functionToMetadata() |
| 27 | |
| 28 | > **functionToMetadata**(`conf`): `Record`<`string`, `any`> |
| 29 | |
| 30 | #### Parameters |
| 31 | |
| 32 | • **conf**: [`EmbeddingFunctionConfig`](../interfaces/EmbeddingFunctionConfig.md) |
| 33 | |
| 34 | #### Returns |
| 35 | |
| 36 | `Record`<`string`, `any`> |
| 37 | |
| 38 | *** |
| 39 | |
| 40 | ### get() |
| 41 | |
| 42 | > **get**<`T`, `Name`>(`name`): `Name` *extends* `"openai"` ? `EmbeddingFunctionCreate`<[`OpenAIEmbeddingFunction`](OpenAIEmbeddingFunction.md)> : `undefined` \| `EmbeddingFunctionCreate`<`T`> |
| 43 | |
| 44 | Fetch an embedding function by name |
| 45 | |
| 46 | #### Type Parameters |
| 47 | |
| 48 | • **T** *extends* [`EmbeddingFunction`](EmbeddingFunction.md)<`unknown`, `FunctionOptions`> |
| 49 | |
| 50 | • **Name** *extends* `string` = `""` |
| 51 | |
| 52 | #### Parameters |
| 53 | |
| 54 | • **name**: `Name` *extends* `"openai"` ? `"openai"` : `string` |
| 55 | |
| 56 | The name of the function |
| 57 | |
| 58 | #### Returns |
| 59 | |
| 60 | `Name` *extends* `"openai"` ? `EmbeddingFunctionCreate`<[`OpenAIEmbeddingFunction`](OpenAIEmbeddingFunction.md)> : `undefined` \| `EmbeddingFunctionCreate`<`T`> |
| 61 | |
| 62 | *** |
| 63 | |
| 64 | ### getTableMetadata() |
| 65 | |
| 66 | > **getTableMetadata**(`functions`): `Map`<`string`, `string`> |
| 67 | |
| 68 | #### Parameters |
| 69 | |
| 70 | • **functions**: [`EmbeddingFunctionConfig`](../interfaces/EmbeddingFunctionConfig.md)[] |
| 71 | |
| 72 | #### Returns |
| 73 | |
| 74 | `Map`<`string`, `string`> |
| 75 | |
| 76 | *** |
| 77 | |
| 78 | ### register() |
| 79 | |
| 80 | > **register**<`T`>(`this`, `alias`?): (`ctor`) => `any` |
| 81 | |
| 82 | Register an embedding function |
| 83 | |
| 84 | #### Type Parameters |
| 85 | |
| 86 | • **T** *extends* `EmbeddingFunctionConstructor`<[`EmbeddingFunction`](EmbeddingFunction.md)<`any`, `FunctionOptions`>> = `EmbeddingFunctionConstructor`<[`EmbeddingFunction`](EmbeddingFunction.md)<`any`, `FunctionOptions`>> |
| 87 | |
| 88 | #### Parameters |
| 89 | |
| 90 | • **this**: [`EmbeddingFunctionRegistry`](EmbeddingFunctionRegistry.md) |
| 91 | |
| 92 | • **alias?**: `string` |
| 93 | |
| 94 | #### Returns |
| 95 | |
| 96 | `Function` |
| 97 | |
| 98 | ##### Parameters |
| 99 | |
| 100 | • **ctor**: `T` |
| 101 | |
| 102 | ##### Returns |
| 103 | |
| 104 | `any` |
| 105 | |
| 106 | #### Throws |
| 107 | |
| 108 | Error if the function is already registered |
| 109 | |
| 110 | *** |
| 111 | |
| 112 | ### reset() |
| 113 | |
| 114 | > **reset**(`this`): `void` |
| 115 | |
| 116 | reset the registry to the initial state |
| 117 | |
| 118 | #### Parameters |
| 119 | |
| 120 | • **this**: [`EmbeddingFunctionRegistry`](EmbeddingFunctionRegistry.md) |
| 121 | |
| 122 | #### Returns |
| 123 | |
| 124 | `void` |