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.61.0 #1070

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

## 4.61.0 (2024-09-13)

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

### Bug Fixes

* **client:** partial parsing update to handle strings ([46e8eb6](https://github.com/openai/openai-node/commit/46e8eb6a9a45b11f9e4c97474ed6c02b1faa43af))
* **examples:** handle usage chunk in tool call streaming ([#1068](https://github.com/openai/openai-node/issues/1068)) ([e4188c4](https://github.com/openai/openai-node/commit/e4188c4ba443a21d1ef94658df5366f80f0e573b))


### Chores

* **examples:** add a small delay to tool-calls example streaming ([a3fc659](https://github.com/openai/openai-node/commit/a3fc65928af7085d1d8d785ad4765fedc3955641))


### Documentation

* update CONTRIBUTING.md ([#1071](https://github.com/openai/openai-node/issues/1071)) ([5de81c9](https://github.com/openai/openai-node/commit/5de81c95d7326602865e007715a76d5595824fd9))

## 4.60.1 (2024-09-13)

Full Changelog: [v4.60.0...v4.60.1](https://github.com/openai/openai-node/compare/v4.60.0...v4.60.1)
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ This will install all the required dependencies and build output files to `dist/

## Modifying/Adding code

Most of the SDK is generated code, and any modified code will be overridden on the next generation. The
`src/lib/` and `examples/` directories are exceptions and will never be overridden.
Most of the SDK is generated code. Modifications to code will be persisted between generations, but may
result in merge conflicts between manual patches and changes from the generator. The generator will never
modify the contents of the `src/lib/` and `examples/` directories.

## Adding and running examples

All files in the `examples/` directory are not modified by the Stainless generator and can be freely edited or
added to.
All files in the `examples/` directory are not modified by the generator and can be freely edited or added to.

```bash
// add an example to examples/<your-example>.ts
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.60.1/mod.ts';
import OpenAI from 'https://deno.land/x/openai@v4.61.0/mod.ts';
```

<!-- x-release-please-end -->
Expand Down
14 changes: 13 additions & 1 deletion examples/tool-calls-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import {
ChatCompletionMessageParam,
} from 'openai/resources/chat';

// Used so that the each chunk coming in is noticable
const CHUNK_DELAY_MS = 100;

// gets API Key from environment variable OPENAI_API_KEY
const openai = new OpenAI();

Expand Down Expand Up @@ -126,6 +129,9 @@ async function main() {
for await (const chunk of stream) {
message = messageReducer(message, chunk);
writeLine(message);

// Add a small delay so that the chunks coming in are noticablej
await new Promise((resolve) => setTimeout(resolve, CHUNK_DELAY_MS));
}
console.log();
messages.push(message);
Expand Down Expand Up @@ -184,7 +190,13 @@ function messageReducer(previous: ChatCompletionMessage, item: ChatCompletionChu
}
return acc;
};
return reduce(previous, item.choices[0]!.delta) as ChatCompletionMessage;

const choice = item.choices[0];
if (!choice) {
// chunk contains information about usage and token counts
return previous;
}
return reduce(previous, choice.delta) as ChatCompletionMessage;
}

function lineRewriter() {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openai",
"version": "4.60.1",
"version": "4.61.0",
"description": "The official TypeScript library for the OpenAI API",
"author": "OpenAI <support@openai.com>",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -43,6 +43,7 @@
"eslint": "^8.49.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-unused-imports": "^3.0.0",
"fast-check": "^3.22.0",
"jest": "^29.4.0",
"prettier": "^3.0.0",
"prettier-2": "npm:prettier@^2",
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/openai@v4.60.1/mod.ts";
import OpenAI from "https://deno.land/x/openai@v4.61.0/mod.ts";

const client = new OpenAI();
\`\`\`
Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/partial-json-parser/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Partial JSON Parser

Vendored from https://www.npmjs.com/package/partial-json-parser and updated to use TypeScript.
Vendored from https://www.npmjs.com/package/partial-json with some modifications
Loading