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.38.0 #782

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.37.1"
".": "4.38.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 62
configured_endpoints: 63
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 4.38.0 (2024-04-18)

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

### Features

* **api:** batch list endpoint ([#781](https://github.com/openai/openai-node/issues/781)) ([d226759](https://github.com/openai/openai-node/commit/d226759164fbed33198d8bdc315c98e1052dade8))

## 4.37.1 (2024-04-17)

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

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

<!-- x-release-please-end -->
Expand Down
1 change: 1 addition & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,5 @@ Methods:

- <code title="post /batches">client.batches.<a href="./src/resources/batches.ts">create</a>({ ...params }) -> Batch</code>
- <code title="get /batches/{batch_id}">client.batches.<a href="./src/resources/batches.ts">retrieve</a>(batchId) -> Batch</code>
- <code title="get /batches">client.batches.<a href="./src/resources/batches.ts">list</a>({ ...params }) -> BatchesPage</code>
- <code title="post /batches/{batch_id}/cancel">client.batches.<a href="./src/resources/batches.ts">cancel</a>(batchId) -> Batch</code>
2 changes: 1 addition & 1 deletion build-deno
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This is a build produced from https://github.com/openai/openai-node – please g
Usage:

\`\`\`ts
import OpenAI from "https://deno.land/x/openai@v4.37.1/mod.ts";
import OpenAI from "https://deno.land/x/openai@v4.38.0/mod.ts";

const client = new OpenAI();
\`\`\`
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.37.1",
"version": "4.38.0",
"description": "The official TypeScript library for the OpenAI API",
"author": "OpenAI <support@openai.com>",
"types": "dist/index.d.ts",
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ export namespace OpenAI {
export import Batch = API.Batch;
export import BatchError = API.BatchError;
export import BatchRequestCounts = API.BatchRequestCounts;
export import BatchesPage = API.BatchesPage;
export import BatchCreateParams = API.BatchCreateParams;
export import BatchListParams = API.BatchListParams;

export import ErrorObject = API.ErrorObject;
export import FunctionDefinition = API.FunctionDefinition;
Expand Down
23 changes: 23 additions & 0 deletions src/resources/batches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import * as Core from 'openai/core';
import { APIResource } from 'openai/resource';
import { isRequestOptions } from 'openai/core';
import * as BatchesAPI from 'openai/resources/batches';
import { CursorPage, type CursorPageParams } from 'openai/pagination';

export class Batches extends APIResource {
/**
Expand All @@ -19,6 +21,21 @@ export class Batches extends APIResource {
return this._client.get(`/batches/${batchId}`, options);
}

/**
* List your organization's batches.
*/
list(query?: BatchListParams, options?: Core.RequestOptions): Core.PagePromise<BatchesPage, Batch>;
list(options?: Core.RequestOptions): Core.PagePromise<BatchesPage, Batch>;
list(
query: BatchListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<BatchesPage, Batch> {
if (isRequestOptions(query)) {
return this.list({}, query);
}
return this._client.getAPIList('/batches', BatchesPage, { query, ...options });
}

/**
* Cancels an in-progress batch.
*/
Expand All @@ -27,6 +44,8 @@ export class Batches extends APIResource {
}
}

export class BatchesPage extends CursorPage<Batch> {}

export interface Batch {
id: string;

Expand Down Expand Up @@ -217,9 +236,13 @@ export interface BatchCreateParams {
metadata?: Record<string, string> | null;
}

export interface BatchListParams extends CursorPageParams {}

export namespace Batches {
export import Batch = BatchesAPI.Batch;
export import BatchError = BatchesAPI.BatchError;
export import BatchRequestCounts = BatchesAPI.BatchRequestCounts;
export import BatchesPage = BatchesAPI.BatchesPage;
export import BatchCreateParams = BatchesAPI.BatchCreateParams;
export import BatchListParams = BatchesAPI.BatchListParams;
}
10 changes: 9 additions & 1 deletion src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
export * from './chat/index';
export * from './shared';
export { Audio } from './audio/audio';
export { Batch, BatchError, BatchRequestCounts, BatchCreateParams, Batches } from './batches';
export {
Batch,
BatchError,
BatchRequestCounts,
BatchCreateParams,
BatchListParams,
BatchesPage,
Batches,
} from './batches';
export { Beta } from './beta/beta';
export {
Completion,
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.37.1'; // x-release-please-version
export const VERSION = '4.38.0'; // x-release-please-version
25 changes: 25 additions & 0 deletions tests/api-resources/batches.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,31 @@ describe('resource batches', () => {
);
});

test('list', async () => {
const responsePromise = openai.batches.list();
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
expect(response).not.toBeInstanceOf(Response);
const dataAndResponse = await responsePromise.withResponse();
expect(dataAndResponse.data).toBe(response);
expect(dataAndResponse.response).toBe(rawResponse);
});

test('list: 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.batches.list({ path: '/_stainless_unknown_path' })).rejects.toThrow(
OpenAI.NotFoundError,
);
});

test('list: 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.batches.list({ after: 'string', limit: 0 }, { path: '/_stainless_unknown_path' }),
).rejects.toThrow(OpenAI.NotFoundError);
});

test('cancel', async () => {
const responsePromise = openai.batches.cancel('string');
const rawResponse = await responsePromise.asResponse();
Expand Down