Skip to content

Commit

Permalink
Merge branch 'master' into redact-sensitive-header
Browse files Browse the repository at this point in the history
  • Loading branch information
minhanh-phan authored Dec 18, 2024
2 parents 28bc8e3 + 21c3ed6 commit 9eb8d6b
Show file tree
Hide file tree
Showing 16 changed files with 393 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "4.76.3"
".": "4.77.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 68
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-2e0e0678be19d1118fd796af291822075e40538dba326611e177e9f3dc245a53.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-0d64ca9e45f51b4279f87b205eeb3a3576df98407698ce053f2e2302c1c08df1.yml
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 4.77.0 (2024-12-17)

Full Changelog: [v4.76.3...v4.77.0](https://github.com/openai/openai-node/compare/v4.76.3...v4.77.0)

### Features

* **api:** new o1 and GPT-4o models + preference fine-tuning ([#1229](https://github.com/openai/openai-node/issues/1229)) ([2e872d4](https://github.com/openai/openai-node/commit/2e872d4ac3717ab8f61741efffb7a31acd798338))


### Chores

* **internal:** fix some typos ([#1227](https://github.com/openai/openai-node/issues/1227)) ([d51fcfe](https://github.com/openai/openai-node/commit/d51fcfe3a66550a684eeeb0e6f17e1d9825cdf78))
* **internal:** spec update ([#1230](https://github.com/openai/openai-node/issues/1230)) ([ed2b61d](https://github.com/openai/openai-node/commit/ed2b61d32703b64d9f91223bc02627a607f60483))

## 4.76.3 (2024-12-13)

Full Changelog: [v4.76.2...v4.76.3](https://github.com/openai/openai-node/compare/v4.76.2...v4.76.3)
Expand Down
2 changes: 2 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Types:
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionContentPartInputAudio</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionContentPartRefusal</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionContentPartText</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionDeveloperMessageParam</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionFunctionCallOption</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionFunctionMessageParam</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionMessage</a></code>
Expand All @@ -49,6 +50,7 @@ Types:
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionModality</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionNamedToolChoice</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionPredictionContent</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionReasoningEffort</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionRole</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionStreamOptions</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionSystemMessageParam</a></code>
Expand Down
2 changes: 1 addition & 1 deletion jsr.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openai/openai",
"version": "4.76.3",
"version": "4.77.0",
"exports": "./index.ts",
"publish": {
"exclude": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openai",
"version": "4.76.3",
"version": "4.77.0",
"description": "The official TypeScript library for the OpenAI API",
"author": "OpenAI <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export abstract class APIClient {
maxRetries = 2,
timeout = 600000, // 10 minutes
httpAgent,
fetch: overridenFetch,
fetch: overriddenFetch,
}: {
baseURL: string;
maxRetries?: number | undefined;
Expand All @@ -211,7 +211,7 @@ export abstract class APIClient {
this.timeout = validatePositiveInteger('timeout', timeout);
this.httpAgent = httpAgent;

this.fetch = overridenFetch ?? fetch;
this.fetch = overriddenFetch ?? fetch;
}

protected authHeaders(opts: FinalRequestOptions): Headers {
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import {
ChatCompletionCreateParams,
ChatCompletionCreateParamsNonStreaming,
ChatCompletionCreateParamsStreaming,
ChatCompletionDeveloperMessageParam,
ChatCompletionFunctionCallOption,
ChatCompletionFunctionMessageParam,
ChatCompletionMessage,
Expand All @@ -88,6 +89,7 @@ import {
ChatCompletionModality,
ChatCompletionNamedToolChoice,
ChatCompletionPredictionContent,
ChatCompletionReasoningEffort,
ChatCompletionRole,
ChatCompletionStreamOptions,
ChatCompletionSystemMessageParam,
Expand Down Expand Up @@ -353,6 +355,7 @@ export declare namespace OpenAI {
type ChatCompletionContentPartInputAudio as ChatCompletionContentPartInputAudio,
type ChatCompletionContentPartRefusal as ChatCompletionContentPartRefusal,
type ChatCompletionContentPartText as ChatCompletionContentPartText,
type ChatCompletionDeveloperMessageParam as ChatCompletionDeveloperMessageParam,
type ChatCompletionFunctionCallOption as ChatCompletionFunctionCallOption,
type ChatCompletionFunctionMessageParam as ChatCompletionFunctionMessageParam,
type ChatCompletionMessage as ChatCompletionMessage,
Expand All @@ -361,6 +364,7 @@ export declare namespace OpenAI {
type ChatCompletionModality as ChatCompletionModality,
type ChatCompletionNamedToolChoice as ChatCompletionNamedToolChoice,
type ChatCompletionPredictionContent as ChatCompletionPredictionContent,
type ChatCompletionReasoningEffort as ChatCompletionReasoningEffort,
type ChatCompletionRole as ChatCompletionRole,
type ChatCompletionStreamOptions as ChatCompletionStreamOptions,
type ChatCompletionSystemMessageParam as ChatCompletionSystemMessageParam,
Expand Down
11 changes: 9 additions & 2 deletions src/resources/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
ChatCompletionCreateParams,
ChatCompletionCreateParamsNonStreaming,
ChatCompletionCreateParamsStreaming,
ChatCompletionDeveloperMessageParam,
ChatCompletionFunctionCallOption,
ChatCompletionFunctionMessageParam,
ChatCompletionMessage,
Expand All @@ -24,6 +25,7 @@ import {
ChatCompletionModality,
ChatCompletionNamedToolChoice,
ChatCompletionPredictionContent,
ChatCompletionReasoningEffort,
ChatCompletionRole,
ChatCompletionStreamOptions,
ChatCompletionSystemMessageParam,
Expand All @@ -44,6 +46,8 @@ export class Chat extends APIResource {
}

export type ChatModel =
| 'o1'
| 'o1-2024-12-17'
| 'o1-preview'
| 'o1-preview-2024-09-12'
| 'o1-mini'
Expand All @@ -52,10 +56,11 @@ export type ChatModel =
| 'gpt-4o-2024-11-20'
| 'gpt-4o-2024-08-06'
| 'gpt-4o-2024-05-13'
| 'gpt-4o-realtime-preview'
| 'gpt-4o-realtime-preview-2024-10-01'
| 'gpt-4o-audio-preview'
| 'gpt-4o-audio-preview-2024-10-01'
| 'gpt-4o-audio-preview-2024-12-17'
| 'gpt-4o-mini-audio-preview'
| 'gpt-4o-mini-audio-preview-2024-12-17'
| 'chatgpt-4o-latest'
| 'gpt-4o-mini'
| 'gpt-4o-mini-2024-07-18'
Expand Down Expand Up @@ -96,6 +101,7 @@ export declare namespace Chat {
type ChatCompletionContentPartInputAudio as ChatCompletionContentPartInputAudio,
type ChatCompletionContentPartRefusal as ChatCompletionContentPartRefusal,
type ChatCompletionContentPartText as ChatCompletionContentPartText,
type ChatCompletionDeveloperMessageParam as ChatCompletionDeveloperMessageParam,
type ChatCompletionFunctionCallOption as ChatCompletionFunctionCallOption,
type ChatCompletionFunctionMessageParam as ChatCompletionFunctionMessageParam,
type ChatCompletionMessage as ChatCompletionMessage,
Expand All @@ -104,6 +110,7 @@ export declare namespace Chat {
type ChatCompletionModality as ChatCompletionModality,
type ChatCompletionNamedToolChoice as ChatCompletionNamedToolChoice,
type ChatCompletionPredictionContent as ChatCompletionPredictionContent,
type ChatCompletionReasoningEffort as ChatCompletionReasoningEffort,
type ChatCompletionRole as ChatCompletionRole,
type ChatCompletionStreamOptions as ChatCompletionStreamOptions,
type ChatCompletionSystemMessageParam as ChatCompletionSystemMessageParam,
Expand Down
96 changes: 80 additions & 16 deletions src/resources/chat/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ export class Completions extends APIResource {
* [text generation](https://platform.openai.com/docs/guides/text-generation),
* [vision](https://platform.openai.com/docs/guides/vision), and
* [audio](https://platform.openai.com/docs/guides/audio) guides.
*
* Parameter support can differ depending on the model used to generate the
* response, particularly for newer reasoning models. Parameters that are only
* supported for reasoning models are noted below. For the current state of
* unsupported parameters in reasoning models,
* [refer to the reasoning guide](https://platform.openai.com/docs/guides/reasoning).
*/
create(
body: ChatCompletionCreateParamsNonStreaming,
Expand Down Expand Up @@ -135,6 +141,9 @@ export namespace ChatCompletion {
}
}

/**
* Messages sent by the model in response to user messages.
*/
export interface ChatCompletionAssistantMessageParam {
/**
* The role of the messages author, in this case `assistant`.
Expand Down Expand Up @@ -530,6 +539,29 @@ export interface ChatCompletionContentPartText {
type: 'text';
}

/**
* Developer-provided instructions that the model should follow, regardless of
* messages sent by the user. With o1 models and newer, `developer` messages
* replace the previous `system` messages.
*/
export interface ChatCompletionDeveloperMessageParam {
/**
* The contents of the developer message.
*/
content: string | Array<ChatCompletionContentPartText>;

/**
* The role of the messages author, in this case `developer`.
*/
role: 'developer';

/**
* An optional name for the participant. Provides the model information to
* differentiate between participants of the same role.
*/
name?: string;
}

/**
* Specifying a particular function via `{"name": "my_function"}` forces the model
* to call that function.
Expand Down Expand Up @@ -620,7 +652,13 @@ export namespace ChatCompletionMessage {
}
}

/**
* Developer-provided instructions that the model should follow, regardless of
* messages sent by the user. With o1 models and newer, `developer` messages
* replace the previous `system` messages.
*/
export type ChatCompletionMessageParam =
| ChatCompletionDeveloperMessageParam
| ChatCompletionSystemMessageParam
| ChatCompletionUserMessageParam
| ChatCompletionAssistantMessageParam
Expand Down Expand Up @@ -707,6 +745,16 @@ export interface ChatCompletionPredictionContent {
type: 'content';
}

/**
* **o1 models only**
*
* Constrains effort on reasoning for
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
* supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
* result in faster responses and fewer tokens used on reasoning in a response.
*/
export type ChatCompletionReasoningEffort = 'low' | 'medium' | 'high';

/**
* The role of the author of a message
*/
Expand All @@ -725,6 +773,11 @@ export interface ChatCompletionStreamOptions {
include_usage?: boolean;
}

/**
* Developer-provided instructions that the model should follow, regardless of
* messages sent by the user. With o1 models and newer, use `developer` messages
* for this purpose instead.
*/
export interface ChatCompletionSystemMessageParam {
/**
* The contents of the system message.
Expand Down Expand Up @@ -835,6 +888,10 @@ export interface ChatCompletionToolMessageParam {
tool_call_id: string;
}

/**
* Messages sent by an end user, containing prompts or additional context
* information.
*/
export interface ChatCompletionUserMessageParam {
/**
* The contents of the user message.
Expand Down Expand Up @@ -891,20 +948,22 @@ export interface ChatCompletionCreateParamsBase {
* Number between -2.0 and 2.0. Positive values penalize new tokens based on their
* 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.](https://platform.openai.com/docs/guides/text-generation)
*/
frequency_penalty?: number | null;

/**
* Deprecated in favor of `tool_choice`.
*
* Controls which (if any) function is called by the model. `none` means the model
* will not call a function and instead generates a message. `auto` means the model
* can pick between generating a message or calling a function. Specifying a
* particular function via `{"name": "my_function"}` forces the model to call that
* Controls which (if any) function is called by the model.
*
* `none` means the model will not call a function and instead generates a message.
*
* `auto` means the model can pick between generating a message 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 are present.
*/
Expand Down Expand Up @@ -998,17 +1057,21 @@ export interface ChatCompletionCreateParamsBase {
* Number between -2.0 and 2.0. Positive values penalize new tokens based on
* 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.](https://platform.openai.com/docs/guides/text-generation)
*/
presence_penalty?: number | null;

/**
* An object specifying the format that the model must output. Compatible with
* [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
* [GPT-4o mini](https://platform.openai.com/docs/models#gpt-4o-mini),
* [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4) and
* all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
* **o1 models only**
*
* Constrains effort on reasoning for
* [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
* supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
* result in faster responses and fewer tokens used on reasoning in a response.
*/
reasoning_effort?: ChatCompletionReasoningEffort;

/**
* An object specifying the format that the model must output.
*
* Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
* Outputs which ensures the model will match your supplied JSON schema. Learn more
Expand Down Expand Up @@ -1088,9 +1151,8 @@ export interface ChatCompletionCreateParamsBase {
/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
* make the output more random, while lower values like 0.2 will make it more
* focused and deterministic.
*
* We generally recommend altering this or `top_p` but not both.
* focused and deterministic. We generally recommend altering this or `top_p` but
* not both.
*/
temperature?: number | null;

Expand Down Expand Up @@ -1223,6 +1285,7 @@ export declare namespace Completions {
type ChatCompletionContentPartInputAudio as ChatCompletionContentPartInputAudio,
type ChatCompletionContentPartRefusal as ChatCompletionContentPartRefusal,
type ChatCompletionContentPartText as ChatCompletionContentPartText,
type ChatCompletionDeveloperMessageParam as ChatCompletionDeveloperMessageParam,
type ChatCompletionFunctionCallOption as ChatCompletionFunctionCallOption,
type ChatCompletionFunctionMessageParam as ChatCompletionFunctionMessageParam,
type ChatCompletionMessage as ChatCompletionMessage,
Expand All @@ -1231,6 +1294,7 @@ export declare namespace Completions {
type ChatCompletionModality as ChatCompletionModality,
type ChatCompletionNamedToolChoice as ChatCompletionNamedToolChoice,
type ChatCompletionPredictionContent as ChatCompletionPredictionContent,
type ChatCompletionReasoningEffort as ChatCompletionReasoningEffort,
type ChatCompletionRole as ChatCompletionRole,
type ChatCompletionStreamOptions as ChatCompletionStreamOptions,
type ChatCompletionSystemMessageParam as ChatCompletionSystemMessageParam,
Expand Down
2 changes: 2 additions & 0 deletions src/resources/chat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export {
type ChatCompletionContentPartInputAudio,
type ChatCompletionContentPartRefusal,
type ChatCompletionContentPartText,
type ChatCompletionDeveloperMessageParam,
type ChatCompletionFunctionCallOption,
type ChatCompletionFunctionMessageParam,
type ChatCompletionMessage,
Expand All @@ -21,6 +22,7 @@ export {
type ChatCompletionModality,
type ChatCompletionNamedToolChoice,
type ChatCompletionPredictionContent,
type ChatCompletionReasoningEffort,
type ChatCompletionRole,
type ChatCompletionStreamOptions,
type ChatCompletionSystemMessageParam,
Expand Down
Loading

0 comments on commit 9eb8d6b

Please sign in to comment.