Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit authored Dec 8, 2022
2 parents 643d8ce + 700d13b commit 13c857d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chatgpt",
"version": "2.0.3",
"version": "2.0.5",
"description": "Node.js client for the unofficial ChatGPT API.",
"author": "Travis Fischer <[email protected]>",
"repository": "transitive-bullshit/chatgpt-api",
Expand Down
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ const response = await api.sendMessage('this is a timeout test', {
})
```

You can stream responses using the `onProgress` or `onConversationResponse` callbacks. See the [docs](./docs/classes/ChatGPTAPI.md) for more details.

<details>
<summary>Usage in CommonJS (Dynamic import)</summary>

Expand Down Expand Up @@ -180,10 +182,12 @@ All of these awesome projects are built using the `chatgpt` package. 🤯
- [Discord Bot #2](https://github.com/Nageld/ChatGPT-Bot)
- [WeChat Bot #1](https://github.com/AutumnWhj/ChatGPT-wechat-bot)
- [WeChat Bot #2](https://github.com/fuergaosi233/wechat-chatgpt)
- [QQ Bot (plugin for Yunzai-bot)](https://github.com/ikechan8370/chatgpt-plugin)
- [Lovelines.xyz](https://lovelines.xyz)
- [EXM smart contracts](https://github.com/decentldotland/molecule)
- [Flutter ChatGPT API](https://github.com/coskuncay/flutter_chatgpt_api)
- [Carik Bot](https://github.com/luridarmawan/Carik)
- [Github Action for reviewing PRs](https://github.com/kxxt/chatgpt-action/)

If you create a cool integration, feel free to open a PR and add it to the list.

Expand Down
2 changes: 1 addition & 1 deletion src/chatgpt-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class ChatGPTAPI {
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json',
'user-agent': this._userAgent
'User-Agent': this._userAgent
},
body: JSON.stringify(body),
signal: abortSignal,
Expand Down
6 changes: 6 additions & 0 deletions src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ const fetch =
_undici = await import('undici')
}

if (typeof _undici?.fetch !== 'function') {
throw new Error(
'Invalid undici installation; please make sure undici is installed correctly in your node_modules. Note that this package requires Node.js >= 16.8'
)
}

return _undici.fetch(...args)
}

Expand Down

0 comments on commit 13c857d

Please sign in to comment.