Skip to content

dembasowfr/chatGPT-clone-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CHATGPT CLONE

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.

Installation

To use this API do the following steps:

  1. 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
  1. Go to the openai website and generate a new API KEY.

  2. 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.
  1. 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:your-password@cluster0.lm9patn.mongodb.net/?retryWrites=true&w=majority)
  1. Use the package manager pip to install(or update) all the dependencies.
npm install
npm install mongodb nodemon express dotenv openai

Usage

  1. 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"
  },
  1. Locate the directory and run the following command:
nodemon server.js
  1. 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.

Contributing

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.

License

This project is an open-source, under the MIT license.

Owner