Aller au contenu principal
Version: Suivant

OpenAIResult

The OpenAIResult class is designed to handle the response from HTTP requests and provides functions to evaluate the success of the request, retrieve body content, and collect any errors that may have occurred during processing.

Properties

PropertyTypeDescription
request4D.HTTPRequestThe HTTP request

Computed properties

PropertyTypeDescription
successBooleanA Boolean indicating whether the HTTP request was successful.
errorsCollectionReturns a collection of errors. These could be network errors or errors returned by OpenAI.
terminatedBooleanA Boolean indicating whether the HTTP request was terminated.
headersObjectReturns the response headers as an object.
rateLimitObjectReturns rate limit information from the response headers.
usageObjectReturns usage information from the response body if any.

rateLimit

The rateLimit property returns an object containing rate limit information from the response headers. This information includes the limits, remaining requests, and reset times for both requests and tokens.

For more details on rate limits and the specific headers used, refer to the OpenAI Rate Limits Documentation.

The structure of the rateLimit object is as follows:

FieldTypeDescription
limit.requestIntegerNumber of allowed requests.
limit.tokensIntegerNumber of allowed tokens.
remaining.requestIntegerNumber of remaining requests.
remaining.tokensIntegerNumber of remaining tokens.
reset.requestStringTime until request limit resets.
reset.tokensStringTime until token limit resets.

Functions

throw()

Throws the first error in the errors collection. This function is useful for propagating errors up the call stack.

Inherited Classes

Several classes inherit from OpenAIResult to extend its functionality for specific use cases. Below are some of the classes that extend OpenAIResult: