Skip to content

Commit

Permalink
feat(api): add additional messages when creating thread run (#759)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Apr 5, 2024
1 parent 4999e9b commit f1fdb41
Show file tree
Hide file tree
Showing 2 changed files with 163 additions and 0 deletions.
158 changes: 158 additions & 0 deletions src/resources/beta/threads/runs/runs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,11 @@ export interface RunCreateParamsBase {
*/
additional_instructions?: string | null;

/**
* Adds additional messages to the thread before creating the run.
*/
additional_messages?: Array<RunCreateParams.AdditionalMessage> | null;

/**
* Overrides the
* [instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant)
Expand Down Expand Up @@ -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<string>;

/**
* 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;
}
Expand Down Expand Up @@ -637,6 +675,11 @@ export interface RunCreateAndPollParams {
*/
additional_instructions?: string | null;

/**
* Adds additional messages to the thread before creating the run.
*/
additional_messages?: Array<RunCreateAndPollParams.AdditionalMessage> | null;

/**
* Overrides the
* [instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant)
Expand Down Expand Up @@ -674,6 +717,41 @@ export interface RunCreateAndPollParams {
tools?: Array<AssistantsAPI.AssistantTool> | 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<string>;

/**
* 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
Expand All @@ -689,6 +767,11 @@ export interface RunCreateAndStreamParams {
*/
additional_instructions?: string | null;

/**
* Adds additional messages to the thread before creating the run.
*/
additional_messages?: Array<RunCreateAndStreamParams.AdditionalMessage> | null;

/**
* Overrides the
* [instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant)
Expand Down Expand Up @@ -726,6 +809,41 @@ export interface RunCreateAndStreamParams {
tools?: Array<AssistantsAPI.AssistantTool> | 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<string>;

/**
* 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
Expand All @@ -741,6 +859,11 @@ export interface RunStreamParams {
*/
additional_instructions?: string | null;

/**
* Adds additional messages to the thread before creating the run.
*/
additional_messages?: Array<RunStreamParams.AdditionalMessage> | null;

/**
* Overrides the
* [instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant)
Expand Down Expand Up @@ -778,6 +901,41 @@ export interface RunStreamParams {
tools?: Array<AssistantsAPI.AssistantTool> | 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<string>;

/**
* 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;
Expand Down
5 changes: 5 additions & 0 deletions tests/api-resources/beta/threads/runs/runs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit f1fdb41

Please sign in to comment.