Class: EmbeddingModel
Extends
Constructors
new EmbeddingModel(args)
new EmbeddingModel(
args?):EmbeddingModel
Doesn't accept OpenAIClient because retry needs to be handled at the model level.
Parameters
| Parameter | Type | Description |
|---|---|---|
args? | object | - |
args.cache? | CacheStorage<string, Response> | Enables caching for model responses. Must implement .get(key) and .set(key, value), both of which can be either sync or async.Some examples include: new Map(), quick-lru (opens in a new tab), or any keyv adaptor (opens in a new tab). |
args.cacheKey? | CacheKey<Run & Config, string> | A function that returns a cache key for the given params. A simple example would be: (params) => JSON.stringify(params)The default cacheKey function uses hash-object (opens in a new tab) to create a stable sha256 hash of the params. |
args.client? | Client | - |
args.context? | Ctx | - |
args.debug? | boolean | Whether or not to add default console.log event handlers |
args.events? | Events<Run & Config, Response, any> | - |
args.params? | Config & Partial<Run> | - |
Returns
Overrides
Source
src/model/embedding.ts:48 (opens in a new tab)
Properties
| Property | Type | Description | Inheritance | Source |
|---|---|---|---|---|
modelProvider | "openai" | - | AbstractModel.modelProvider | src/model/embedding.ts:44 (opens in a new tab) |
modelType | "embedding" | - | AbstractModel.modelType | src/model/embedding.ts:43 (opens in a new tab) |
throttledModel | BulkEmbedder | - | - | src/model/embedding.ts:45 (opens in a new tab) |
tokenizer | ITokenizer | - | AbstractModel.tokenizer | src/model/model.ts:65 (opens in a new tab) |
Methods
addEvents()
addEvents(
events):EmbeddingModel
Add event handlers to the model.
Parameters
| Parameter | Type |
|---|---|
events | Events<Run & Config, Response, CreateEmbeddingResponse> |
Returns
Inherited from
Source
src/model/model.ts:235 (opens in a new tab)
addParams()
addParams(
params):EmbeddingModel
Add the params. Overrides existing keys.
Parameters
| Parameter | Type |
|---|---|
params | Partial<Config & Partial<Run>> |
Returns
Inherited from
Source
src/model/model.ts:213 (opens in a new tab)
clone()
clone(
args?):EmbeddingModel
Clone the model and merge/override the given properties.
Parameters
| Parameter | Type | Description |
|---|---|---|
args? | object | - |
args.cache? | CacheStorage<string, Response> | Enables caching for model responses. Must implement .get(key) and .set(key, value), both of which can be either sync or async.Some examples include: new Map(), quick-lru (opens in a new tab), or any keyv adaptor (opens in a new tab). |
args.cacheKey? | CacheKey<Run & Config, string> | A function that returns a cache key for the given params. A simple example would be: (params) => JSON.stringify(params)The default cacheKey function uses hash-object (opens in a new tab) to create a stable sha256 hash of the params. |
args.client? | Client | - |
args.context? | Ctx | - |
args.debug? | boolean | Whether or not to add default console.log event handlers |
args.events? | Events<Run & Config, Response, any> | - |
args.params? | Config & Partial<Run> | - |
Returns
Overrides
Source
src/model/embedding.ts:154 (opens in a new tab)
getClient()
getClient():
Client
Get the current client
Returns
Inherited from
Source
src/model/model.ts:180 (opens in a new tab)
getContext()
getContext():
Ctx
Get the current context
Returns
Inherited from
Source
src/model/model.ts:191 (opens in a new tab)
getEvents()
getEvents():
Events<Run&Config,Response,CreateEmbeddingResponse>
Get the current event handlers
Returns
Events<Run & Config, Response, CreateEmbeddingResponse>
Inherited from
Source
src/model/model.ts:230 (opens in a new tab)
getParams()
Get the current params
Returns
Inherited from
Source
src/model/model.ts:208 (opens in a new tab)
run()
run(
params,context?):Promise<Response>
Parameters
| Parameter | Type |
|---|---|
params | object |
params.batch? | Partial<BatchOptions> |
params.input? | string[] |
params.model? | "text-embedding-ada-002" | string & object |
params.throttle? | Partial<ThrottleOptions> |
context? | Ctx |
Returns
Promise<Response>
Inherited from
Source
src/model/model.ts:78 (opens in a new tab)
setCache()
setCache(
cache):EmbeddingModel
Set the cache to a new cache. Set to undefined to remove existing.
Parameters
| Parameter | Type |
|---|---|
cache | undefined | CacheStorage<string, Response> |
Returns
Inherited from
Source
src/model/model.ts:174 (opens in a new tab)
setClient()
setClient(
client):EmbeddingModel
Set the client to a new OpenAI API client.
Parameters
| Parameter | Type |
|---|---|
client | Client |
Returns
Inherited from
Source
src/model/model.ts:185 (opens in a new tab)
setContext()
setContext(
context):EmbeddingModel
Set the context to a new context. Removes all existing values.
Parameters
| Parameter | Type |
|---|---|
context | Ctx |
Returns
Inherited from
Source
src/model/model.ts:202 (opens in a new tab)
setEvents()
setEvents(
events):EmbeddingModel
Set the event handlers to a new set of events. Removes all existing event handlers.
Set to empty object {} to remove all events.
Parameters
| Parameter | Type |
|---|---|
events | Events<Run & Config, Response, CreateEmbeddingResponse> |
Returns
Inherited from
Source
src/model/model.ts:244 (opens in a new tab)
setParams()
setParams(
params):EmbeddingModel
Set the params to a new params. Removes all existing values.
Parameters
| Parameter | Type |
|---|---|
params | Config & Partial<Run> |
Returns
Inherited from
Source
src/model/model.ts:223 (opens in a new tab)
updateContext()
updateContext(
context):EmbeddingModel
Add the context. Overrides existing keys.
Parameters
| Parameter | Type |
|---|---|
context | Ctx |