Class: abstract AbstractModel<MClient, MConfig, MRun, MResponse, AResponse>
Extended By
Type parameters
| Parameter | Default |
|---|---|
MClient extends Client | - |
MConfig extends Config | - |
MRun extends Run | - |
MResponse extends Response | - |
AResponse extends any | any |
Constructors
new AbstractModel(args)
new AbstractModel<
MClient,MConfig,MRun,MResponse,AResponse>(args):AbstractModel<MClient,MConfig,MRun,MResponse,AResponse>
Parameters
| Parameter | Type |
|---|---|
args | ModelArgs<MClient, MConfig, MRun, MResponse> |
Returns
AbstractModel<MClient, MConfig, MRun, MResponse, AResponse>
Source
src/model/model.ts:67 (opens in a new tab)
Properties
| Modifier | Property | Type | Description | Source |
|---|---|---|---|---|
abstract | modelProvider | Provider | - | src/model/model.ts:57 (opens in a new tab) |
abstract | modelType | Type | - | src/model/model.ts:56 (opens in a new tab) |
public | tokenizer | ITokenizer | - | src/model/model.ts:65 (opens in a new tab) |
Methods
addEvents()
addEvents(
events):AbstractModel<MClient,MConfig,MRun,MResponse,AResponse>
Add event handlers to the model.
Parameters
| Parameter | Type |
|---|---|
events | Events<MRun & MConfig, MResponse, AResponse> |
Returns
AbstractModel<MClient, MConfig, MRun, MResponse, AResponse>
Source
src/model/model.ts:235 (opens in a new tab)
addParams()
addParams(
params):AbstractModel<MClient,MConfig,MRun,MResponse,AResponse>
Add the params. Overrides existing keys.
Parameters
| Parameter | Type |
|---|---|
params | Partial<MConfig & Partial<MRun>> |
Returns
AbstractModel<MClient, MConfig, MRun, MResponse, AResponse>
Source
src/model/model.ts:213 (opens in a new tab)
abstract clone()
abstractclone<Args>(args?):AbstractModel<MClient,MConfig,MRun,MResponse,AResponse>
Clone the model, optionally adding new arguments
Type parameters
| Parameter |
|---|
Args extends ModelArgs<MClient, MConfig, MRun, MResponse> |
Parameters
| Parameter | Type |
|---|---|
args? | Args |
Returns
AbstractModel<MClient, MConfig, MRun, MResponse, AResponse>
Source
src/model/model.ts:52 (opens in a new tab)
getClient()
getClient():
MClient
Get the current client
Returns
MClient
Source
src/model/model.ts:180 (opens in a new tab)
getContext()
getContext():
Ctx
Get the current context
Returns
Source
src/model/model.ts:191 (opens in a new tab)
getEvents()
getEvents():
Events<MRun&MConfig,MResponse,AResponse>
Get the current event handlers
Returns
Events<MRun & MConfig, MResponse, AResponse>
Source
src/model/model.ts:230 (opens in a new tab)
getParams()
getParams():
MConfig&Partial<MRun>
Get the current params
Returns
MConfig & Partial<MRun>
Source
src/model/model.ts:208 (opens in a new tab)
run()
run(
params,context?):Promise<MResponse>
Parameters
| Parameter | Type |
|---|---|
params | `{ [K in string |
context? | Ctx |
Returns
Promise<MResponse>
Source
src/model/model.ts:78 (opens in a new tab)
setCache()
setCache(
cache):AbstractModel<MClient,MConfig,MRun,MResponse,AResponse>
Set the cache to a new cache. Set to undefined to remove existing.
Parameters
| Parameter | Type |
|---|---|
cache | undefined | CacheStorage<string, MResponse> |
Returns
AbstractModel<MClient, MConfig, MRun, MResponse, AResponse>
Source
src/model/model.ts:174 (opens in a new tab)
setClient()
setClient(
client):AbstractModel<MClient,MConfig,MRun,MResponse,AResponse>
Set the client to a new OpenAI API client.
Parameters
| Parameter | Type |
|---|---|
client | MClient |
Returns
AbstractModel<MClient, MConfig, MRun, MResponse, AResponse>
Source
src/model/model.ts:185 (opens in a new tab)
setContext()
setContext(
context):AbstractModel<MClient,MConfig,MRun,MResponse,AResponse>
Set the context to a new context. Removes all existing values.
Parameters
| Parameter | Type |
|---|---|
context | Ctx |
Returns
AbstractModel<MClient, MConfig, MRun, MResponse, AResponse>
Source
src/model/model.ts:202 (opens in a new tab)
setEvents()
setEvents(
events):AbstractModel<MClient,MConfig,MRun,MResponse,AResponse>
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<MRun & MConfig, MResponse, AResponse> |
Returns
AbstractModel<MClient, MConfig, MRun, MResponse, AResponse>
Source
src/model/model.ts:244 (opens in a new tab)
setParams()
setParams(
params):AbstractModel<MClient,MConfig,MRun,MResponse,AResponse>
Set the params to a new params. Removes all existing values.
Parameters
| Parameter | Type |
|---|---|
params | MConfig & Partial<MRun> |
Returns
AbstractModel<MClient, MConfig, MRun, MResponse, AResponse>
Source
src/model/model.ts:223 (opens in a new tab)
updateContext()
updateContext(
context):AbstractModel<MClient,MConfig,MRun,MResponse,AResponse>
Add the context. Overrides existing keys.
Parameters
| Parameter | Type |
|---|---|
context | Ctx |
Returns
AbstractModel<MClient, MConfig, MRun, MResponse, AResponse>