Skip to content

Commit

Permalink
Update README, fix typos and address vulnerabilities. (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
blrchen authored Sep 1, 2023
1 parent e3066ea commit 8c21d8d
Show file tree
Hide file tree
Showing 13 changed files with 1,215 additions and 1,140 deletions.
9 changes: 4 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git
.next
Dockerfile
README.md
node_modules
11 changes: 11 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Duplicate this to .env.local for local development
# For more details, visit the following link: https://github.com/blrchen/chatgpt-minimal#environment-variables

# OpenAI API credentials. These are necessary if you intend to utilize the OpenAI API.
OPENAI_API_KEY=
OPENAI_API_BASE_URL="https://api.openai.com"

# Azure OpenAI API credentials. These are necessary if you intend to utilize the Azure OpenAI API.
# AZURE_OPENAI_API_BASE_URL=
# AZURE_OPENAI_API_KEY=
# AZURE_OPENAI_DEPLOYMENT=
40 changes: 40 additions & 0 deletions .github/workflows/docker.chatgpt-minimal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish blrchen/chatgpt-minimal

on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'chatgpt-minimal/**'

jobs:
build_and_push_image:
name: Push image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: blrchen/chatgpt-minimal
- name: Build and push multi-arch image
uses: docker/build-push-action@v4
with:
context: ./chatgpt-minimal
file: chatgpt-minimal/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.next
node_modules
.next
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "website",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "dev"],
"autoAttachChildProcesses": true,
"stopOnEntry": true,
"skipFiles": ["<node_internals>/**"]
}
]
}
85 changes: 58 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

English | [简体中文](./README.zh-CN.md)

## Demo

Visit [ChatGPT Minimal Demo Site](https://chatgpt-minimal.vercel.app)

## Features

ChatGPT Minimal is a lightweight chatbot built using Next.js and the OpenAI Streaming API for the GPT-3.5 model. It supports both OpenAI and Azure OpenAI accounts.

Components:
Expand All @@ -10,55 +16,80 @@ Components:
- API Routes
- Chatbot UI with React and Ant Design

For a full-featured ChatGPT UI, visit [GPT Lite](https://github.com/blrchen/gptlite).

[Live Demo](https://gptlite-minimal.vercel.app)
![demo](./docs/images/demo.jpg)

For a full-featured ChatGPT UI, visit [ChatGPT Lite](https://github.com/blrchen/chatgpt-lite).

## Prerequisites

You need either an OpenAI account or an Azure OpenAI account.
You need an OpenAI or Azure OpenAI account.

## Deployment

Refer to the [Environment Variables](#environment-variables) section for required environment variables.

### Deploy on Vercel

Click the button below to deploy on Vercel:
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fblrchen%2Fchatgpt-minimal&project-name=chatgpt-minimal&framework=nextjs&repository-name=chatgpt-minimal)

## Running Locally
### Deploy with Docker

For OpenAI account users:

```
docker run -d -p 3000:3000 \
-e OPENAI_API_KEY="<REPLACE-ME>" \
blrchen/chatgpt-minimal
```

For Azure OpenAI account users:

```
docker run -d -p 3000:3000 \
-e AZURE_OPENAI_API_BASE_URL="<REPLACE-ME>" \
-e AZURE_OPENAI_API_KEY="<REPLACE-ME>" \
-e AZURE_OPENAI_DEPLOYMENT="<REPLACE-ME>" \
blrchen/chatgpt-minimal
```

## Development

### Running Locally

1. Install NodeJS 18.
2. Clone the repository.
3. Install dependencies with `npm install`.
4. Set the `OPENAI_API_KEY` environment variable.
4. Copy `.env.example` to `.env.local` and modify environment variables accordingly.
5. Start the application using `npm run dev`.
6. Visit `http://localhost:3000` in your browser.

## Run with Docker
### Running Locally with Docker

1. Clone the repository and navigate to the root directory.
2. Update the `OPENAI_API_KEY` environment variable in the `docker-compose.yml` file.
3. Build the application using `docker-compose build .`.
4. Start it by running `docker-compose up -d`.

## One-click Deploy on Vercel

Click the button below to deploy to Vercel:
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fblrchen%2Fgptlite-minimal&project-name=gptlite-minimal&framework=nextjs&repository-name=gptlite-minimal)
4. Start the application by running `docker-compose up -d`.

## Environment Variables

For OpenAI-specific environments:
Required environment variables:

For OpenAI account:

| Name | Description | Default Value |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
| OPENAI_API_BASE_URL | Use only if you intend to use a reserved proxy for `api.openai.com`. | `https://api.openai.com` |
| OPENAI_API_KEY | Obtain secret key string from the [Open AI API website](https://platform.openai.com/account/api-keys). |
| Name | Description | Default Value |
|---------------------|---------------------------------------------------------------------------------------------------------|--------------------------|
| OPENAI_API_BASE_URL | Use if you intend to use a reverse proxy for `api.openai.com`. | `https://api.openai.com` |
| OPENAI_API_KEY | Secret key string obtained from the [OpenAI API website](https://platform.openai.com/account/api-keys). |

For Azure Open AI-specific environments:
For Azure OpenAI account:

| Name | Description |
|----------------------------|------------------------------------------------|
| AZURE_OPENAI_API_BASE_URL | Endpoint (e.g., https://xxx.openai.azure.com). |
| AZURE_OPENAI_API_KEY | Key |
| AZURE_OPENAI_DEPLOYMENT | Model deployment name |
| Name | Description |
|---------------------------|------------------------------------------------|
| AZURE_OPENAI_API_BASE_URL | Endpoint (e.g., https://xxx.openai.azure.com). |
| AZURE_OPENAI_API_KEY | Key |
| AZURE_OPENAI_DEPLOYMENT | Model deployment name |

## Contribution
We welcome PRs of any size.

## Disclaimers
This code is intended solely for demonstration and testing purposes.
We welcome PRs of all sizes.
101 changes: 65 additions & 36 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,94 @@

[English](./README.md) | 简体中文

ChatGPT Minimal 是一个使用 Next.js 和 OpenAI Streaming API 为 GPT-3.5 模型创建的简易聊天机器人。它同时支持 OpenAI 和 Azure OpenAI 帐户。
## 演示

访问 [ChatGPT Minimal 演示网站](https://chatgpt-minimal.vercel.app)

## 功能

ChatGPT Minimal 是一个简单的聊天机器人,使用 Next.js 和 OpenAI Streaming API 为 GPT-3.5 模型创建。它支持 OpenAI 和 Azure OpenAI 帐户。

组件:
- Next.js v13
- OpenAI Streaming API(GPT-3.5 模型,gpt-3.5-turbo)
- API 路由
- 基于 React 和 Ant Design 的聊天机器人用户界面

如需访问具有完整功能的 ChatGPT UI,请前往 [GPT Lite](https://github.com/blrchen/gptlite)

[在线演示](https://gptlite-minimal.vercel.app)
![演示](./docs/images/demo.jpg)

如需完整功能的 ChatGPT UI,请访问 [ChatGPT Lite](https://github.com/blrchen/chatgpt-lite)

## 前提条件

需要一个 OpenAI 账户或 Azure OpenAI 账户
需要OpenAI账户或Azure OpenAI账户

## 本地运行
## 部署

1. 安装 NodeJS 18。
2. 克隆仓库。
3. 使用 `npm install` 安装依赖。
4. 设置 `OPENAI_API_KEY` 环境变量。
5. 使用 `npm run dev` 启动应用。
6. 在浏览器中访问 `http://localhost:3000`
参考[环境变量](#环境变量)了解所需环境变量。

## 使用 Docker 运行
### 在Vercel上部署

1. 克隆仓库并进入根目录。
2. 更新 `docker-compose.yml` 文件中的 `OPENAI_API_KEY` 环境变量。
3. 使用 `docker-compose build .` 构建应用。
4. 运行 `docker-compose up -d` 启动。
点击下方按钮部署到Vercel:
[![使用 Vercel 部署](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fblrchen%2Fchatgpt-minimal&project-name=chatgpt-minimal&framework=nextjs&repository-name=chatgpt-minimal)

## 在 Vercel 上一键部署
### 使用Docker部署

点击下面的按钮一键部署到 Vercel:
[![使用 Vercel 部署](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fblrchen%2Fgptlite-minimal&project-name=gptlite-minimal&framework=nextjs&repository-name=gptlite-minimal)
OpenAI账户用户:

## 环境变量
```
docker run -d -p 3000:3000 \
-e OPENAI_API_KEY="<REPLACE-ME>" \
blrchen/chatgpt-minimal
```

OpenAI 相关环境变量
Azure OpenAI账户用户

| 名称 | 描述 | 默认值 |
|---------------------|-------------------------------------------------------------------------------------------------------|------------------------|
| OPENAI_API_BASE_URL | 仅在打算为 `api.openai.com` 使用反向代理时使用。 | `https://api.openai.com` |
| OPENAI_API_KEY |[OpenAI API 网站](https://platform.openai.com/account/api-keys) 获取密钥字符串。 |
```
docker run -d -p 3000:3000 \
-e AZURE_OPENAI_API_BASE_URL="<REPLACE-ME>" \
-e AZURE_OPENAI_API_KEY="<REPLACE-ME>" \
-e AZURE_OPENAI_DEPLOYMENT="<REPLACE-ME>" \
blrchen/chatgpt-minimal
```

Azure Open AI 相关环境变量:
## 开发

| 名称 | 描述 |
|----------------------------|----------------------------------------------|
| AZURE_OPENAI_API_BASE_URL | 端点(如,https://xxx.openai.azure.com)。 |
| AZURE_OPENAI_API_KEY | 密钥 |
| AZURE_OPENAI_DEPLOYMENT | 模型部署名称 |
### 本地运行

## 贡献
1. 安装NodeJS 18。
2. 克隆仓库。
3. 使用`npm install`安装依赖。
4. 复制`.env.example`文件为`.env.local`并更新环境变量。
5. 使用`npm run dev`启动应用。
6. 在浏览器中访问`http://localhost:3000`

欢迎提交各种大小的 PR。
### 使用Docker本地运行

## 免责声明
1. 克隆仓库并导航至根目录。
2.`docker-compose.yml`文件中更新`OPENAI_API_KEY`环境变量。
3. 使用`docker-compose build .`构建应用。
4. 运行`docker-compose up -d`启动。

## 环境变量

运行应用所需的环境变量:

OpenAI账户环境变量:

| 名称 | 描述 | 默认值 |
|---------------------|------------------------------------------------------------------------|--------------------------|
| OPENAI_API_BASE_URL | 如需为`api.openai.com`使用反向代理,请使用此变量。 | `https://api.openai.com` |
| OPENAI_API_KEY |[OpenAI API网站](https://platform.openai.com/account/api-keys)获取的密钥字符串。 |

Azure OpenAI账户环境变量:

| 名称 | 描述 |
|---------------------------|-------------------------------------|
| AZURE_OPENAI_API_BASE_URL | 端点(如,https://xxx.openai.azure.com)。 |
| AZURE_OPENAI_API_KEY | 密钥 |
| AZURE_OPENAI_DEPLOYMENT | 模型部署名称 |

## 贡献

此代码仅用于演示和测试目的
欢迎提交各种大小的PR
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.8'

services:
gptlite:
chatgpt-minimal:
build: .
ports:
- "3000:3000"
Expand Down
Loading

1 comment on commit 8c21d8d

@vercel
Copy link

@vercel vercel bot commented on 8c21d8d Sep 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

chatgpt-minimal – ./

chatgpt-minimal-git-main-blrchen.vercel.app
chatgpt-minimal-blrchen.vercel.app
chatgpt-minimal.vercel.app

Please sign in to comment.