openai 2.0.0 → 2.0.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.
Files changed (2) hide show
  1. package/README.md +22 -2
  2. package/package.json +5 -1
package/README.md CHANGED
@@ -28,7 +28,7 @@ const completion = await openai.createCompletion("davinci", {
28
28
  console.log(completion.data.choices[0].text);
29
29
  ```
30
30
 
31
- Check out the [full API documentation](https://beta.openai.com/docs/api-reference?lang=javascript) for examples of all the available functions.
31
+ Check out the [full API documentation](https://beta.openai.com/docs/api-reference?lang=node.js) for examples of all the available functions.
32
32
 
33
33
  ### Request options
34
34
 
@@ -51,6 +51,26 @@ const completion = await openai.createCompletion(
51
51
  );
52
52
  ```
53
53
 
54
+ ### Error handling
55
+
56
+ API requests can potentially return errors due to invalid inputs or other issues. These errors can be handled with a `try...catch` statement, and the error details can be found in either `error.response` or `error.message`:
57
+
58
+ ```javascript
59
+ try {
60
+ const completion = await openai.createCompletion("davinci", {
61
+ prompt: "Hello world",
62
+ });
63
+ console.log(completion.data.choices[0].text);
64
+ } catch (error) {
65
+ if (error.response) {
66
+ console.log(error.response.status);
67
+ console.log(error.response.data);
68
+ } else {
69
+ console.log(error.message);
70
+ }
71
+ }
72
+ ```
73
+
54
74
  ## Thanks
55
75
 
56
- Thank you to [ceifa](https://github.com/ceifa) for creating and maintaining the original unofficial `openai` npm package before we released this official library!
76
+ Thank you to [ceifa](https://github.com/ceifa) for creating and maintaining the original unofficial `openai` npm package before we released this official library! ceifa's original package has been renamed to [gpt-x](https://www.npmjs.com/package/gpt-x).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openai",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Node.js library for the OpenAI API",
5
5
  "keywords": [
6
6
  "openai",
@@ -9,6 +9,10 @@
9
9
  "gpt-3",
10
10
  "gpt3"
11
11
  ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git@github.com:openai/openai-node.git"
15
+ },
12
16
  "author": "OpenAI",
13
17
  "license": "MIT",
14
18
  "main": "./dist/index.js",