Skip to content
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.57.0"
".": "4.57.1"
}
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 4.57.1 (2024-09-03)

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

### Bug Fixes

* **assistants:** correctly accumulate tool calls when streaming ([#1031](https://github.com/openai/openai-node/issues/1031)) ([d935ad3](https://github.com/openai/openai-node/commit/d935ad3fa37b2701f4c9f6e433ada6074280a871))
* **client:** correct File construction from node-fetch Responses ([#1029](https://github.com/openai/openai-node/issues/1029)) ([22ebdc2](https://github.com/openai/openai-node/commit/22ebdc2ca7d98e0f266110c4cf827e53a0a22026))
* runTools without stream should not emit user message events ([#1005](https://github.com/openai/openai-node/issues/1005)) ([22ded4d](https://github.com/openai/openai-node/commit/22ded4d549a157482a8de2faf65e92c5be07fa95))


### Chores

* **internal/tests:** workaround bug in recent types/node release ([3c7bdfd](https://github.com/openai/openai-node/commit/3c7bdfdb373bff77db0e3fecd5d49ddfa4284cd9))

## 4.57.0 (2024-08-29)

Full Changelog: [v4.56.2...v4.57.0](https://github.com/openai/openai-node/compare/v4.56.2...v4.57.0)
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/[email protected].0/mod.ts';
import OpenAI from 'https://deno.land/x/[email protected].1/mod.ts';
```

<!-- x-release-please-end -->
Expand Down
19 changes: 5 additions & 14 deletions ecosystem-tests/node-ts-cjs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion ecosystem-tests/node-ts-cjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"tsconfig-paths": "^4.0.0"
},
"devDependencies": {
"@types/node": "^20.4.2",
"@types/node": "20.4.2",
"@types/node-fetch": "^2.6.1",
"@types/ws": "^8.5.4",
"fastest-levenshtein": "^1.0.16",
Expand All @@ -22,5 +22,8 @@
"text-encoding-polyfill": "^0.6.7",
"ts-jest": "^29.1.0",
"typescript": "4.7.4"
},
"overrides": {
"@types/node": "20.4.2"
}
}
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.57.0",
"version": "4.57.1",
"description": "The official TypeScript library for the OpenAI API",
"author": "OpenAI <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-deno
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This is a build produced from https://github.com/openai/openai-node – please g
Usage:

\`\`\`ts
import OpenAI from "https://deno.land/x/[email protected].0/mod.ts";
import OpenAI from "https://deno.land/x/[email protected].1/mod.ts";

const client = new OpenAI();
\`\`\`
Expand Down
24 changes: 24 additions & 0 deletions src/lib/AssistantStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,30 @@ export class AssistantStream
accValue.push(...deltaValue); // Use spread syntax for efficient addition
continue;
}

for (const deltaEntry of deltaValue) {
if (!Core.isObj(deltaEntry)) {
throw new Error(`Expected array delta entry to be an object but got: ${deltaEntry}`);
}

const index = deltaEntry['index'];
if (index == null) {
console.error(deltaEntry);
throw new Error('Expected array delta entry to have an `index` property');
}

if (typeof index !== 'number') {
throw new Error(`Expected array delta entry \`index\` property to be a number but got ${index}`);
}

const accEntry = accValue[index];
if (accEntry == null) {
accValue.push(deltaEntry);
} else {
accValue[index] = this.accumulateDelta(accEntry, deltaEntry);
}
}
continue;
} else {
throw Error(`Unhandled record type: ${key}, deltaValue: ${deltaValue}, accValue: ${accValue}`);
}
Expand Down
8 changes: 6 additions & 2 deletions src/lib/ChatCompletionRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ export class ChatCompletionRunner<ParsedT = null> extends AbstractChatCompletion
return runner;
}

override _addMessage(this: ChatCompletionRunner<ParsedT>, message: ChatCompletionMessageParam) {
super._addMessage(message);
override _addMessage(
this: ChatCompletionRunner<ParsedT>,
message: ChatCompletionMessageParam,
emit: boolean = true,
) {
super._addMessage(message, emit);
if (isAssistantMessage(message) && message.content) {
this._emit('content', message.content as string);
}
Expand Down
7 changes: 6 additions & 1 deletion src/uploads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ export async function toFile(
const blob = await value.blob();
name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? 'unknown_file';

return new File([blob as any], name, options);
// we need to convert the `Blob` into an array buffer because the `Blob` class
// that `node-fetch` defines is incompatible with the web standard which results
// in `new File` interpreting it as a string instead of binary data.
const data = isBlobLike(blob) ? [(await blob.arrayBuffer()) as any] : [blob];

return new File(data, name, options);
}

const bits = await getBytes(value);
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.57.0'; // x-release-please-version
export const VERSION = '4.57.1'; // x-release-please-version
12 changes: 0 additions & 12 deletions tests/lib/ChatCompletionRunFunctions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ describe('resource completions', () => {
await runner.done();

expect(listener.messages).toEqual([
{ role: 'user', content: 'tell me what the weather is like' },
{
role: 'assistant',
content: null,
Expand Down Expand Up @@ -700,7 +699,6 @@ describe('resource completions', () => {
await runner.done().catch(() => {});

expect(listener.messages).toEqual([
{ role: 'user', content: 'tell me what the weather is like' },
{
role: 'assistant',
content: null,
Expand Down Expand Up @@ -855,10 +853,6 @@ describe('resource completions', () => {
await runner.done();

expect(listener.messages).toEqual([
{
role: 'user',
content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}',
},
{
role: 'assistant',
content: null,
Expand Down Expand Up @@ -1090,10 +1084,6 @@ describe('resource completions', () => {
]);

expect(listener.messages).toEqual([
{
role: 'user',
content: 'can you tell me how many properties are in {"a": 1, "b": 2, "c": 3}',
},
{
role: 'assistant',
content: null,
Expand Down Expand Up @@ -1207,7 +1197,6 @@ describe('resource completions', () => {
]);

expect(listener.messages).toEqual([
{ role: 'user', content: 'tell me what the weather is like' },
{
role: 'assistant',
content: null,
Expand Down Expand Up @@ -1413,7 +1402,6 @@ describe('resource completions', () => {
]);

expect(listener.messages).toEqual([
{ role: 'user', content: 'tell me what the weather is like' },
{
role: 'assistant',
content: null,
Expand Down