From 35fe06e8811d2692f2ae4adc23eb2ad77934592d Mon Sep 17 00:00:00 2001 From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com> Date: Fri, 19 Apr 2024 13:42:26 -0400 Subject: [PATCH] fix(api): correct types for message attachment tools (#787) --- src/resources/beta/threads/messages.ts | 11 +- src/resources/beta/threads/runs/runs.ts | 20 ++- src/resources/beta/threads/threads.ts | 20 ++- .../beta/threads/messages.test.ts | 15 +- .../beta/threads/runs/runs.test.ts | 81 ++++++++- .../beta/threads/threads.test.ts | 162 ++++++++++++++++-- 6 files changed, 269 insertions(+), 40 deletions(-) diff --git a/src/resources/beta/threads/messages.ts b/src/resources/beta/threads/messages.ts index 68fee1a94..559395ca5 100644 --- a/src/resources/beta/threads/messages.ts +++ b/src/resources/beta/threads/messages.ts @@ -4,6 +4,7 @@ import * as Core from 'openai/core'; import { APIResource } from 'openai/resource'; import { isRequestOptions } from 'openai/core'; import * as MessagesAPI from 'openai/resources/beta/threads/messages'; +import * as AssistantsAPI from 'openai/resources/beta/assistants'; import { CursorPage, type CursorPageParams } from 'openai/pagination'; export class Messages extends APIResource { @@ -374,7 +375,10 @@ export namespace Message { */ file_id?: string; - tools?: Array<'file_search' | 'code_interpreter'>; + /** + * The tools to add this file to. + */ + tools?: Array; } /** @@ -528,7 +532,10 @@ export namespace MessageCreateParams { */ file_id?: string; - tools?: Array<'file_search' | 'code_interpreter'>; + /** + * The tools to add this file to. + */ + tools?: Array; } } diff --git a/src/resources/beta/threads/runs/runs.ts b/src/resources/beta/threads/runs/runs.ts index d48619fba..a15565450 100644 --- a/src/resources/beta/threads/runs/runs.ts +++ b/src/resources/beta/threads/runs/runs.ts @@ -780,7 +780,10 @@ export namespace RunCreateParams { */ file_id?: string; - tools?: Array<'file_search' | 'code_interpreter'>; + /** + * The tools to add this file to. + */ + tools?: Array; } } @@ -1028,7 +1031,10 @@ export namespace RunCreateAndPollParams { */ file_id?: string; - tools?: Array<'file_search' | 'code_interpreter'>; + /** + * The tools to add this file to. + */ + tools?: Array; } } @@ -1229,7 +1235,10 @@ export namespace RunCreateAndStreamParams { */ file_id?: string; - tools?: Array<'file_search' | 'code_interpreter'>; + /** + * The tools to add this file to. + */ + tools?: Array; } } @@ -1430,7 +1439,10 @@ export namespace RunStreamParams { */ file_id?: string; - tools?: Array<'file_search' | 'code_interpreter'>; + /** + * The tools to add this file to. + */ + tools?: Array; } } diff --git a/src/resources/beta/threads/threads.ts b/src/resources/beta/threads/threads.ts index 5f325d33a..81ba31dba 100644 --- a/src/resources/beta/threads/threads.ts +++ b/src/resources/beta/threads/threads.ts @@ -318,7 +318,10 @@ export namespace ThreadCreateParams { */ file_id?: string; - tools?: Array<'file_search' | 'code_interpreter'>; + /** + * The tools to add this file to. + */ + tools?: Array; } } @@ -653,7 +656,10 @@ export namespace ThreadCreateAndRunParams { */ file_id?: string; - tools?: Array<'file_search' | 'code_interpreter'>; + /** + * The tools to add this file to. + */ + tools?: Array; } } @@ -999,7 +1005,10 @@ export namespace ThreadCreateAndRunPollParams { */ file_id?: string; - tools?: Array<'file_search' | 'code_interpreter'>; + /** + * The tools to add this file to. + */ + tools?: Array; } } @@ -1324,7 +1333,10 @@ export namespace ThreadCreateAndRunStreamParams { */ file_id?: string; - tools?: Array<'file_search' | 'code_interpreter'>; + /** + * The tools to add this file to. + */ + tools?: Array; } } diff --git a/tests/api-resources/beta/threads/messages.test.ts b/tests/api-resources/beta/threads/messages.test.ts index 61ccebe9f..eb1e78133 100644 --- a/tests/api-resources/beta/threads/messages.test.ts +++ b/tests/api-resources/beta/threads/messages.test.ts @@ -25,9 +25,18 @@ describe('resource messages', () => { content: 'x', role: 'user', attachments: [ - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, + { + file_id: 'string', + tools: [{ type: 'code_interpreter' }, { type: 'code_interpreter' }, { type: 'code_interpreter' }], + }, + { + file_id: 'string', + tools: [{ type: 'code_interpreter' }, { type: 'code_interpreter' }, { type: 'code_interpreter' }], + }, + { + file_id: 'string', + tools: [{ type: 'code_interpreter' }, { type: 'code_interpreter' }, { type: 'code_interpreter' }], + }, ], metadata: {}, }); diff --git a/tests/api-resources/beta/threads/runs/runs.test.ts b/tests/api-resources/beta/threads/runs/runs.test.ts index ea9c0761e..85d97c34c 100644 --- a/tests/api-resources/beta/threads/runs/runs.test.ts +++ b/tests/api-resources/beta/threads/runs/runs.test.ts @@ -29,9 +29,30 @@ describe('resource runs', () => { role: 'user', content: 'x', attachments: [ - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, ], metadata: {}, }, @@ -39,9 +60,30 @@ describe('resource runs', () => { role: 'user', content: 'x', attachments: [ - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, ], metadata: {}, }, @@ -49,9 +91,30 @@ describe('resource runs', () => { role: 'user', content: 'x', attachments: [ - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, ], metadata: {}, }, diff --git a/tests/api-resources/beta/threads/threads.test.ts b/tests/api-resources/beta/threads/threads.test.ts index 6a697865b..f2521cd5b 100644 --- a/tests/api-resources/beta/threads/threads.test.ts +++ b/tests/api-resources/beta/threads/threads.test.ts @@ -37,9 +37,30 @@ describe('resource threads', () => { role: 'user', content: 'x', attachments: [ - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, ], metadata: {}, }, @@ -47,9 +68,30 @@ describe('resource threads', () => { role: 'user', content: 'x', attachments: [ - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, ], metadata: {}, }, @@ -57,9 +99,30 @@ describe('resource threads', () => { role: 'user', content: 'x', attachments: [ - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, ], metadata: {}, }, @@ -153,9 +216,30 @@ describe('resource threads', () => { role: 'user', content: 'x', attachments: [ - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, ], metadata: {}, }, @@ -163,9 +247,30 @@ describe('resource threads', () => { role: 'user', content: 'x', attachments: [ - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, ], metadata: {}, }, @@ -173,9 +278,30 @@ describe('resource threads', () => { role: 'user', content: 'x', attachments: [ - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, - { file_id: 'string', tools: ['file_search', 'code_interpreter'] }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, + { + file_id: 'string', + tools: [ + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + { type: 'code_interpreter' }, + ], + }, ], metadata: {}, },