Skip to content

@ralphschuler.ai function caller.index.<internal>.APIPromise

github-actions edited this page Nov 26, 2023 · 1 revision

Class: APIPromise<T>

index.<internal>.APIPromise

A subclass of Promise providing additional helper methods for interacting with the SDK.

Type parameters

Name
T

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new APIPromise<T>(responsePromise, parseResponse?): APIPromise<T>

Type parameters

Name
T

Parameters

Name Type
responsePromise Promise<APIResponseProps>
parseResponse? (props: APIResponseProps) => PromiseOrValue<T>

Returns

APIPromise<T>

Overrides

Promise&lt;T&gt;.constructor

Defined in

node_modules/openai/core.d.ts:23

Properties

[toStringTag]

Readonly [toStringTag]: string

Inherited from

Promise.[toStringTag]

Defined in

node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:176


parse

Private parse: any

Defined in

node_modules/openai/core.d.ts:56


parseResponse

Private parseResponse: any

Defined in

node_modules/openai/core.d.ts:21


parsedPromise

Private parsedPromise: any

Defined in

node_modules/openai/core.d.ts:22


responsePromise

Private responsePromise: any

Defined in

node_modules/openai/core.d.ts:20


[species]

Static Readonly [species]: PromiseConstructor

Inherited from

Promise.[species]

Defined in

node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:180

Methods

_thenUnwrap

_thenUnwrap<U>(transform): APIPromise<U>

Type parameters

Name
U

Parameters

Name Type
transform (data: T) => U

Returns

APIPromise<U>

Defined in

node_modules/openai/core.d.ts:24


asResponse

asResponse(): Promise<Response>

Gets the raw Response instance instead of parsing the response data.

If you want to parse the response body but still get the Response instance, you can use ().

👋 Getting the wrong TypeScript type for Response? Try setting "moduleResolution": "NodeNext" if you can, or add one of these imports before your first import … from 'openai':

  • import 'openai/shims/node' (if you're running on Node)
  • import 'openai/shims/web' (otherwise)

Returns

Promise<Response>

Defined in

node_modules/openai/core.d.ts:38


catch

catch<TResult>(onrejected?): Promise<T | TResult>

Type parameters

Name Type
TResult never

Parameters

Name Type
onrejected? null | (reason: any) => TResult | PromiseLike<TResult>

Returns

Promise<T | TResult>

Overrides

Promise.catch

Defined in

node_modules/openai/core.d.ts:58


finally

finally(onfinally?): Promise<T>

Parameters

Name Type
onfinally? null | () => void

Returns

Promise<T>

Overrides

Promise.finally

Defined in

node_modules/openai/core.d.ts:59


then

then<TResult1, TResult2>(onfulfilled?, onrejected?): Promise<TResult1 | TResult2>

Type parameters

Name Type
TResult1 T
TResult2 never

Parameters

Name Type
onfulfilled? null | (value: T) => TResult1 | PromiseLike<TResult1>
onrejected? null | (reason: any) => TResult2 | PromiseLike<TResult2>

Returns

Promise<TResult1 | TResult2>

Overrides

Promise.then

Defined in

node_modules/openai/core.d.ts:57


withResponse

withResponse(): Promise<{ data: T ; response: Response }>

Gets the parsed response data and the raw Response instance.

If you just want to get the raw Response instance without parsing it, you can use ().

👋 Getting the wrong TypeScript type for Response? Try setting "moduleResolution": "NodeNext" if you can, or add one of these imports before your first import … from 'openai':

  • import 'openai/shims/node' (if you're running on Node)
  • import 'openai/shims/web' (otherwise)

Returns

Promise<{ data: T ; response: Response }>

Defined in

node_modules/openai/core.d.ts:52


all

all<T>(values): Promise<Awaited<T>[]>

Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.

Type parameters

Name
T

Parameters

Name Type Description
values Iterable<T | PromiseLike<T>> An iterable of Promises.

Returns

Promise<Awaited<T>[]>

A new Promise.

Inherited from

Promise.all

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:225

all<T>(values): Promise<{ -readonly [P in string | number | symbol]: Awaited<T[P]> }>

Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.

Type parameters

Name Type
T extends [] | readonly unknown[]

Parameters

Name Type Description
values T An array of Promises.

Returns

Promise<{ -readonly [P in string | number | symbol]: Awaited<T[P]> }>

A new Promise.

Inherited from

Promise.all

Defined in

node_modules/typescript/lib/lib.es2015.promise.d.ts:39


allSettled

allSettled<T>(values): Promise<{ -readonly [P in string | number | symbol]: PromiseSettledResult<Awaited<T[P]>> }>

Creates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.

Type parameters

Name Type
T extends [] | readonly unknown[]

Parameters

Name Type Description
values T An array of Promises.

Returns

Promise<{ -readonly [P in string | number | symbol]: PromiseSettledResult<Awaited<T[P]>> }>

A new Promise.

Inherited from

Promise.allSettled

Defined in

node_modules/typescript/lib/lib.es2020.promise.d.ts:38

allSettled<T>(values): Promise<PromiseSettledResult<Awaited<T>>[]>

Creates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.

Type parameters

Name
T

Parameters

Name Type Description
values Iterable<T | PromiseLike<T>> An array of Promises.

Returns

Promise<PromiseSettledResult<Awaited<T>>[]>

A new Promise.

Inherited from

Promise.allSettled

Defined in

node_modules/typescript/lib/lib.es2020.promise.d.ts:46


any

any<T>(values): Promise<Awaited<T[number]>>

The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.

Type parameters

Name Type
T extends [] | readonly unknown[]

Parameters

Name Type Description
values T An array or iterable of Promises.

Returns

Promise<Awaited<T[number]>>

A new Promise.

Inherited from

Promise.any

Defined in

node_modules/typescript/lib/lib.es2021.promise.d.ts:40

any<T>(values): Promise<Awaited<T>>

The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.

Type parameters

Name
T

Parameters

Name Type Description
values Iterable<T | PromiseLike<T>> An array or iterable of Promises.

Returns

Promise<Awaited<T>>

A new Promise.

Inherited from

Promise.any

Defined in

node_modules/typescript/lib/lib.es2021.promise.d.ts:47


race

race<T>(values): Promise<Awaited<T>>

Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.

Type parameters

Name
T

Parameters

Name Type Description
values Iterable<T | PromiseLike<T>> An iterable of Promises.

Returns

Promise<Awaited<T>>

A new Promise.

Inherited from

Promise.race

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:233

race<T>(values): Promise<Awaited<T[number]>>

Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.

Type parameters

Name Type
T extends [] | readonly unknown[]

Parameters

Name Type Description
values T An array of Promises.

Returns

Promise<Awaited<T[number]>>

A new Promise.

Inherited from

Promise.race

Defined in

node_modules/typescript/lib/lib.es2015.promise.d.ts:50


reject

reject<T>(reason?): Promise<T>

Creates a new rejected promise for the provided reason.

Type parameters

Name Type
T never

Parameters

Name Type Description
reason? any The reason the promise was rejected.

Returns

Promise<T>

A new rejected Promise.

Inherited from

Promise.reject

Defined in

node_modules/typescript/lib/lib.es2015.promise.d.ts:60


resolve

resolve(): Promise<void>

Creates a new resolved promise.

Returns

Promise<void>

A resolved promise.

Inherited from

Promise.resolve

Defined in

node_modules/typescript/lib/lib.es2015.promise.d.ts:66

resolve<T>(value): Promise<Awaited<T>>

Creates a new resolved promise for the provided value.

Type parameters

Name
T

Parameters

Name Type Description
value T A promise.

Returns

Promise<Awaited<T>>

A promise whose internal state matches the provided promise.

Inherited from

Promise.resolve

Defined in

node_modules/typescript/lib/lib.es2015.promise.d.ts:72

resolve<T>(value): Promise<Awaited<T>>

Creates a new resolved promise for the provided value.

Type parameters

Name
T

Parameters

Name Type Description
value T | PromiseLike<T> A promise.

Returns

Promise<Awaited<T>>

A promise whose internal state matches the provided promise.

Inherited from

Promise.resolve

Defined in

node_modules/typescript/lib/lib.es2015.promise.d.ts:78

Typescript Libraries

Modules

Namespaces

Clone this wiki locally