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.62.0 #1081

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.61.1"
".": "4.62.0"
}
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## 4.62.0 (2024-09-17)

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

### Features

* **client:** add ._request_id property to object responses ([#1078](https://github.com/openai/openai-node/issues/1078)) ([d5c2131](https://github.com/openai/openai-node/commit/d5c21314449091dd1c668c7358b25e041466f588))


### Chores

* **internal:** add ecosystem test for qs reproduction ([0199dd8](https://github.com/openai/openai-node/commit/0199dd85981497fac2b60f786acc00ea30683897))
* **internal:** add query string encoder ([#1079](https://github.com/openai/openai-node/issues/1079)) ([f870682](https://github.com/openai/openai-node/commit/f870682d5c490182547c428b0b5c75da0e34d15a))
* **internal:** fix some types ([#1082](https://github.com/openai/openai-node/issues/1082)) ([1ec41a7](https://github.com/openai/openai-node/commit/1ec41a7d768502a31abb33bf86b0539e5b4b6541))
* **tests:** add query string tests to ecosystem tests ([36be724](https://github.com/openai/openai-node/commit/36be724384401bb697d8b07b0a1965be721cfa51))

## 4.61.1 (2024-09-16)

Full Changelog: [v4.61.0...v4.61.1](https://github.com/openai/openai-node/compare/v4.61.0...v4.61.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.61.1/mod.ts';
import OpenAI from 'https://deno.land/x/openai@v4.62.0/mod.ts';
```

<!-- x-release-please-end -->
Expand Down
8 changes: 8 additions & 0 deletions ecosystem-tests/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ const projectRunners = {
await installPackage();
await run('node', ['test.js']);
},
'nodenext-tsup': async () => {
await installPackage();
await run('npm', ['run', 'build']);

if (state.live) {
await run('npm', ['run', 'main']);
}
},
'ts-browser-webpack': async () => {
await installPackage();

Expand Down
37 changes: 32 additions & 5 deletions ecosystem-tests/node-js/test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
const openaiKey = "a valid OpenAI key"
const OpenAI = require('openai');

console.log(OpenAI)
const openai = new OpenAI();

const openai = new OpenAI({
apiKey: openaiKey,
});
function assertEqual(actual, expected) {
if (actual === expected) {
return;
}

console.error('expected', expected);
console.error('actual ', actual);
throw new Error('expected values to be equal');
}

async function main() {
const completion = await openai.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Say this is a test' }],
});
if (!completion.choices[0].message.content) {
console.dir(completion, { depth: 4 });
throw new Error('no response content!');
}

assertEqual(
decodeURIComponent(openai.stringifyQuery({ foo: { nested: { a: true, b: 'foo' } } })),
'foo[nested][a]=true&foo[nested][b]=foo',
);
assertEqual(
decodeURIComponent(openai.stringifyQuery({ foo: { nested: { a: ['hello', 'world'] } } })),
'foo[nested][a][]=hello&foo[nested][a][]=world',
);
}

main();
9 changes: 9 additions & 0 deletions ecosystem-tests/node-ts-cjs-auto/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,12 @@ describe('toFile', () => {
expect(result.filename).toEqual('finetune.jsonl');
});
});

test('query strings', () => {
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: true, b: 'foo' } } })),
).toEqual('foo[nested][a]=true&foo[nested][b]=foo');
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: ['hello', 'world'] } } })),
).toEqual('foo[nested][a][]=hello&foo[nested][a][]=world');
});
9 changes: 9 additions & 0 deletions ecosystem-tests/node-ts-cjs-web/tests/test-jsdom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,12 @@ describe.skip('toFile', () => {
expect(result.filename).toEqual('finetune.jsonl');
});
});

test('query strings', () => {
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: true, b: 'foo' } } })),
).toEqual('foo[nested][a]=true&foo[nested][b]=foo');
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: ['hello', 'world'] } } })),
).toEqual('foo[nested][a][]=hello&foo[nested][a][]=world');
});
9 changes: 9 additions & 0 deletions ecosystem-tests/node-ts-cjs-web/tests/test-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,12 @@ describe('toFile', () => {
expect(result.filename).toEqual('finetune.jsonl');
});
});

test('query strings', () => {
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: true, b: 'foo' } } })),
).toEqual('foo[nested][a]=true&foo[nested][b]=foo');
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: ['hello', 'world'] } } })),
).toEqual('foo[nested][a][]=hello&foo[nested][a][]=world');
});
9 changes: 9 additions & 0 deletions ecosystem-tests/node-ts-cjs/tests/test-jsdom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,12 @@ describe.skip('toFile', () => {
expect(result.filename).toEqual('finetune.jsonl');
});
});

test('query strings', () => {
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: true, b: 'foo' } } })),
).toEqual('foo[nested][a]=true&foo[nested][b]=foo');
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: ['hello', 'world'] } } })),
).toEqual('foo[nested][a][]=hello&foo[nested][a][]=world');
});
9 changes: 9 additions & 0 deletions ecosystem-tests/node-ts-cjs/tests/test-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,12 @@ describe('toFile', () => {
expect(result.filename).toEqual('finetune.jsonl');
});
});

test('query strings', () => {
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: true, b: 'foo' } } })),
).toEqual('foo[nested][a]=true&foo[nested][b]=foo');
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: ['hello', 'world'] } } })),
).toEqual('foo[nested][a][]=hello&foo[nested][a][]=world');
});
9 changes: 9 additions & 0 deletions ecosystem-tests/node-ts-esm-auto/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,12 @@ describe('toFile', () => {
expect(result.filename).toEqual('finetune.jsonl');
});
});

test('query strings', () => {
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: true, b: 'foo' } } })),
).toEqual('foo[nested][a]=true&foo[nested][b]=foo');
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: ['hello', 'world'] } } })),
).toEqual('foo[nested][a][]=hello&foo[nested][a][]=world');
});
9 changes: 9 additions & 0 deletions ecosystem-tests/node-ts-esm-web/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,12 @@ describe('toFile', () => {
expect(result.filename).toEqual('finetune.jsonl');
});
});

test('query strings', () => {
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: true, b: 'foo' } } })),
).toEqual('foo[nested][a]=true&foo[nested][b]=foo');
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: ['hello', 'world'] } } })),
).toEqual('foo[nested][a][]=hello&foo[nested][a][]=world');
});
9 changes: 9 additions & 0 deletions ecosystem-tests/node-ts-esm/tests/test-esnext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,12 @@ it(`raw response`, async function () {
const json: ChatCompletion = JSON.parse(chunks.join(''));
expect(json.choices[0]?.message.content || '').toBeSimilarTo('This is a test', 10);
});

test('query strings', () => {
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: true, b: 'foo' } } })),
).toEqual('foo[nested][a]=true&foo[nested][b]=foo');
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: ['hello', 'world'] } } })),
).toEqual('foo[nested][a][]=hello&foo[nested][a][]=world');
});
9 changes: 9 additions & 0 deletions ecosystem-tests/node-ts-esm/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,12 @@ describe('toFile', () => {
expect(result.filename).toEqual('finetune.jsonl');
});
});

test('query strings', () => {
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: true, b: 'foo' } } })),
).toEqual('foo[nested][a]=true&foo[nested][b]=foo');
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: ['hello', 'world'] } } })),
).toEqual('foo[nested][a][]=hello&foo[nested][a][]=world');
});
9 changes: 9 additions & 0 deletions ecosystem-tests/node-ts4.5-jest27/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,12 @@ describe('toFile', () => {
expect(result.filename).toEqual('finetune.jsonl');
});
});

test('query strings', () => {
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: true, b: 'foo' } } })),
).toEqual('foo[nested][a]=true&foo[nested][b]=foo');
expect(
decodeURIComponent((client as any).stringifyQuery({ foo: { nested: { a: ['hello', 'world'] } } })),
).toEqual('foo[nested][a][]=hello&foo[nested][a][]=world');
});
41 changes: 41 additions & 0 deletions ecosystem-tests/nodenext-tsup/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { OpenAI } from 'openai';

const openai = new OpenAI();

function assertEqual(actual: any, expected: any) {
if (actual === expected) {
return;
}

console.error('expected', expected);
console.error('actual ', actual);
throw new Error('expected values to be equal');
}

async function main() {
const completion = await openai.chat.completions.create({
model: 'gpt-4o-mini',
messages: [
{
role: 'user',
content: 'What is the capital of the United States?',
},
],
});
// smoke test for responses
if (!completion.choices[0]?.message.content) {
console.dir(completion, { depth: 4 });
throw new Error('no response content!');
}

assertEqual(
decodeURIComponent((openai as any).stringifyQuery({ foo: { nested: { a: true, b: 'foo' } } })),
'foo[nested][a]=true&foo[nested][b]=foo',
);
assertEqual(
decodeURIComponent((openai as any).stringifyQuery({ foo: { nested: { a: ['hello', 'world'] } } })),
'foo[nested][a][]=hello&foo[nested][a][]=world',
);
}

main();
Loading