From f1fdb410e087f9b94faeda0558de573ec1118601 Mon Sep 17 00:00:00 2001 From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com> Date: Fri, 5 Apr 2024 08:36:22 -0400 Subject: [PATCH 1/2] feat(api): add additional messages when creating thread run (#759) --- src/resources/beta/threads/runs/runs.ts | 158 ++++++++++++++++++ .../beta/threads/runs/runs.test.ts | 5 + 2 files changed, 163 insertions(+) diff --git a/src/resources/beta/threads/runs/runs.ts b/src/resources/beta/threads/runs/runs.ts index 5dfc7d595..04234a74f 100644 --- a/src/resources/beta/threads/runs/runs.ts +++ b/src/resources/beta/threads/runs/runs.ts @@ -529,6 +529,11 @@ export interface RunCreateParamsBase { */ additional_instructions?: string | null; + /** + * Adds additional messages to the thread before creating the run. + */ + additional_messages?: Array | null; + /** * Overrides the * [instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant) @@ -574,6 +579,39 @@ export interface RunCreateParamsBase { } export namespace RunCreateParams { + export interface AdditionalMessage { + /** + * The content of the message. + */ + content: string; + + /** + * The role of the entity that is creating the message. Allowed values include: + * + * - `user`: Indicates the message is sent by an actual user and should be used in + * most cases to represent user-generated messages. + * - `assistant`: Indicates the message is generated by the assistant. Use this + * value to insert messages from the assistant into the conversation. + */ + role: 'user' | 'assistant'; + + /** + * A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that + * the message should use. There can be a maximum of 10 files attached to a + * message. Useful for tools like `retrieval` and `code_interpreter` that can + * access and use files. + */ + file_ids?: Array; + + /** + * Set of 16 key-value pairs that can be attached to an object. This can be useful + * for storing additional information about the object in a structured format. Keys + * can be a maximum of 64 characters long and values can be a maxium of 512 + * characters long. + */ + metadata?: unknown | null; + } + export type RunCreateParamsNonStreaming = RunsAPI.RunCreateParamsNonStreaming; export type RunCreateParamsStreaming = RunsAPI.RunCreateParamsStreaming; } @@ -637,6 +675,11 @@ export interface RunCreateAndPollParams { */ additional_instructions?: string | null; + /** + * Adds additional messages to the thread before creating the run. + */ + additional_messages?: Array | null; + /** * Overrides the * [instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant) @@ -674,6 +717,41 @@ export interface RunCreateAndPollParams { tools?: Array | null; } +export namespace RunCreateAndPollParams { + export interface AdditionalMessage { + /** + * The content of the message. + */ + content: string; + + /** + * The role of the entity that is creating the message. Allowed values include: + * + * - `user`: Indicates the message is sent by an actual user and should be used in + * most cases to represent user-generated messages. + * - `assistant`: Indicates the message is generated by the assistant. Use this + * value to insert messages from the assistant into the conversation. + */ + role: 'user' | 'assistant'; + + /** + * A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that + * the message should use. There can be a maximum of 10 files attached to a + * message. Useful for tools like `retrieval` and `code_interpreter` that can + * access and use files. + */ + file_ids?: Array; + + /** + * Set of 16 key-value pairs that can be attached to an object. This can be useful + * for storing additional information about the object in a structured format. Keys + * can be a maximum of 64 characters long and values can be a maxium of 512 + * characters long. + */ + metadata?: unknown | null; + } +} + export interface RunCreateAndStreamParams { /** * The ID of the @@ -689,6 +767,11 @@ export interface RunCreateAndStreamParams { */ additional_instructions?: string | null; + /** + * Adds additional messages to the thread before creating the run. + */ + additional_messages?: Array | null; + /** * Overrides the * [instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant) @@ -726,6 +809,41 @@ export interface RunCreateAndStreamParams { tools?: Array | null; } +export namespace RunCreateAndStreamParams { + export interface AdditionalMessage { + /** + * The content of the message. + */ + content: string; + + /** + * The role of the entity that is creating the message. Allowed values include: + * + * - `user`: Indicates the message is sent by an actual user and should be used in + * most cases to represent user-generated messages. + * - `assistant`: Indicates the message is generated by the assistant. Use this + * value to insert messages from the assistant into the conversation. + */ + role: 'user' | 'assistant'; + + /** + * A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that + * the message should use. There can be a maximum of 10 files attached to a + * message. Useful for tools like `retrieval` and `code_interpreter` that can + * access and use files. + */ + file_ids?: Array; + + /** + * Set of 16 key-value pairs that can be attached to an object. This can be useful + * for storing additional information about the object in a structured format. Keys + * can be a maximum of 64 characters long and values can be a maxium of 512 + * characters long. + */ + metadata?: unknown | null; + } +} + export interface RunStreamParams { /** * The ID of the @@ -741,6 +859,11 @@ export interface RunStreamParams { */ additional_instructions?: string | null; + /** + * Adds additional messages to the thread before creating the run. + */ + additional_messages?: Array | null; + /** * Overrides the * [instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant) @@ -778,6 +901,41 @@ export interface RunStreamParams { tools?: Array | null; } +export namespace RunStreamParams { + export interface AdditionalMessage { + /** + * The content of the message. + */ + content: string; + + /** + * The role of the entity that is creating the message. Allowed values include: + * + * - `user`: Indicates the message is sent by an actual user and should be used in + * most cases to represent user-generated messages. + * - `assistant`: Indicates the message is generated by the assistant. Use this + * value to insert messages from the assistant into the conversation. + */ + role: 'user' | 'assistant'; + + /** + * A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that + * the message should use. There can be a maximum of 10 files attached to a + * message. Useful for tools like `retrieval` and `code_interpreter` that can + * access and use files. + */ + file_ids?: Array; + + /** + * Set of 16 key-value pairs that can be attached to an object. This can be useful + * for storing additional information about the object in a structured format. Keys + * can be a maximum of 64 characters long and values can be a maxium of 512 + * characters long. + */ + metadata?: unknown | null; + } +} + export type RunSubmitToolOutputsParams = | RunSubmitToolOutputsParamsNonStreaming | RunSubmitToolOutputsParamsStreaming; diff --git a/tests/api-resources/beta/threads/runs/runs.test.ts b/tests/api-resources/beta/threads/runs/runs.test.ts index 5f17c1b58..2911cfd53 100644 --- a/tests/api-resources/beta/threads/runs/runs.test.ts +++ b/tests/api-resources/beta/threads/runs/runs.test.ts @@ -24,6 +24,11 @@ describe('resource runs', () => { const response = await openai.beta.threads.runs.create('string', { assistant_id: 'string', additional_instructions: 'string', + additional_messages: [ + { role: 'user', content: 'x', file_ids: ['string'], metadata: {} }, + { role: 'user', content: 'x', file_ids: ['string'], metadata: {} }, + { role: 'user', content: 'x', file_ids: ['string'], metadata: {} }, + ], instructions: 'string', metadata: {}, model: 'string', From 9ca6ad52ef9719e2a7034864486792b3847478a3 Mon Sep 17 00:00:00 2001 From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com> Date: Fri, 5 Apr 2024 08:36:43 -0400 Subject: [PATCH 2/2] release: 4.33.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ README.md | 2 +- build-deno | 2 +- package.json | 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 d6b720422..e5b450ff3 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.32.2" + ".": "4.33.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 22748a5bd..f865d94f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 4.33.0 (2024-04-05) + +Full Changelog: [v4.32.2...v4.33.0](https://github.com/openai/openai-node/compare/v4.32.2...v4.33.0) + +### Features + +* **api:** add additional messages when creating thread run ([#759](https://github.com/openai/openai-node/issues/759)) ([f1fdb41](https://github.com/openai/openai-node/commit/f1fdb410e087f9b94faeda0558de573ec1118601)) + ## 4.32.2 (2024-04-04) Full Changelog: [v4.32.1...v4.32.2](https://github.com/openai/openai-node/compare/v4.32.1...v4.32.2) diff --git a/README.md b/README.md index ba4b69838..62c8967c6 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.32.2/mod.ts'; +import OpenAI from 'https://deno.land/x/openai@v4.33.0/mod.ts'; ``` diff --git a/build-deno b/build-deno index 8d0ee6da9..bbe96faae 100755 --- a/build-deno +++ b/build-deno @@ -14,7 +14,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.32.2/mod.ts"; +import OpenAI from "https://deno.land/x/openai@v4.33.0/mod.ts"; const client = new OpenAI(); \`\`\` diff --git a/package.json b/package.json index 3d0107223..490a9e492 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openai", - "version": "4.32.2", + "version": "4.33.0", "description": "The official TypeScript library for the OpenAI API", "author": "OpenAI ", "types": "dist/index.d.ts", diff --git a/src/version.ts b/src/version.ts index ecc4c1a71..6726dc21c 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '4.32.2'; // x-release-please-version +export const VERSION = '4.33.0'; // x-release-please-version