diff --git a/.release-please-manifest.json b/.release-please-manifest.json index fd087344c..c0f9e2df1 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.6.0" + ".": "4.7.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index b4fa6c08c..60ef9e938 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 4.7.0 (2023-09-14) + +Full Changelog: [v4.6.0...v4.7.0](https://github.com/openai/openai-node/compare/v4.6.0...v4.7.0) + +### Features + +* **client:** retry on 408 Request Timeout ([#310](https://github.com/openai/openai-node/issues/310)) ([1f98eac](https://github.com/openai/openai-node/commit/1f98eac5be956e56d75ef5456115165b45a4763c)) +* make docs urls in comments absolute ([#306](https://github.com/openai/openai-node/issues/306)) ([9db3819](https://github.com/openai/openai-node/commit/9db381961e38d2280b0602447e7d91691b327bde)) + ## 4.6.0 (2023-09-08) Full Changelog: [v4.5.0...v4.6.0](https://github.com/openai/openai-node/compare/v4.5.0...v4.6.0) diff --git a/README.md b/README.md index 1e670180f..3e66766ab 100644 --- a/README.md +++ b/README.md @@ -178,8 +178,8 @@ See [`@azure/openai`](https://www.npmjs.com/package/@azure/openai) for an Azure- ### Retries Certain errors will be automatically retried 2 times by default, with a short exponential backoff. -Connection errors (for example, due to a network connectivity problem), 409 Conflict, 429 Rate Limit, -and >=500 Internal errors will all be retried by default. +Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, +429 Rate Limit, and >=500 Internal errors will all be retried by default. You can use the `maxRetries` option to configure or disable this: diff --git a/package.json b/package.json index 5e4fd2c66..02a50b866 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openai", - "version": "4.6.0", + "version": "4.7.0", "description": "Client library for the OpenAI API", "author": "OpenAI ", "types": "dist/index.d.ts", diff --git a/src/core.ts b/src/core.ts index 18190d28e..acf3bd33b 100644 --- a/src/core.ts +++ b/src/core.ts @@ -463,6 +463,9 @@ export abstract class APIClient { if (shouldRetryHeader === 'true') return true; if (shouldRetryHeader === 'false') return false; + // Retry on request timeouts. + if (response.status === 408) return true; + // Retry on lock timeouts. if (response.status === 409) return true; diff --git a/src/resources/audio/transcriptions.ts b/src/resources/audio/transcriptions.ts index 18b8e784b..5819804bd 100644 --- a/src/resources/audio/transcriptions.ts +++ b/src/resources/audio/transcriptions.ts @@ -39,8 +39,9 @@ export interface TranscriptionCreateParams { /** * An optional text to guide the model's style or continue a previous audio - * segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the - * audio language. + * segment. The + * [prompt](https://platform.openai.com/docs/guides/speech-to-text/prompting) + * should match the audio language. */ prompt?: string; diff --git a/src/resources/audio/translations.ts b/src/resources/audio/translations.ts index 922fec294..7043c2c3b 100644 --- a/src/resources/audio/translations.ts +++ b/src/resources/audio/translations.ts @@ -32,8 +32,9 @@ export interface TranslationCreateParams { /** * An optional text to guide the model's style or continue a previous audio - * segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in - * English. + * segment. The + * [prompt](https://platform.openai.com/docs/guides/speech-to-text/prompting) + * should be in English. */ prompt?: string; diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index dfc37a731..76e645445 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -304,8 +304,8 @@ export interface ChatCompletionCreateParamsBase { /** * ID of the model to use. See the - * [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table - * for details on which models work with the Chat API. + * [model endpoint compatibility](https://platform.openai.com/docs/models/model-endpoint-compatibility) + * table for details on which models work with the Chat API. */ model: | (string & {}) @@ -326,7 +326,7 @@ export interface ChatCompletionCreateParamsBase { * existing frequency in the text so far, decreasing the model's likelihood to * repeat the same line verbatim. * - * [See more information about frequency and presence penalties.](/docs/guides/gpt/parameter-details) + * [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/gpt/parameter-details) */ frequency_penalty?: number | null; @@ -377,7 +377,7 @@ export interface ChatCompletionCreateParamsBase { * whether they appear in the text so far, increasing the model's likelihood to * talk about new topics. * - * [See more information about frequency and presence penalties.](/docs/guides/gpt/parameter-details) + * [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/gpt/parameter-details) */ presence_penalty?: number | null; @@ -416,7 +416,8 @@ export interface ChatCompletionCreateParamsBase { /** * A unique identifier representing your end-user, which can help OpenAI to monitor - * and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + * and detect abuse. + * [Learn more](https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids). */ user?: string; } @@ -438,7 +439,8 @@ export namespace ChatCompletionCreateParams { /** * The parameters the functions accepts, described as a JSON Schema object. See the - * [guide](/docs/guides/gpt/function-calling) for examples, and the + * [guide](https://platform.openai.com/docs/guides/gpt/function-calling) for + * examples, and the * [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for * documentation about the format. * diff --git a/src/resources/completions.ts b/src/resources/completions.ts index ee3ccd34f..21f46e63b 100644 --- a/src/resources/completions.ts +++ b/src/resources/completions.ts @@ -117,9 +117,10 @@ export type CompletionCreateParams = CompletionCreateParamsNonStreaming | Comple export interface CompletionCreateParamsBase { /** * ID of the model to use. You can use the - * [List models](/docs/api-reference/models/list) API to see all of your available - * models, or see our [Model overview](/docs/models/overview) for descriptions of - * them. + * [List models](https://platform.openai.com/docs/api-reference/models/list) API to + * see all of your available models, or see our + * [Model overview](https://platform.openai.com/docs/models/overview) for + * descriptions of them. */ model: | (string & {}) @@ -166,7 +167,7 @@ export interface CompletionCreateParamsBase { * existing frequency in the text so far, decreasing the model's likelihood to * repeat the same line verbatim. * - * [See more information about frequency and presence penalties.](/docs/guides/gpt/parameter-details) + * [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/gpt/parameter-details) */ frequency_penalty?: number | null; @@ -221,7 +222,7 @@ export interface CompletionCreateParamsBase { * whether they appear in the text so far, increasing the model's likelihood to * talk about new topics. * - * [See more information about frequency and presence penalties.](/docs/guides/gpt/parameter-details) + * [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/gpt/parameter-details) */ presence_penalty?: number | null; @@ -266,7 +267,8 @@ export interface CompletionCreateParamsBase { /** * A unique identifier representing your end-user, which can help OpenAI to monitor - * and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + * and detect abuse. + * [Learn more](https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids). */ user?: string; } diff --git a/src/resources/embeddings.ts b/src/resources/embeddings.ts index 8709deb9f..5b6484ed5 100644 --- a/src/resources/embeddings.ts +++ b/src/resources/embeddings.ts @@ -61,7 +61,8 @@ export namespace CreateEmbeddingResponse { export interface Embedding { /** * The embedding vector, which is a list of floats. The length of vector depends on - * the model as listed in the [embedding guide](/docs/guides/embeddings). + * the model as listed in the + * [embedding guide](https://platform.openai.com/docs/guides/embeddings). */ embedding: Array; @@ -89,15 +90,17 @@ export interface EmbeddingCreateParams { /** * ID of the model to use. You can use the - * [List models](/docs/api-reference/models/list) API to see all of your available - * models, or see our [Model overview](/docs/models/overview) for descriptions of - * them. + * [List models](https://platform.openai.com/docs/api-reference/models/list) API to + * see all of your available models, or see our + * [Model overview](https://platform.openai.com/docs/models/overview) for + * descriptions of them. */ model: (string & {}) | 'text-embedding-ada-002'; /** * A unique identifier representing your end-user, which can help OpenAI to monitor - * and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + * and detect abuse. + * [Learn more](https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids). */ user?: string; } diff --git a/src/resources/files.ts b/src/resources/files.ts index 90d3f64e5..5ce8096e0 100644 --- a/src/resources/files.ts +++ b/src/resources/files.ts @@ -153,8 +153,9 @@ export interface FileCreateParams { /** * The intended purpose of the uploaded documents. * - * Use "fine-tune" for [fine-tuning](/docs/api-reference/fine-tuning). This allows - * us to validate the format of the uploaded file. + * Use "fine-tune" for + * [fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning). This + * allows us to validate the format of the uploaded file. */ purpose: string; } diff --git a/src/resources/fine-tunes.ts b/src/resources/fine-tunes.ts index e75eed7c7..c65cdd47a 100644 --- a/src/resources/fine-tunes.ts +++ b/src/resources/fine-tunes.ts @@ -15,7 +15,7 @@ export class FineTunes extends APIResource { * Response includes details of the enqueued job including job status and the name * of the fine-tuned models once complete. * - * [Learn more about fine-tuning](/docs/guides/legacy-fine-tuning) + * [Learn more about fine-tuning](https://platform.openai.com/docs/guides/legacy-fine-tuning) */ create(body: FineTuneCreateParams, options?: Core.RequestOptions): Core.APIPromise { return this.post('/fine-tunes', { body, ...options }); @@ -24,7 +24,7 @@ export class FineTunes extends APIResource { /** * Gets info about the fine-tune job. * - * [Learn more about fine-tuning](/docs/guides/legacy-fine-tuning) + * [Learn more about fine-tuning](https://platform.openai.com/docs/guides/legacy-fine-tuning) */ retrieve(fineTuneId: string, options?: Core.RequestOptions): Core.APIPromise { return this.get(`/fine-tunes/${fineTuneId}`, options); @@ -105,8 +105,8 @@ export interface FineTune { /** * The hyperparameters used for the fine-tuning job. See the - * [fine-tuning guide](/docs/guides/legacy-fine-tuning/hyperparameters) for more - * details. + * [fine-tuning guide](https://platform.openai.com/docs/guides/legacy-fine-tuning/hyperparameters) + * for more details. */ hyperparams: FineTune.Hyperparams; @@ -160,8 +160,8 @@ export interface FineTune { export namespace FineTune { /** * The hyperparameters used for the fine-tuning job. See the - * [fine-tuning guide](/docs/guides/legacy-fine-tuning/hyperparameters) for more - * details. + * [fine-tuning guide](https://platform.openai.com/docs/guides/legacy-fine-tuning/hyperparameters) + * for more details. */ export interface Hyperparams { /** @@ -224,15 +224,16 @@ export interface FineTuneCreateParams { /** * The ID of an uploaded file that contains training data. * - * See [upload file](/docs/api-reference/files/upload) for how to upload a file. + * See [upload file](https://platform.openai.com/docs/api-reference/files/upload) + * for how to upload a file. * * Your dataset must be formatted as a JSONL file, where each training example is a * JSON object with the keys "prompt" and "completion". Additionally, you must * upload your file with the purpose `fine-tune`. * * See the - * [fine-tuning guide](/docs/guides/legacy-fine-tuning/creating-training-data) for - * more details. + * [fine-tuning guide](https://platform.openai.com/docs/guides/legacy-fine-tuning/creating-training-data) + * for more details. */ training_file: string; @@ -276,7 +277,7 @@ export interface FineTuneCreateParams { * If set, we calculate classification-specific metrics such as accuracy and F-1 * score using the validation set at the end of every epoch. These metrics can be * viewed in the - * [results file](/docs/guides/legacy-fine-tuning/analyzing-your-fine-tuned-model). + * [results file](https://platform.openai.com/docs/guides/legacy-fine-tuning/analyzing-your-fine-tuned-model). * * In order to compute classification metrics, you must provide a * `validation_file`. Additionally, you must specify `classification_n_classes` for @@ -299,8 +300,8 @@ export interface FineTuneCreateParams { /** * The name of the base model to fine-tune. You can select one of "ada", "babbage", * "curie", "davinci", or a fine-tuned model created after 2022-04-21 and before - * 2023-08-22. To learn more about these models, see the [Models](/docs/models) - * documentation. + * 2023-08-22. To learn more about these models, see the + * [Models](https://platform.openai.com/docs/models) documentation. */ model?: (string & {}) | 'ada' | 'babbage' | 'curie' | 'davinci' | null; @@ -335,7 +336,7 @@ export interface FineTuneCreateParams { * * If you provide this file, the data is used to generate validation metrics * periodically during fine-tuning. These metrics can be viewed in the - * [fine-tuning results file](/docs/guides/legacy-fine-tuning/analyzing-your-fine-tuned-model). + * [fine-tuning results file](https://platform.openai.com/docs/guides/legacy-fine-tuning/analyzing-your-fine-tuned-model). * Your train and validation data should be mutually exclusive. * * Your dataset must be formatted as a JSONL file, where each validation example is @@ -343,8 +344,8 @@ export interface FineTuneCreateParams { * upload your file with the purpose `fine-tune`. * * See the - * [fine-tuning guide](/docs/guides/legacy-fine-tuning/creating-training-data) for - * more details. + * [fine-tuning guide](https://platform.openai.com/docs/guides/legacy-fine-tuning/creating-training-data) + * for more details. */ validation_file?: string | null; } diff --git a/src/resources/fine-tuning/jobs.ts b/src/resources/fine-tuning/jobs.ts index dfb128d4b..2c8ad1049 100644 --- a/src/resources/fine-tuning/jobs.ts +++ b/src/resources/fine-tuning/jobs.ts @@ -14,7 +14,7 @@ export class Jobs extends APIResource { * Response includes details of the enqueued job including job status and the name * of the fine-tuned models once complete. * - * [Learn more about fine-tuning](/docs/guides/fine-tuning) + * [Learn more about fine-tuning](https://platform.openai.com/docs/guides/fine-tuning) */ create(body: JobCreateParams, options?: Core.RequestOptions): Core.APIPromise { return this.post('/fine_tuning/jobs', { body, ...options }); @@ -23,7 +23,7 @@ export class Jobs extends APIResource { /** * Get info about a fine-tuning job. * - * [Learn more about fine-tuning](/docs/guides/fine-tuning) + * [Learn more about fine-tuning](https://platform.openai.com/docs/guides/fine-tuning) */ retrieve(fineTuningJobId: string, options?: Core.RequestOptions): Core.APIPromise { return this.get(`/fine_tuning/jobs/${fineTuningJobId}`, options); @@ -111,7 +111,8 @@ export interface FineTuningJob { /** * The hyperparameters used for the fine-tuning job. See the - * [fine-tuning guide](/docs/guides/fine-tuning) for more details. + * [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning) for + * more details. */ hyperparameters: FineTuningJob.Hyperparameters; @@ -165,7 +166,8 @@ export interface FineTuningJob { export namespace FineTuningJob { /** * The hyperparameters used for the fine-tuning job. See the - * [fine-tuning guide](/docs/guides/fine-tuning) for more details. + * [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning) for + * more details. */ export interface Hyperparameters { /** @@ -193,19 +195,21 @@ export interface FineTuningJobEvent { export interface JobCreateParams { /** * The name of the model to fine-tune. You can select one of the - * [supported models](/docs/guides/fine-tuning/what-models-can-be-fine-tuned). + * [supported models](https://platform.openai.com/docs/guides/fine-tuning/what-models-can-be-fine-tuned). */ model: (string & {}) | 'babbage-002' | 'davinci-002' | 'gpt-3.5-turbo'; /** * The ID of an uploaded file that contains training data. * - * See [upload file](/docs/api-reference/files/upload) for how to upload a file. + * See [upload file](https://platform.openai.com/docs/api-reference/files/upload) + * for how to upload a file. * * Your dataset must be formatted as a JSONL file. Additionally, you must upload * your file with the purpose `fine-tune`. * - * See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. + * See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning) + * for more details. */ training_file: string; @@ -234,7 +238,8 @@ export interface JobCreateParams { * Your dataset must be formatted as a JSONL file. You must upload your file with * the purpose `fine-tune`. * - * See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. + * See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning) + * for more details. */ validation_file?: string | null; } diff --git a/src/resources/images.ts b/src/resources/images.ts index 81eb78674..a7a7424b2 100644 --- a/src/resources/images.ts +++ b/src/resources/images.ts @@ -79,7 +79,8 @@ export interface ImageCreateVariationParams { /** * A unique identifier representing your end-user, which can help OpenAI to monitor - * and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + * and detect abuse. + * [Learn more](https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids). */ user?: string; } @@ -123,7 +124,8 @@ export interface ImageEditParams { /** * A unique identifier representing your end-user, which can help OpenAI to monitor - * and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + * and detect abuse. + * [Learn more](https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids). */ user?: string; } @@ -154,7 +156,8 @@ export interface ImageGenerateParams { /** * A unique identifier representing your end-user, which can help OpenAI to monitor - * and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + * and detect abuse. + * [Learn more](https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids). */ user?: string; } diff --git a/src/version.ts b/src/version.ts index b04b2bd0c..65ca08e28 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '4.6.0'; // x-release-please-version +export const VERSION = '4.7.0'; // x-release-please-version