From 6424924b6361e54f07c04fce9075ab16fcb712fb Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Tue, 1 Oct 2024 17:52:44 +0000 Subject: [PATCH 1/2] feat(api): support storing chat completions, enabling evals and model distillation in the dashboard (#1112) Learn more at http://openai.com/devday2024 --- src/resources/chat/chat.ts | 1 + src/resources/chat/completions.ts | 20 ++++++++++++++-- src/resources/completions.ts | 25 ++++++++++++++++++++ tests/api-resources/chat/completions.test.ts | 2 ++ 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/resources/chat/chat.ts b/src/resources/chat/chat.ts index 1a758fbb5..5bc7de955 100644 --- a/src/resources/chat/chat.ts +++ b/src/resources/chat/chat.ts @@ -16,6 +16,7 @@ export type ChatModel = | 'gpt-4o' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-05-13' + | 'gpt-4o-realtime-preview-2024-10-01' | 'chatgpt-4o-latest' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index f426ce36f..27aebdc4c 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -727,8 +727,12 @@ export type ChatCompletionCreateParams = export interface ChatCompletionCreateParamsBase { /** - * A list of messages comprising the conversation so far. - * [Example Python code](https://cookbook.openai.com/examples/how_to_format_inputs_to_chatgpt_models). + * A list of messages comprising the conversation so far. Depending on the + * [model](https://platform.openai.com/docs/models) you use, different message + * types (modalities) are supported, like + * [text](https://platform.openai.com/docs/guides/text-generation), + * [images](https://platform.openai.com/docs/guides/vision), and + * [audio](https://platform.openai.com/docs/guides/audio). */ messages: Array; @@ -806,6 +810,12 @@ export interface ChatCompletionCreateParamsBase { */ max_tokens?: number | null; + /** + * Developer-defined tags and values used for filtering completions in the + * [dashboard](https://platform.openai.com/completions). + */ + metadata?: Record | null; + /** * How many chat completion choices to generate for each input message. Note that * you will be charged based on the number of generated tokens across all of the @@ -889,6 +899,12 @@ export interface ChatCompletionCreateParamsBase { */ stop?: string | null | Array; + /** + * Whether or not to store the output of this completion request for traffic + * logging in the [dashboard](https://platform.openai.com/completions). + */ + store?: boolean | null; + /** * If set, partial message deltas will be sent, like in ChatGPT. Tokens will be * sent as data-only diff --git a/src/resources/completions.ts b/src/resources/completions.ts index 152496766..7acd5d13f 100644 --- a/src/resources/completions.ts +++ b/src/resources/completions.ts @@ -125,6 +125,11 @@ export interface CompletionUsage { * Breakdown of tokens used in a completion. */ completion_tokens_details?: CompletionUsage.CompletionTokensDetails; + + /** + * Breakdown of tokens used in the prompt. + */ + prompt_tokens_details?: CompletionUsage.PromptTokensDetails; } export namespace CompletionUsage { @@ -132,11 +137,31 @@ export namespace CompletionUsage { * Breakdown of tokens used in a completion. */ export interface CompletionTokensDetails { + /** + * Audio input tokens generated by the model. + */ + audio_tokens?: number; + /** * Tokens generated by the model for reasoning. */ reasoning_tokens?: number; } + + /** + * Breakdown of tokens used in the prompt. + */ + export interface PromptTokensDetails { + /** + * Audio input tokens present in the prompt. + */ + audio_tokens?: number; + + /** + * Cached tokens present in the prompt. + */ + cached_tokens?: number; + } } export type CompletionCreateParams = CompletionCreateParamsNonStreaming | CompletionCreateParamsStreaming; diff --git a/tests/api-resources/chat/completions.test.ts b/tests/api-resources/chat/completions.test.ts index 692b953f2..4f015b47e 100644 --- a/tests/api-resources/chat/completions.test.ts +++ b/tests/api-resources/chat/completions.test.ts @@ -34,6 +34,7 @@ describe('resource completions', () => { logprobs: true, max_completion_tokens: 0, max_tokens: 0, + metadata: { foo: 'string' }, n: 1, parallel_tool_calls: true, presence_penalty: -2, @@ -41,6 +42,7 @@ describe('resource completions', () => { seed: -9007199254740991, service_tier: 'auto', stop: 'string', + store: true, stream: false, stream_options: { include_usage: true }, temperature: 1, From 544e1cfc17bdfda423ebd7ea9528d828c97423bd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:53:05 +0000 Subject: [PATCH 2/2] release: 4.67.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ README.md | 2 +- package.json | 2 +- scripts/build-deno | 2 +- src/version.ts | 2 +- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 933d4022c..6872cea50 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.66.1" + ".": "4.67.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index e927252ce..1c8960f56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 4.67.0 (2024-10-01) + +Full Changelog: [v4.66.1...v4.67.0](https://github.com/openai/openai-node/compare/v4.66.1...v4.67.0) + +### Features + +* **api:** support storing chat completions, enabling evals and model distillation in the dashboard ([#1112](https://github.com/openai/openai-node/issues/1112)) ([6424924](https://github.com/openai/openai-node/commit/6424924b6361e54f07c04fce9075ab16fcb712fb)) + ## 4.66.1 (2024-09-30) Full Changelog: [v4.66.0...v4.66.1](https://github.com/openai/openai-node/compare/v4.66.0...v4.66.1) diff --git a/README.md b/README.md index a0132bb63..4eaa2a8f7 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ You can import in Deno via: ```ts -import OpenAI from 'https://deno.land/x/openai@v4.66.1/mod.ts'; +import OpenAI from 'https://deno.land/x/openai@v4.67.0/mod.ts'; ``` diff --git a/package.json b/package.json index 038d377ea..eb6aa2fa0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openai", - "version": "4.66.1", + "version": "4.67.0", "description": "The official TypeScript library for the OpenAI API", "author": "OpenAI ", "types": "dist/index.d.ts", diff --git a/scripts/build-deno b/scripts/build-deno index 7d0c4219d..91d392205 100755 --- a/scripts/build-deno +++ b/scripts/build-deno @@ -16,7 +16,7 @@ This is a build produced from https://github.com/openai/openai-node – please g Usage: \`\`\`ts -import OpenAI from "https://deno.land/x/openai@v4.66.1/mod.ts"; +import OpenAI from "https://deno.land/x/openai@v4.67.0/mod.ts"; const client = new OpenAI(); \`\`\` diff --git a/src/version.ts b/src/version.ts index ce3023d68..fe2f611c2 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '4.66.1'; // x-release-please-version +export const VERSION = '4.67.0'; // x-release-please-version