modify starting files and readme

This commit is contained in:
Daniel Avila 2023-03-06 18:17:43 -05:00
parent b9e9203a75
commit d93282640c
4 changed files with 90 additions and 41 deletions

127
README.md
View file

@ -1,6 +1,6 @@
# ChatGPT Clone #
![chatgpt-clone demo](./public/demo.gif)
## Wrap all conversational AIs under one roof. ##
![chatgpt-clone demo](./client/public/demo.gif)
## All AI Conversations under One Roof. ##
Assistant AIs are the future and OpenAI revolutionized this movement with ChatGPT. While numerous methods exist to integrate these AIs, this app commemorates the original styling of ChatGPT, with the ability to integrate any current/future AI models, while improving upon original client features, such as conversation search and prompt templates (currently WIP). This project was started early in Feb '23, anticipating the release of the official ChatGPT API from OpenAI, and now uses it along with access to the free version. Through this clone, you can avoid subscription-based models (ChatGPT Plus) in favor of free or pay-per-call APIs. I will soon deploy a demo of this app. Feel free to contribute, clone, or fork. Currently dockerized.
## Updates
@ -8,14 +8,14 @@
<summary><strong>2023-03-06</strong></summary>
Due to increased interest in the repo, I've dockerized the app as of this update for quick setup! See setup instructions below. I realize this still takes some time with installing docker dependencies, so it's on the roadmap to have a deployed demo. Besides this, I've made major improvements for a lot of the existing features across the board, mainly UI/UX.
</details>
<details>
<summary><strong>2023-03-04</strong></summary>
Custom prompt prefixing and labeling is now supported through the official API. This nets some interesting results when you need ChatGPT for specific uses or entertainment. Select 'CustomGPT' in the model menu to configure this, and you can choose to save the configuration or reference it by conversation. Model selection will change by conversation.
</details>
<details>
<summary><strong>Previous Updates</strong></summary>
<details>
<summary><strong>2023-03-04</strong></summary>
Custom prompt prefixing and labeling is now supported through the official API. This nets some interesting results when you need ChatGPT for specific uses or entertainment. Select 'CustomGPT' in the model menu to configure this, and you can choose to save the configuration or reference it by conversation. Model selection will change by conversation.
</details>
<details>
<summary><strong>2023-03-01</strong></summary>
Official ChatGPT API is out! Removed davinci since the official API is extremely fast and 10x less expensive. Since user labeling and prompt prefixing is officially supported, I will add a View feature so you can set this within chat, which gives the UI an added use case. I've kept the BrowserClient, since it's free to use like the official site.
@ -46,10 +46,13 @@ Currently, this project is only functional with the `text-davinci-003` model.
* [Getting Started](#getting-started)
* [Prerequisites](#prerequisites)
* [Usage](#usage)
<!-- * [Module](#module)
* [API Server](#api-server)
* [CLI](#cli) -->
* [Local (npm)](#npm)
* [Docker](#docker)
* [Access Tokens](#access-tokens)
* [Updating](#updating)
* [Using a Reverse Proxy](#using-a-reverse-proxy)
* [Use Cases](#use-cases)
* [Origin](#origin)
* [Caveats](#caveats)
* [Contributing](#contributing)
* [License](#license)
@ -86,60 +89,106 @@ Here are my recently completed and planned features:
- Response streaming identical to ChatGPT through server-sent events
- UI from original ChatGPT, including Dark mode
- AI model selection, including OpenAI's official ChatGPT API
- AI model selection (official ChatGPT API, BingAI, ChatGPT Free)
- Create and Save custom ChatGPTs*
^* ChatGPT can be 'customized' by setting a system prompt prefix and alternate 'role' to the API request
[More info here](https://platform.openai.com/docs/guides/chat/instructing-chat-models). Here's an [example from this app.]()
### Tech Stack
- Utilizes [node-chatgpt-api](https://github.com/waylaidwanderer/node-chatgpt-api)
- No React boilerplate/toolchain, created from scratch with react@latest
- No React boilerplate/toolchain/clone tutorials, created from scratch with react@latest
- Use of Tailwind CSS and [shadcn/ui](https://github.com/shadcn/ui) components
- Docker, useSWR, Redux, Express, MongoDB, [Keyv](https://www.npmjs.com/package/keyv)
## Getting Started
### Prerequisites
- npm
- Node.js >= 19.0.0
- MongoDB installed or [MongoDB Atlas](https://account.mongodb.com/account/login) (required if not using Docker)
- [Docker (optional)](https://www.docker.com/get-started/)
- [OpenAI API key](https://platform.openai.com/account/api-keys)
- BingAI, ChatGPT access tokens (optional, free AIs)
## Usage
- **Clone/download** the repo down where desired
```bash
git clone https://github.com/danny-avila/chatgpt-clone.git
```
- If using MongoDB Atlas, remove `&w=majority` from default connection string.
### Local
- **Run npm** install in both the api and client directories
- **Provide** all credentials, (API keys, access tokens, and Mongo Connection String) in api/.env [(see .env example)](api/.env.example)
- **Run** `npm run build` in /client/ dir, `npm start` in /api/ dir
- **Visit** http://localhost:3080 (default port) & enjoy
### Docker
- **Provide** all credentials, (API keys, access tokens, and Mongo Connection String) in [docker-compose.yml](docker-compose.yml) under api service
- **Build images** in both /api/ and /client/ directories (will eventually share through docker hub)
- `api/`
```bash
docker build -t node-api .
```
- `client/`
```bash
docker build -t react-client .
```
- **Run** `docker-compose build` in project root dir and then `docker-compose up` to start the app
### Access Tokens
<details>
<summary><strong>ChatGPT Free Instructions</strong></summary>
To get your Access token For ChatGPT 'Free Version', login to chat.openai.com, then visit https://chat.openai.com/api/auth/session.
Warning: There may be a high chance of your account being banned with this method. Continue doing so at your own risk.
</details>
<details>
<summary><strong>BingAI Instructions</strong></summary>
Note: Specific Styling for this model is still in progress.
</details>
### Updating
- As the project is still a work-in-progress, you should pull the latest and run some of the steps above again
## Use Cases ##
- One stop shop for all conversational AIs, with the added bonus of searching past conversations.
- Using the official API, you'd have to generate 7.5 million words to expense the same cost as ChatGPT Plus ($20).
- ChatGPT/Google Bard/Bing AI conversations are lost in space or
cannot be searched past a certain timeframe.
- ChatGPT Free (at [chat.openai.com](https://chat.openai.com/chat)) is more limited than the API
- Customize ChatGPT
![use case example](./public/use_case2.png "chat.openai.com is getting more limited by the day!")
![use case example](./client/public/use_case3.png "Make a Custom GPT")
- API is not as limited as ChatGPT Free (at [chat.openai.com](https://chat.openai.com/chat))
![use case example](./client/public/use_case2.png "chat.openai.com is getting more limited by the day!")
- ChatGPT Free is down.
![use case example](./public/use_case.png "GPT is down! Plus is too expensive!")
![use case example](./client/public/use_case.png "GPT is down! Plus is too expensive!")
## Origin ##
This project was originally created as a Minimum Viable Product (or MVP) for the [@HackReactor](https://github.com/hackreactor/) Bootcamp. It was built with OpenAI response streaming and most of the UI completed in under 20 hours. During the end of that time, I had most of the UI and basic functionality done. This was created without using any boilerplates or templates, including create-react-app and other toolchains. I didn't follow any 'un-official chatgpt' video tutorials, and simply referenced the official site for the UI. The purpose of the exercise was to learn setting up a full stack project from scratch. Please feel free to give feedback, suggestions, or fork the project for your own use.
<!-- ## Solution ##
Serves and searches all conversations reliably. All AI convos under one house.
Pay per call and not per month (cents compared to dollars). -->
## Getting Started
### Prerequisites
- Node.js >= 19.0.0
- npm
- [Docker (optional)](https://www.docker.com/get-started/)
- [OpenAI API key](https://platform.openai.com/account/api-keys)
- BingAI, ChatGPT access tokens (optional, free AIs)
## Usage
<details open>
<summary><strong>BingAI Instructions</strong></summary>
<details open>
<summary><strong>ChatGPT Free Instructions</strong></summary>
See [`demos/use-browser-client.js`](demos/use-browser-client.js).
</details>
## Caveats
### Regarding `ChatGPTClient`
From @waylaidwanderer's use of the official API: Since `gpt-3.5-turbo` is ChatGPT's underlying model, I had to do my best to replicate the way the official ChatGPT website uses it.
### Regarding use of Official ChatGPT API
From [@waylaidwanderer](https://github.com/waylaidwanderer/node-chatgpt-api/blob/main/README.md#caveats):
Since `gpt-3.5-turbo` is ChatGPT's underlying model, I had to do my best to replicate the way the official ChatGPT website uses it.
This means my implementation or the underlying model may not behave exactly the same in some ways:
- Conversations are not tied to any user IDs, so if that's important to you, you should implement your own user ID system.
- ChatGPT's model parameters (temperature, frequency penalty, etc.) are unknown, so I set some defaults that I thought would be reasonable.

View file

@ -4,7 +4,7 @@
"description": "",
"main": "server/index.js",
"scripts": {
"start": "npx node server/index.js",
"start": "node server/index.js",
"server-dev": "npx nodemon server/index.js"
},
"repository": {

View file

@ -4,7 +4,7 @@ const path = require('path');
const cors = require('cors');
const routes = require('./routes');
const app = express();
const port = process.env.PORT || 3050;
const port = process.env.PORT || 3080;
const projectPath = path.join(__dirname, '..', '..', 'client');
dbConnect().then(() => console.log('Connected to MongoDB'));

BIN
client/public/use_case3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB