https://github.com/optixal/chatgpt-http-service
Simple Express server to interface with ChatGPT
https://github.com/optixal/chatgpt-http-service
Last synced: 8 months ago
JSON representation
Simple Express server to interface with ChatGPT
- Host: GitHub
- URL: https://github.com/optixal/chatgpt-http-service
- Owner: Optixal
- Created: 2023-01-02T09:15:06.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-15T19:37:09.000Z (about 3 years ago)
- Last Synced: 2025-03-02T03:59:00.704Z (over 1 year ago)
- Language: JavaScript
- Size: 168 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ChatGPT HTTP Web Service
Simple Express server to interface with ChatGPT. Uses [chatgpt-api](https://github.com/transitive-bullshit/chatgpt-api) in the background.
## Set Up
1. Install npm packages: `npm install`
2. Copy `.env.example` to `.env`
3. Enter OpenAI credentials into `.env` (please look through the main `index.js` source file first to understand how the credentials are being used)
## Running
In the background, [chatgpt-api](https://github.com/transitive-bullshit/chatgpt-api) is being used to interact with ChatGPT, which uses `puppeteer` to spawn a browser window. Meaning, a non-headless server that can display a browser window is required to run this.
1. Run with `node index.js`
2. Browser window opens, solve the reCAPTCHA
3. Done. Server is serving on `localhost:3000`. Endpoints:
* `POST /api/chat`, accepts JSON data containing message to send to ChatGPT: `{"message": "Hello world"}`. Subsequent requests are followed-up by default.
* `GET /api/reinit` to reauthenticate with OpenAI.
* `GET /api/reset` to start a new conversation.
## Issues
If `puppeteer` throws an error stating it can't find `chrome.exe` or whichever equivalent binary for your system, you might need to edit `node_modules/chatgpt/build/index.js`, around line 1060. Search for the path and point it accordingly to where your Chrome is located at.