@waylaidwanderer/chatgpt-api
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -5,11 +5,7 @@ #!/usr/bin/env node | ||
import ChatGPTClient from '../src/ChatGPTClient.js'; | ||
import * as readline from 'node:readline/promises'; | ||
import { stdin as input, stdout as output } from 'node:process'; | ||
import boxen from 'boxen'; | ||
import ora from 'ora'; | ||
import terminalKit from 'terminal-kit'; | ||
import clipboard from 'clipboardy'; | ||
import inquirer from 'inquirer'; | ||
const { terminal } = terminalKit; | ||
const arg = process.argv.find((arg) => arg.startsWith('--settings')); | ||
@@ -44,6 +40,9 @@ let path; | ||
async function conversation(conversationId = null, parentMessageId = null) { | ||
terminal.bold.blue('Write a message:\n'); | ||
const rl = readline.createInterface({ input, output }); | ||
const message = (await rl.question('')).trim(); | ||
rl.close(); | ||
const { message } = await inquirer.prompt([ | ||
{ | ||
type: 'input', | ||
name: 'message', | ||
message: 'Write a message:', | ||
}, | ||
]); | ||
if (message === '!exit') { | ||
@@ -50,0 +49,0 @@ return true; |
{ | ||
"name": "@waylaidwanderer/chatgpt-api", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "A ChatGPT implementation using the official ChatGPT model via OpenAI's API.", | ||
@@ -40,7 +40,7 @@ "main": "index.js", | ||
"gpt-3-encoder": "^1.1.4", | ||
"inquirer": "^9.1.4", | ||
"keyv": "^4.5.2", | ||
"node-fetch": "^3.3.0", | ||
"ora": "^6.1.2", | ||
"terminal-kit": "^3.0.0" | ||
"ora": "^6.1.2" | ||
} | ||
} |
@@ -20,5 +20,8 @@ # ChatGPT API | ||
- Includes a `ChatGPTClient` class that you can use in your own Node.js applications. | ||
- Includes a CLI interface where you can chat with ChatGPT. | ||
- Replicates chat threads from the official ChatGPT website (with conversation IDs and message IDs), with persistent conversations using [Keyv](https://www.npmjs.com/package/keyv). | ||
- Conversations are stored in memory by default, but you can optionally [install a storage adapter](https://www.npmjs.com/package/keyv#usage) to persist conversations to a database. | ||
![cli](./demos/cli.svg) | ||
## Getting Started | ||
@@ -111,3 +114,3 @@ | ||
3. Rename `settings.example.js` to `settings.js` in the root directory and change the settings where required. | ||
4. Start the server using `npm start` or `node bin/server.js` | ||
4. Start the server using `npm start` or `npm run server` | ||
@@ -140,2 +143,15 @@ To start a conversation with ChatGPT, send a POST request to the server's `/conversation` endpoint with a JSON body in the following format: | ||
### CLI | ||
Install the package using the same instructions as the API server. | ||
If installed globally: | ||
```bash | ||
chatgpt-cli | ||
``` | ||
If installed locally: | ||
```bash | ||
npm run cli | ||
``` | ||
## Caveats | ||
@@ -142,0 +158,0 @@ Since `text-chat-davinci-002-20230126` is ChatGPT's raw model, I had to do my best to replicate the way the official ChatGPT website uses it. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
283006
15
168
+ Addedinquirer@^9.1.4
+ Added@inquirer/figures@1.0.8(transitive)
+ Addedansi-escapes@4.3.2(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedbl@4.1.0(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedchardet@0.7.0(transitive)
+ Addedcli-cursor@3.1.0(transitive)
+ Addedcli-width@4.1.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedexternal-editor@3.1.0(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinquirer@9.3.7(transitive)
+ Addedis-interactive@1.0.0(transitive)
+ Addedis-unicode-supported@0.1.0(transitive)
+ Addedlog-symbols@4.1.0(transitive)
+ Addedmute-stream@1.0.0(transitive)
+ Addedora@5.4.1(transitive)
+ Addedos-tmpdir@1.0.2(transitive)
+ Addedrestore-cursor@3.1.0(transitive)
+ Addedrun-async@3.0.0(transitive)
+ Addedrxjs@7.8.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedtmp@0.0.33(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addedtype-fest@0.21.3(transitive)
+ Addedwrap-ansi@6.2.0(transitive)
+ Addedyoctocolors-cjs@2.1.2(transitive)
- Removedterminal-kit@^3.0.0
- Removed@cronvel/get-pixels@3.4.1(transitive)
- Removedchroma-js@2.6.0(transitive)
- Removedcwise-compiler@1.1.3(transitive)
- Removediota-array@1.0.0(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedjpeg-js@0.4.4(transitive)
- Removedlazyness@1.2.0(transitive)
- Removedndarray@1.0.19(transitive)
- Removedndarray-pack@1.2.1(transitive)
- Removednextgen-events@1.5.3(transitive)
- Removednode-bitmap@0.0.1(transitive)
- Removedomggif@1.0.10(transitive)
- Removedpngjs@6.0.0(transitive)
- Removedsetimmediate@1.0.5(transitive)
- Removedseventh@0.9.2(transitive)
- Removedstring-kit@0.18.3(transitive)
- Removedterminal-kit@3.1.1(transitive)
- Removedtree-kit@0.8.7(transitive)
- Removeduniq@1.0.1(transitive)