Skip to content

aisbreaker-api-js - v0.1.15 / base/BaseAIsService / BaseAIsService

Class: BaseAIsService<PROPS_T, DEFAULTS_T>

base/BaseAIsService.BaseAIsService

Every service API must implement this interface.

Type parameters

NameType
PROPS_Textends AIsServiceProps
DEFAULTS_Textends AIsServiceDefaults

Hierarchy

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new BaseAIsService<PROPS_T, DEFAULTS_T>(serviceProps, serviceDefaults, auth?)

Type parameters

NameType
PROPS_Textends AIsServiceProps
DEFAULTS_Textends AIsServiceDefaults

Parameters

NameType
servicePropsPROPS_T
serviceDefaultsDEFAULTS_T
auth?Auth

Defined in

aisbreaker-js/packages/aisbreaker-api-js/src/base/BaseAIsService.ts:47

Properties

auth

Optional auth: Auth

Defined in

aisbreaker-js/packages/aisbreaker-api-js/src/base/BaseAIsService.ts:37


engine

engine: string

Defined in

aisbreaker-js/packages/aisbreaker-api-js/src/base/BaseAIsService.ts:43


engineOpt

Optional engineOpt: string

Defined in

aisbreaker-js/packages/aisbreaker-api-js/src/base/BaseAIsService.ts:42


serviceDefaults

serviceDefaults: DEFAULTS_T

Defined in

aisbreaker-js/packages/aisbreaker-api-js/src/base/BaseAIsService.ts:36


serviceProps

serviceProps: PROPS_T

set in constructor

Implementation of

AIsService.serviceProps

Defined in

aisbreaker-js/packages/aisbreaker-api-js/src/base/BaseAIsService.ts:35


task

task: string

Defined in

aisbreaker-js/packages/aisbreaker-api-js/src/base/BaseAIsService.ts:40


url

url: string

Defined in

aisbreaker-js/packages/aisbreaker-api-js/src/base/BaseAIsService.ts:45


urlOpt

Optional urlOpt: string

Defined in

aisbreaker-js/packages/aisbreaker-api-js/src/base/BaseAIsService.ts:44


vendor

vendor: string

Defined in

aisbreaker-js/packages/aisbreaker-api-js/src/base/BaseAIsService.ts:41

Methods

checkRequest

checkRequest(request, context): void

Check that all required fields are present

Parameters

NameTypeDescription
requestRequest
contextstringoptional context information/description/message prefix for logging and for error messages

Returns

void

Defined in

aisbreaker-js/packages/aisbreaker-api-js/src/base/BaseAIsService.ts:264


getContext

getContext(request?): string

Optionally, provide additional context information/description for logging and error messages.

Parameters

NameType
request?Request

Returns

string

Defined in

aisbreaker-js/packages/aisbreaker-api-js/src/base/BaseAIsService.ts:217


getContextService

getContextService(request?): undefined | string

Optionally, provide additional context information/description for logging and error messages.

Parameters

NameType
request?Request

Returns

undefined | string

Defined in

aisbreaker-js/packages/aisbreaker-api-js/src/base/BaseAIsService.ts:230


getConversationState

getConversationState(request): DefaultConversationState

Parameters

NameType
requestRequest

Returns

DefaultConversationState

Defined in

aisbreaker-js/packages/aisbreaker-api-js/src/base/BaseAIsService.ts:277


getService

getService(actualEngine?): Service

Parameters

NameType
actualEngine?string

Returns

Service

ResponseFinal.usage.service

Defined in

aisbreaker-js/packages/aisbreaker-api-js/src/base/BaseAIsService.ts:200


getServiceUrl

getServiceUrl(url, engine, serviceDefaults): undefined | string

Derive the service URL.

Implemented as method here to allow overriding.

Parameters

NameTypeDescription
urlundefined | stringThe (base) URL specified in AIsServiceProps.
engineundefined | stringThe engine derived form serviceId
serviceDefaultsAIsServiceDefaults

Returns

undefined | string

The URL to access the actual AI service.

Defined in

aisbreaker-js/packages/aisbreaker-api-js/src/base/BaseAIsService.ts:249


process

process(request): Promise<ResponseFinal>

Let the service do its work.

Parameters

NameType
requestRequest

Returns

Promise<ResponseFinal>

Implementation of

AIsService.process

Defined in

aisbreaker-js/packages/aisbreaker-api-js/src/base/BaseAIsService.ts:70


processUnprotected

processUnprotected(request, context): Promise<undefined | AIsError | ResponseFinal>

Do the work of process() without the need to care about all error handling.

Parameters

NameTypeDescription
requestRequestthe request to process
contextstringoptional context information/description/message prefix for logging and for error messages

Returns

Promise<undefined | AIsError | ResponseFinal>

The final result. In the case of an error it returns an AIsError OR throws an AIError or general Error.

Defined in

aisbreaker-js/packages/aisbreaker-api-js/src/base/BaseAIsService.ts:188

Released under the MIT License.