openai 4.15.0 → 4.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +40 -5
- package/package.json +1 -1
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.15.2 (2023-11-04)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v4.15.1...v4.15.2](https://github.com/openai/openai-node/compare/v4.15.1...v4.15.2)
|
|
6
|
+
|
|
7
|
+
### Documentation
|
|
8
|
+
|
|
9
|
+
* fix deno.land import ([#423](https://github.com/openai/openai-node/issues/423)) ([e5415a2](https://github.com/openai/openai-node/commit/e5415a29ab447ced8535fafda7928b0a6748c8d1))
|
|
10
|
+
|
|
11
|
+
## 4.15.1 (2023-11-04)
|
|
12
|
+
|
|
13
|
+
Full Changelog: [v4.15.0...v4.15.1](https://github.com/openai/openai-node/compare/v4.15.0...v4.15.1)
|
|
14
|
+
|
|
15
|
+
### Documentation
|
|
16
|
+
|
|
17
|
+
* document customizing fetch ([#420](https://github.com/openai/openai-node/issues/420)) ([1ca982f](https://github.com/openai/openai-node/commit/1ca982f192daf49e33b7acb5505ed26c9d891255))
|
|
18
|
+
|
|
3
19
|
## 4.15.0 (2023-11-03)
|
|
4
20
|
|
|
5
21
|
Full Changelog: [v4.14.2...v4.15.0](https://github.com/openai/openai-node/compare/v4.14.2...v4.15.0)
|
package/README.md
CHANGED
|
@@ -18,14 +18,10 @@ yarn add openai
|
|
|
18
18
|
|
|
19
19
|
You can import in Deno via:
|
|
20
20
|
|
|
21
|
-
<!-- x-release-please-start-version -->
|
|
22
|
-
|
|
23
21
|
```ts
|
|
24
|
-
import OpenAI from 'https://
|
|
22
|
+
import OpenAI from 'https://deno.land/x/openai';
|
|
25
23
|
```
|
|
26
24
|
|
|
27
|
-
<!-- x-release-please-end -->
|
|
28
|
-
|
|
29
25
|
## Usage
|
|
30
26
|
|
|
31
27
|
The full API of this library can be found in [api.md file](https://github.com/openai/openai-node/blob/master/api.md). The code below shows how to get started using the chat completions API.
|
|
@@ -395,6 +391,45 @@ console.log(raw.headers.get('X-My-Header'));
|
|
|
395
391
|
console.log(chatCompletion.choices);
|
|
396
392
|
```
|
|
397
393
|
|
|
394
|
+
## Customizing the fetch client
|
|
395
|
+
|
|
396
|
+
By default, this library uses `node-fetch` in Node, and expects a global `fetch` function in other environments.
|
|
397
|
+
|
|
398
|
+
If you would prefer to use a global, web-standards-compliant `fetch` function even in a Node environment,
|
|
399
|
+
(for example, if you are running Node with `--experimental-fetch` or using NextJS which polyfills with `undici`),
|
|
400
|
+
add the following import before your first import `from "OpenAI"`:
|
|
401
|
+
|
|
402
|
+
<!-- prettier-ignore -->
|
|
403
|
+
```ts
|
|
404
|
+
// Tell TypeScript and the package to use the global web fetch instead of node-fetch.
|
|
405
|
+
// Note, despite the name, this does not add any polyfills, but expects them to be provided if needed.
|
|
406
|
+
import "openai/shims/web";
|
|
407
|
+
import OpenAI from "openai";
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
To do the inverse, add `import "openai/shims/node"` (which does import polyfills).
|
|
411
|
+
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).
|
|
412
|
+
|
|
413
|
+
You may also provide a custom `fetch` function when instantiating the client,
|
|
414
|
+
which can be used to inspect or alter the `Request` or `Response` before/after each request:
|
|
415
|
+
|
|
416
|
+
```ts
|
|
417
|
+
import { fetch } from 'undici'; // as one example
|
|
418
|
+
import OpenAI from 'openai';
|
|
419
|
+
|
|
420
|
+
const client = new OpenAI({
|
|
421
|
+
fetch: (url: RequestInfo, init?: RequestInfo): Response => {
|
|
422
|
+
console.log('About to make request', url, init);
|
|
423
|
+
const response = await fetch(url, init);
|
|
424
|
+
console.log('Got response', response);
|
|
425
|
+
return response;
|
|
426
|
+
},
|
|
427
|
+
});
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
Note that if given a `DEBUG=true` environment variable, this library will log all requests and responses automatically.
|
|
431
|
+
This is intended for debugging purposes only and may change in the future without notice.
|
|
432
|
+
|
|
398
433
|
## Configuring an HTTP(S) Agent (e.g., for proxies)
|
|
399
434
|
|
|
400
435
|
By default, this library uses a stable agent for all http/https requests to reuse TCP connections, eliminating many TCP & TLS handshakes and shaving around 100ms off most requests.
|
package/package.json
CHANGED
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '4.15.
|
|
1
|
+
export const VERSION = '4.15.2'; // x-release-please-version
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "4.15.
|
|
1
|
+
export declare const VERSION = "4.15.2";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '4.15.
|
|
1
|
+
export const VERSION = '4.15.2'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|