diff --git a/src/resources/beta/threads/threads.ts b/src/resources/beta/threads/threads.ts index ccc94fb65..641f48738 100644 --- a/src/resources/beta/threads/threads.ts +++ b/src/resources/beta/threads/threads.ts @@ -2,6 +2,7 @@ import * as Core from 'openai/core'; import { APIResource } from 'openai/resource'; +import { isRequestOptions } from 'openai/core'; import * as ThreadsAPI from 'openai/resources/beta/threads/threads'; import * as MessagesAPI from 'openai/resources/beta/threads/messages/messages'; import * as RunsAPI from 'openai/resources/beta/threads/runs/runs'; @@ -13,7 +14,15 @@ export class Threads extends APIResource { /** * Create a thread. */ - create(body: ThreadCreateParams, options?: Core.RequestOptions): Core.APIPromise { + create(body?: ThreadCreateParams, options?: Core.RequestOptions): Core.APIPromise; + create(options?: Core.RequestOptions): Core.APIPromise; + create( + body: ThreadCreateParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(body)) { + return this.create({}, body); + } return this.post('/threads', { body, ...options, diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index b81da9fa3..412688dfa 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -177,6 +177,14 @@ export interface ChatCompletionChunk { * The object type, which is always `chat.completion.chunk`. */ object: 'chat.completion.chunk'; + + /** + * This fingerprint represents the backend configuration that the model runs with. + * + * Can be used in conjunction with the `seed` request parameter to understand when + * backend changes have been made that might impact determinism. + */ + system_fingerprint?: string; } export namespace ChatCompletionChunk { @@ -296,14 +304,14 @@ export interface ChatCompletionContentPartImage { export namespace ChatCompletionContentPartImage { export interface ImageURL { /** - * Specifies the detail level of the image. + * Either a URL of the image or the base64 encoded image data. */ - detail?: 'auto' | 'low' | 'high'; + url: string; /** - * Either a URL of the image or the base64 encoded image data. + * Specifies the detail level of the image. */ - url?: string; + detail?: 'auto' | 'low' | 'high'; } } @@ -579,6 +587,8 @@ export interface ChatCompletionCreateParamsBase { */ model: | (string & {}) + | 'gpt-4-1106-preview' + | 'gpt-4-vision-preview' | 'gpt-4' | 'gpt-4-0314' | 'gpt-4-0613' diff --git a/tests/api-resources/beta/threads/threads.test.ts b/tests/api-resources/beta/threads/threads.test.ts index 4ca2247dd..fc9fef723 100644 --- a/tests/api-resources/beta/threads/threads.test.ts +++ b/tests/api-resources/beta/threads/threads.test.ts @@ -10,7 +10,7 @@ const openai = new OpenAI({ describe('resource threads', () => { test('create', async () => { - const responsePromise = openai.beta.threads.create({}); + const responsePromise = openai.beta.threads.create(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -20,6 +20,30 @@ describe('resource threads', () => { expect(dataAndResponse.response).toBe(rawResponse); }); + test('create: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(openai.beta.threads.create({ path: '/_stainless_unknown_path' })).rejects.toThrow( + OpenAI.NotFoundError, + ); + }); + + test('create: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + openai.beta.threads.create( + { + 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: {} }, + ], + metadata: {}, + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(OpenAI.NotFoundError); + }); + test('retrieve', async () => { const responsePromise = openai.beta.threads.retrieve('string'); const rawResponse = await responsePromise.asResponse();