From e5f385233737002b4bb47a94cba33da7fedfe64d Mon Sep 17 00:00:00 2001 From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com> Date: Thu, 21 Sep 2023 14:51:50 -0400 Subject: [PATCH 1/2] feat(api): add 'gpt-3.5-turbo-instruct', fine-tune error objects, update documentation (#329) --- src/resources/chat/completions.ts | 22 +++++----- src/resources/completions.ts | 8 ++-- src/resources/edits.ts | 5 ++- src/resources/embeddings.ts | 2 +- src/resources/files.ts | 2 +- src/resources/fine-tuning/jobs.ts | 69 +++++++++++++++++++++++-------- 6 files changed, 74 insertions(+), 34 deletions(-) diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index 76e645445..18338c669 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -75,10 +75,11 @@ export namespace ChatCompletion { /** * The reason the model stopped generating tokens. This will be `stop` if the model * hit a natural stop point or a provided stop sequence, `length` if the maximum - * number of tokens specified in the request was reached, or `function_call` if the - * model called a function. + * number of tokens specified in the request was reached, `content_filter` if + * content was omitted due to a flag from our content filters, or `function_call` + * if the model called a function. */ - finish_reason: 'stop' | 'length' | 'function_call'; + finish_reason: 'stop' | 'length' | 'function_call' | 'content_filter'; /** * The index of the choice in the list of choices. @@ -134,8 +135,9 @@ export namespace ChatCompletionChunk { /** * The reason the model stopped generating tokens. This will be `stop` if the model * hit a natural stop point or a provided stop sequence, `length` if the maximum - * number of tokens specified in the request was reached, or `function_call` if the - * model called a function. + * number of tokens specified in the request was reached, `content_filter` if + * content was omitted due to a flag from our content filters, or `function_call` + * if the model called a function. */ finish_reason: 'stop' | 'length' | 'function_call' | null; @@ -331,11 +333,11 @@ export interface ChatCompletionCreateParamsBase { frequency_penalty?: number | null; /** - * Controls how the model responds to function calls. "none" means the model does - * not call a function, and responds to the end-user. "auto" means the model can + * Controls how the model responds to function calls. `none` means the model does + * not call a function, and responds to the end-user. `auto` means the model can * pick between an end-user or calling a function. Specifying a particular function - * via `{"name": "my_function"}` forces the model to call that function. "none" is - * the default when no functions are present. "auto" is the default if functions + * via `{"name": "my_function"}` forces the model to call that function. `none` is + * the default when no functions are present. `auto` is the default if functions * are present. */ function_call?: 'none' | 'auto' | ChatCompletionCreateParams.FunctionCallOption; @@ -365,7 +367,7 @@ export interface ChatCompletionCreateParamsBase { * [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb) * for counting tokens. */ - max_tokens?: number; + max_tokens?: number | null; /** * How many chat completion choices to generate for each input message. diff --git a/src/resources/completions.ts b/src/resources/completions.ts index 21f46e63b..33fa7b258 100644 --- a/src/resources/completions.ts +++ b/src/resources/completions.ts @@ -68,10 +68,11 @@ export interface Completion { export interface CompletionChoice { /** * The reason the model stopped generating tokens. This will be `stop` if the model - * hit a natural stop point or a provided stop sequence, or `length` if the maximum - * number of tokens specified in the request was reached. + * hit a natural stop point or a provided stop sequence, `length` if the maximum + * number of tokens specified in the request was reached, or `content_filter` if + * content was omitted due to a flag from our content filters. */ - finish_reason: 'stop' | 'length'; + finish_reason: 'stop' | 'length' | 'content_filter'; index: number; @@ -126,6 +127,7 @@ export interface CompletionCreateParamsBase { | (string & {}) | 'babbage-002' | 'davinci-002' + | 'gpt-3.5-turbo-instruct' | 'text-davinci-003' | 'text-davinci-002' | 'text-davinci-001' diff --git a/src/resources/edits.ts b/src/resources/edits.ts index 0d23cbb6e..2b6798364 100644 --- a/src/resources/edits.ts +++ b/src/resources/edits.ts @@ -44,8 +44,9 @@ export namespace Edit { export interface Choice { /** * The reason the model stopped generating tokens. This will be `stop` if the model - * hit a natural stop point or a provided stop sequence, or `length` if the maximum - * number of tokens specified in the request was reached. + * hit a natural stop point or a provided stop sequence, `length` if the maximum + * number of tokens specified in the request was reached, or `content_filter` if + * content was omitted due to a flag from our content filters. */ finish_reason: 'stop' | 'length'; diff --git a/src/resources/embeddings.ts b/src/resources/embeddings.ts index 5b6484ed5..ab9fac8d4 100644 --- a/src/resources/embeddings.ts +++ b/src/resources/embeddings.ts @@ -82,7 +82,7 @@ export interface EmbeddingCreateParams { * Input text to embed, encoded as a string or array of tokens. To embed multiple * inputs in a single request, pass an array of strings or array of token arrays. * Each input must not exceed the max input tokens for the model (8191 tokens for - * `text-embedding-ada-002`). + * `text-embedding-ada-002`) and cannot be an empty string. * [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb) * for counting tokens. */ diff --git a/src/resources/files.ts b/src/resources/files.ts index 5ce8096e0..630020214 100644 --- a/src/resources/files.ts +++ b/src/resources/files.ts @@ -41,7 +41,7 @@ export class Files extends APIResource { } /** - * Returns the contents of the specified file + * Returns the contents of the specified file. */ retrieveContent(fileId: string, options?: Core.RequestOptions): Core.APIPromise { return this.get(`/files/${fileId}/content`, { diff --git a/src/resources/fine-tuning/jobs.ts b/src/resources/fine-tuning/jobs.ts index 2c8ad1049..85f5c0f54 100644 --- a/src/resources/fine-tuning/jobs.ts +++ b/src/resources/fine-tuning/jobs.ts @@ -3,7 +3,6 @@ import * as Core from 'openai/core'; import { APIResource } from 'openai/resource'; import { isRequestOptions } from 'openai/core'; -import * as Files from 'openai/resources/files'; import * as API from './index'; import { CursorPage, CursorPageParams } from 'openai/pagination'; @@ -105,10 +104,23 @@ export interface FineTuningJob { created_at: number; /** - * The name of the fine-tuned model that is being created. + * For fine-tuning jobs that have `failed`, this will contain more information on + * the cause of the failure. + */ + error: FineTuningJob.Error | null; + + /** + * The name of the fine-tuned model that is being created. The value will be null + * if the fine-tuning job is still running. */ fine_tuned_model: string | null; + /** + * The Unix timestamp (in seconds) for when the fine-tuning job was finished. The + * value will be null if the fine-tuning job is still running. + */ + finished_at: number | null; + /** * The hyperparameters used for the fine-tuning job. See the * [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning) for @@ -132,38 +144,61 @@ export interface FineTuningJob { organization_id: string; /** - * The compiled results files for the fine-tuning job. + * The compiled results file ID(s) for the fine-tuning job. You can retrieve the + * results with the + * [Files API](https://platform.openai.com/docs/api-reference/files/retrieve-contents). */ - result_files: Array; + result_files: Array; /** - * The current status of the fine-tuning job, which can be either `created`, - * `pending`, `running`, `succeeded`, `failed`, or `cancelled`. + * The current status of the fine-tuning job, which can be either + * `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`. */ status: string; /** - * The total number of billable tokens processed by this fine tuning job. + * The total number of billable tokens processed by this fine-tuning job. The value + * will be null if the fine-tuning job is still running. */ - trained_tokens: number; + trained_tokens: number | null; /** - * The file ID used for training. + * The file ID used for training. You can retrieve the training data with the + * [Files API](https://platform.openai.com/docs/api-reference/files/retrieve-contents). */ training_file: string; /** - * The file ID used for validation. + * The file ID used for validation. You can retrieve the validation results with + * the + * [Files API](https://platform.openai.com/docs/api-reference/files/retrieve-contents). */ validation_file: string | null; +} +export namespace FineTuningJob { /** - * The Unix timestamp (in seconds) for when the fine-tuning job was finished. + * For fine-tuning jobs that have `failed`, this will contain more information on + * the cause of the failure. */ - finished_at?: number; -} + export interface Error { + /** + * A machine-readable error code. + */ + code: string; + + /** + * A human-readable error message. + */ + message: string; + + /** + * The parameter that was invalid, usually `training_file` or `validation_file`. + * This field will be null if the failure was not parameter-specific. + */ + param: string | null; + } -export namespace FineTuningJob { /** * The hyperparameters used for the fine-tuning job. See the * [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning) for @@ -172,11 +207,11 @@ export namespace FineTuningJob { export interface Hyperparameters { /** * The number of epochs to train the model for. An epoch refers to one full cycle - * through the training dataset. "Auto" decides the optimal number of epochs based + * through the training dataset. "auto" decides the optimal number of epochs based * on the size of the dataset. If setting the number manually, we support any * number between 1 and 50 epochs. */ - n_epochs?: 'auto' | number; + n_epochs: 'auto' | number; } } @@ -219,7 +254,7 @@ export interface JobCreateParams { hyperparameters?: JobCreateParams.Hyperparameters; /** - * A string of up to 40 characters that will be added to your fine-tuned model + * A string of up to 18 characters that will be added to your fine-tuned model * name. * * For example, a `suffix` of "custom-model-name" would produce a model name like From dd57062c2976920d22c7efdc0f44df8afedffee2 Mon Sep 17 00:00:00 2001 From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com> Date: Thu, 21 Sep 2023 14:52:08 -0400 Subject: [PATCH 2/2] release: 4.10.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ package.json | 2 +- src/version.ts | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 25b3c3259..7a2c6223d 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.9.1" + ".": "4.10.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index ec37e8079..e1810b0c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 4.10.0 (2023-09-21) + +Full Changelog: [v4.9.1...v4.10.0](https://github.com/openai/openai-node/compare/v4.9.1...v4.10.0) + +### Features + +* **api:** add 'gpt-3.5-turbo-instruct', fine-tune error objects, update documentation ([#329](https://github.com/openai/openai-node/issues/329)) ([e5f3852](https://github.com/openai/openai-node/commit/e5f385233737002b4bb47a94cba33da7fedfe64d)) + ## 4.9.1 (2023-09-21) Full Changelog: [v4.9.0...v4.9.1](https://github.com/openai/openai-node/compare/v4.9.0...v4.9.1) diff --git a/package.json b/package.json index 4754e3626..df892786a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openai", - "version": "4.9.1", + "version": "4.10.0", "description": "Client library for the OpenAI API", "author": "OpenAI ", "types": "dist/index.d.ts", diff --git a/src/version.ts b/src/version.ts index 093c16710..37e598a80 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '4.9.1'; // x-release-please-version +export const VERSION = '4.10.0'; // x-release-please-version