diff --git a/legacy/package.json b/legacy/package.json index c776a3bb..36fe72bc 100644 --- a/legacy/package.json +++ b/legacy/package.json @@ -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 ", "repository": "transitive-bullshit/chatgpt-api", diff --git a/legacy/readme.md b/legacy/readme.md index df3a9014..d70b1c44 100644 --- a/legacy/readme.md +++ b/legacy/readme.md @@ -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. +
Usage in CommonJS (Dynamic import) @@ -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. diff --git a/legacy/src/chatgpt-api.ts b/legacy/src/chatgpt-api.ts index e02c811f..39d59f29 100644 --- a/legacy/src/chatgpt-api.ts +++ b/legacy/src/chatgpt-api.ts @@ -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, diff --git a/legacy/src/fetch.ts b/legacy/src/fetch.ts index f3ea9616..cb637869 100644 --- a/legacy/src/fetch.ts +++ b/legacy/src/fetch.ts @@ -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) }