ChatGPT clone is a fully functioning chatGPT server-side clone with basically all the chatGPT functionalities. Here, creating new conversations, saving conversations, and adding new messages to an existing conversation is made possible. Crud functionalities can be performed on both messages and conversations. A newly added message will generate an automatic response from the ChatGPT openai API and create a new conversation.
To use this API do the following steps:
- first of all, you should clone it on your local computer by using the following command:
git clone https://github.com/dembasow98/chatGPT-clone-API.git
-
Go to the openai website and generate a new API KEY.
-
Open a new mongodb cluster and create a new database with your-database-name that you're going to use on the following config.env file. Don't forget to make the other MongoDB setup such as:
- Adding new username and password.
- Network configuration.
- Copying the database NodeJS connection URL and adding it to your config.env file.
- Create a config.env file on the project's main directory and add the following lines to it:
PORT = port
DATABASE_NAME = your-database-name
MONGODB_URI = your-nodejs-connection-url(copied from mongodb)
OPENAI_API_KEY = your-openai-api-key
Replace your username and password on the nodejs connection url as follows:
mongodb+srv://your-username:[email protected]/?retryWrites=true&w=majority)
- Use the package manager pip to install(or update) all the dependencies.
npm install
npm install mongodb nodemon express dotenv openai
- Go to the package.json and add/modify the following fields:
"engines": {
"node": "14.17.6"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon index.js"
},
- Locate the directory and run the following command:
nodemon server.js
- Go to your localhost:port and add endpoints to the URL for testing purposes.
Here are same examples
- localhost:port/conversations
- localhost:port/conversations/:id/
- localhost:port/conversations/:id/messages
To test all the APIs, you can use postman or any other API platform. Everything should work perfectly.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
This project is an open-source, under the MIT license.