Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 4.16.2 #442

2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "4.16.1"
".": "4.16.2"
}
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

## 4.16.2 (2023-11-08)

Full Changelog: [v4.16.1...v4.16.2](https://github.com/openai/openai-node/compare/v4.16.1...v4.16.2)

### Bug Fixes

* **api:** accidentally required params, add new models & other fixes ([#463](https://github.com/openai/openai-node/issues/463)) ([1cb403e](https://github.com/openai/openai-node/commit/1cb403e4ccde61bb1613d362f6bdbca8b1681e00))
* **api:** update embedding response object type ([#466](https://github.com/openai/openai-node/issues/466)) ([53b7e25](https://github.com/openai/openai-node/commit/53b7e2539cca0b272be96136c123d2b33745e7f6))
* asssitant_deleted -> assistant_deleted ([#452](https://github.com/openai/openai-node/issues/452)) ([ef89bd7](https://github.com/openai/openai-node/commit/ef89bd74d85c833bf7de500eecd1b092a0ad3f37))
* **types:** ensure all code paths return a value ([#458](https://github.com/openai/openai-node/issues/458)) ([19402c3](https://github.com/openai/openai-node/commit/19402c365572a99cbee58bcd34a9942e741269bf))


### Chores

* **docs:** fix github links ([#457](https://github.com/openai/openai-node/issues/457)) ([6b9b94e](https://github.com/openai/openai-node/commit/6b9b94e4e123349a908b708cd574ff107f40a8e1))
* **internal:** fix typo in comment ([#456](https://github.com/openai/openai-node/issues/456)) ([fe24342](https://github.com/openai/openai-node/commit/fe2434284a91d424510873a18079b8870469c672))


### Documentation

* update deno deploy link to include v ([#441](https://github.com/openai/openai-node/issues/441)) ([47b13aa](https://github.com/openai/openai-node/commit/47b13aaa6fac86fffabee1f752ee6d2efc3def9b))

## 4.16.1 (2023-11-06)

Full Changelog: [v4.16.0...v4.16.1](https://github.com/openai/openai-node/compare/v4.16.0...v4.16.1)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ You can import in Deno via:
<!-- x-release-please-start-version -->

```ts
import OpenAI from 'https://deno.land/x/openai@4.16.0/mod.ts';
import OpenAI from 'https://deno.land/x/openai@v4.16.2/mod.ts';
```

<!-- x-release-please-end -->
Expand Down Expand Up @@ -413,7 +413,7 @@ import OpenAI from "openai";
```

To do the inverse, add `import "openai/shims/node"` (which does import polyfills).
This can also be useful if you are getting the wrong TypeScript types for `Response` - more details [here](https://github.com/openai/openai-node/src/_shims#readme).
This can also be useful if you are getting the wrong TypeScript types for `Response` - more details [here](https://github.com/openai/openai-node/tree/master/src/_shims#readme).

You may also provide a custom `fetch` function when instantiating the client,
which can be used to inspect or alter the `Request` or `Response` before/after each request:
Expand Down
4 changes: 2 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@ Methods:
Types:

- <code><a href="./src/resources/beta/assistants/assistants.ts">Assistant</a></code>
- <code><a href="./src/resources/beta/assistants/assistants.ts">AsssitantDeleted</a></code>
- <code><a href="./src/resources/beta/assistants/assistants.ts">AssistantDeleted</a></code>

Methods:

- <code title="post /assistants">client.beta.assistants.<a href="./src/resources/beta/assistants/assistants.ts">create</a>({ ...params }) -> Assistant</code>
- <code title="get /assistants/{assistant_id}">client.beta.assistants.<a href="./src/resources/beta/assistants/assistants.ts">retrieve</a>(assistantId) -> Assistant</code>
- <code title="post /assistants/{assistant_id}">client.beta.assistants.<a href="./src/resources/beta/assistants/assistants.ts">update</a>(assistantId, { ...params }) -> Assistant</code>
- <code title="get /assistants">client.beta.assistants.<a href="./src/resources/beta/assistants/assistants.ts">list</a>({ ...params }) -> AssistantsPage</code>
- <code title="delete /assistants/{assistant_id}">client.beta.assistants.<a href="./src/resources/beta/assistants/assistants.ts">del</a>(assistantId) -> AsssitantDeleted</code>
- <code title="delete /assistants/{assistant_id}">client.beta.assistants.<a href="./src/resources/beta/assistants/assistants.ts">del</a>(assistantId) -> AssistantDeleted</code>

### Files

Expand Down
2 changes: 1 addition & 1 deletion build-deno
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This is a build produced from https://github.com/openai/openai-node – please g
Usage:

\`\`\`ts
import OpenAI from "$(echo 'https://deno.land/x/openai@4.16.0/mod.ts' | sed -E s/@\.+\\//@"$PACKAGE_VERSION"\\//)";
import OpenAI from "$(echo 'https://deno.land/x/openai@v4.16.1/mod.ts' | sed -E s/@\.+\\//@"$PACKAGE_VERSION"\\//)";

const client = new OpenAI();
\`\`\`
Expand Down
2 changes: 0 additions & 2 deletions ecosystem-tests/node-ts-esm/tests/test-esnext.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// shouldn't need extension, but Jest's ESM module resolution is broken
// however, using .mjs doesn't set the right typings with "moduleResolution": "node"...argh
import 'openai/shims/node.mjs';
import OpenAI from 'openai';
import { distance } from 'fastest-levenshtein';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openai",
"version": "4.16.1",
"version": "4.16.2",
"description": "Client library for the OpenAI API",
"author": "OpenAI <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
4 changes: 3 additions & 1 deletion release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
],
"release-type": "node",
"extra-files": [
"src/version.ts"
"src/version.ts",
"README.md",
"bin/build-deno"
]
}
4 changes: 4 additions & 0 deletions src/lib/AbstractChatCompletionRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ export abstract class AbstractChatCompletionRunner<
return message.function_call;
}
}

return;
}

/**
Expand All @@ -270,6 +272,8 @@ export abstract class AbstractChatCompletionRunner<
return message.content as string;
}
}

return;
}

async finalFunctionCallResult(): Promise<string | undefined> {
Expand Down
6 changes: 3 additions & 3 deletions src/resources/beta/assistants/assistants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class Assistants extends APIResource {
/**
* Delete an assistant.
*/
del(assistantId: string, options?: Core.RequestOptions): Core.APIPromise<AsssitantDeleted> {
del(assistantId: string, options?: Core.RequestOptions): Core.APIPromise<AssistantDeleted> {
return this.delete(`/assistants/${assistantId}`, {
...options,
headers: { 'OpenAI-Beta': 'assistants=v1', ...options?.headers },
Expand Down Expand Up @@ -206,7 +206,7 @@ export namespace Assistant {
}
}

export interface AsssitantDeleted {
export interface AssistantDeleted {
id: string;

deleted: boolean;
Expand Down Expand Up @@ -456,7 +456,7 @@ export interface AssistantListParams extends CursorPageParams {

export namespace Assistants {
export import Assistant = AssistantsAPI.Assistant;
export import AsssitantDeleted = AssistantsAPI.AsssitantDeleted;
export import AssistantDeleted = AssistantsAPI.AssistantDeleted;
export import AssistantsPage = AssistantsAPI.AssistantsPage;
export import AssistantCreateParams = AssistantsAPI.AssistantCreateParams;
export import AssistantUpdateParams = AssistantsAPI.AssistantUpdateParams;
Expand Down
2 changes: 1 addition & 1 deletion src/resources/beta/assistants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

export {
Assistant,
AsssitantDeleted,
AssistantDeleted,
AssistantCreateParams,
AssistantUpdateParams,
AssistantListParams,
Expand Down
2 changes: 1 addition & 1 deletion src/resources/beta/beta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export namespace Beta {
export import Chat = ChatAPI.Chat;
export import Assistants = AssistantsAPI.Assistants;
export import Assistant = AssistantsAPI.Assistant;
export import AsssitantDeleted = AssistantsAPI.AsssitantDeleted;
export import AssistantDeleted = AssistantsAPI.AssistantDeleted;
export import AssistantsPage = AssistantsAPI.AssistantsPage;
export import AssistantCreateParams = AssistantsAPI.AssistantCreateParams;
export import AssistantUpdateParams = AssistantsAPI.AssistantUpdateParams;
Expand Down
2 changes: 1 addition & 1 deletion src/resources/beta/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

export {
Assistant,
AsssitantDeleted,
AssistantDeleted,
AssistantCreateParams,
AssistantUpdateParams,
AssistantListParams,
Expand Down
11 changes: 10 additions & 1 deletion src/resources/beta/threads/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -13,7 +14,15 @@ export class Threads extends APIResource {
/**
* Create a thread.
*/
create(body: ThreadCreateParams, options?: Core.RequestOptions): Core.APIPromise<Thread> {
create(body?: ThreadCreateParams, options?: Core.RequestOptions): Core.APIPromise<Thread>;
create(options?: Core.RequestOptions): Core.APIPromise<Thread>;
create(
body: ThreadCreateParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<Thread> {
if (isRequestOptions(body)) {
return this.create({}, body);
}
return this.post('/threads', {
body,
...options,
Expand Down
18 changes: 14 additions & 4 deletions src/resources/chat/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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';
}
}

Expand Down Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions src/resources/embeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export interface CreateEmbeddingResponse {
model: string;

/**
* The object type, which is always "embedding".
* The object type, which is always "list".
*/
object: 'embedding';
object: 'list';

/**
* The usage information for the request.
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '4.16.1'; // x-release-please-version
export const VERSION = '4.16.2'; // x-release-please-version
26 changes: 25 additions & 1 deletion tests/api-resources/beta/threads/threads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"alwaysStrict": true,
"exactOptionalPropertyTypes": true,
"noUncheckedIndexedAccess": true,
Expand Down