Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@waylaidwanderer/chatgpt-api

Package Overview
Dependencies
Maintainers
1
Versions
168
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@waylaidwanderer/chatgpt-api - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

demos/cli.svg

17

bin/cli.js

@@ -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.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc