From 4f38d4df907fe99f3757da6b58b422b4e663e67c 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] 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 5dfc7d59..04234a74 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 5f17c1b5..2911cfd5 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',