openai 4.22.0 → 4.22.1

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.22.1 (2023-12-15)
4
+
5
+ Full Changelog: [v4.22.0...v4.22.1](https://github.com/openai/openai-node/compare/v4.22.0...v4.22.1)
6
+
7
+ ### Chores
8
+
9
+ * update dependencies ([#572](https://github.com/openai/openai-node/issues/572)) ([a51e620](https://github.com/openai/openai-node/commit/a51e62065224a516b17dd850ae564f5436d8db52))
10
+
11
+
12
+ ### Documentation
13
+
14
+ * replace runFunctions with runTools in readme ([#570](https://github.com/openai/openai-node/issues/570)) ([c3b9ad5](https://github.com/openai/openai-node/commit/c3b9ad58e5f74d3339889aeb1d758c8c18f54de7))
15
+
3
16
  ## 4.22.0 (2023-12-15)
4
17
 
5
18
  Full Changelog: [v4.21.0...v4.22.0](https://github.com/openai/openai-node/compare/v4.21.0...v4.22.0)
package/README.md CHANGED
@@ -21,7 +21,7 @@ You can import in Deno via:
21
21
  <!-- x-release-please-start-version -->
22
22
 
23
23
  ```ts
24
- import OpenAI from 'https://deno.land/x/openai@v4.22.0/mod.ts';
24
+ import OpenAI from 'https://deno.land/x/openai@v4.22.1/mod.ts';
25
25
  ```
26
26
 
27
27
  <!-- x-release-please-end -->
@@ -143,17 +143,17 @@ If you need to cancel a stream, you can `break` from a `for await` loop or call
143
143
 
144
144
  ### Automated function calls
145
145
 
146
- We provide `openai.beta.chat.completions.runFunctions({…})` and `openai.beta.chat.completions.runTools({…})`
147
- convenience helpers for using function calls with the `/chat/completions` endpoint
146
+ We provide the `openai.beta.chat.completions.runTools({…})`
147
+ convenience helper for using function tool calls with the `/chat/completions` endpoint
148
148
  which automatically call the JavaScript functions you provide
149
149
  and sends their results back to the `/chat/completions` endpoint,
150
- looping as long as the model requests function calls.
150
+ looping as long as the model requests tool calls.
151
151
 
152
152
  If you pass a `parse` function, it will automatically parse the `arguments` for you
153
153
  and returns any parsing errors to the model to attempt auto-recovery.
154
154
  Otherwise, the args will be passed to the function you provide as a string.
155
155
 
156
- If you pass `function_call: {name: …}` or `tool_choice: {function: {name: …}}` instead of `auto`,
156
+ If you pass `tool_choice: {function: {name: …}}` instead of `auto`,
157
157
  it returns immediately after calling that function (and only loops to auto-recover parsing errors).
158
158
 
159
159
  ```ts
@@ -163,21 +163,27 @@ const client = new OpenAI();
163
163
 
164
164
  async function main() {
165
165
  const runner = client.beta.chat.completions
166
- .runFunctions({
166
+ .runTools({
167
167
  model: 'gpt-3.5-turbo',
168
168
  messages: [{ role: 'user', content: 'How is the weather this week?' }],
169
- functions: [
169
+ tools: [
170
170
  {
171
- function: getCurrentLocation,
172
- parameters: { type: 'object', properties: {} },
171
+ type: 'function',
172
+ function: {
173
+ function: getCurrentLocation,
174
+ parameters: { type: 'object', properties: {} },
175
+ },
173
176
  },
174
177
  {
175
- function: getWeather,
176
- parse: JSON.parse, // or use a validation library like zod for typesafe parsing.
177
- parameters: {
178
- type: 'object',
179
- properties: {
180
- location: { type: 'string' },
178
+ type: 'function',
179
+ function: {
180
+ function: getWeather,
181
+ parse: JSON.parse, // or use a validation library like zod for typesafe parsing.
182
+ parameters: {
183
+ type: 'object',
184
+ properties: {
185
+ location: { type: 'string' },
186
+ },
181
187
  },
182
188
  },
183
189
  },
@@ -203,10 +209,10 @@ async function getWeather(args: { location: string }) {
203
209
  main();
204
210
 
205
211
  // {role: "user", content: "How's the weather this week?"}
206
- // {role: "assistant", function_call: "getCurrentLocation", arguments: "{}"}
207
- // {role: "function", name: "getCurrentLocation", content: "Boston"}
208
- // {role: "assistant", function_call: "getWeather", arguments: '{"location": "Boston"}'}
209
- // {role: "function", name: "getWeather", content: '{"temperature": "50degF", "preciptation": "high"}'}
212
+ // {role: "assistant", tool_calls: [{type: "function", function: {name: "getCurrentLocation", arguments: "{}"}, id: "123"}
213
+ // {role: "tool", name: "getCurrentLocation", content: "Boston", tool_call_id: "123"}
214
+ // {role: "assistant", tool_calls: [{type: "function", function: {name: "getWeather", arguments: '{"location": "Boston"}'}, id: "1234"}]}
215
+ // {role: "tool", name: "getWeather", content: '{"temperature": "50degF", "preciptation": "high"}', tool_call_id: "1234"}
210
216
  // {role: "assistant", content: "It's looking cold and rainy - you might want to wear a jacket!"}
211
217
  //
212
218
  // Final content: "It's looking cold and rainy - you might want to wear a jacket!"
@@ -214,6 +220,8 @@ main();
214
220
 
215
221
  Like with `.stream()`, we provide a variety of [helpers and events](helpers.md#events).
216
222
 
223
+ Note that `runFunctions` was previously available as well, but has been deprecated in favor of `runTools`.
224
+
217
225
  Read more about various examples such as with integrating with [zod](helpers.md#integrate-with-zod),
218
226
  [next.js](helpers.md#integrate-wtih-next-js), and [proxying a stream to the browser](helpers.md#proxy-streaming-to-a-browser).
219
227
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openai",
3
- "version": "4.22.0",
3
+ "version": "4.22.1",
4
4
  "description": "The official TypeScript library for the OpenAI API",
5
5
  "author": "OpenAI <support@openai.com>",
6
6
  "types": "./index.d.ts",
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '4.22.0'; // x-release-please-version
1
+ export const VERSION = '4.22.1'; // x-release-please-version
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "4.22.0";
1
+ export declare const VERSION = "4.22.1";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '4.22.0'; // x-release-please-version
4
+ exports.VERSION = '4.22.1'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '4.22.0'; // x-release-please-version
1
+ export const VERSION = '4.22.1'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map