├── chatgpt-image.jpeg ├── chatgpt-service.gif ├── public ├── favicon.ico ├── index.html └── favicon.svg ├── src ├── assets │ ├── error.png │ ├── logo.png │ ├── chatgpt.png │ ├── developer.png │ └── logo.svg ├── plugins │ └── vuetify.js ├── main.js └── App.vue ├── vue.config.js ├── babel.config.js ├── .env.production ├── .env.development ├── docker-files ├── Dockerfile ├── README.md └── nginx.conf ├── .gitignore ├── docker-compose.yaml ├── LICENSE ├── config.yaml ├── package.json ├── README_CN.md └── README.md /chatgpt-image.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cookeem/chatgpt-stream/HEAD/chatgpt-image.jpeg -------------------------------------------------------------------------------- /chatgpt-service.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cookeem/chatgpt-stream/HEAD/chatgpt-service.gif -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cookeem/chatgpt-stream/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /src/assets/error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cookeem/chatgpt-stream/HEAD/src/assets/error.png -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cookeem/chatgpt-stream/HEAD/src/assets/logo.png -------------------------------------------------------------------------------- /src/assets/chatgpt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cookeem/chatgpt-stream/HEAD/src/assets/chatgpt.png -------------------------------------------------------------------------------- /vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | transpileDependencies: [ 3 | 'vuetify' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /src/assets/developer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cookeem/chatgpt-stream/HEAD/src/assets/developer.png -------------------------------------------------------------------------------- /.env.production: -------------------------------------------------------------------------------- 1 | # 访问的chatgpt-stream的地址 2 | VUE_APP_BASE_HTTP = '' 3 | # 访问的chatgpt-service的地址 4 | VUE_APP_BASE_WS = '' 5 | -------------------------------------------------------------------------------- /.env.development: -------------------------------------------------------------------------------- 1 | # 访问的chatgpt-stream的地址 2 | VUE_APP_BASE_HTTP = 'http://localhost:9000' 3 | # 访问的chatgpt-service的地址 4 | VUE_APP_BASE_WS = 'ws://localhost:9000' 5 | -------------------------------------------------------------------------------- /src/plugins/vuetify.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Vuetify from 'vuetify/lib/framework'; 3 | 4 | Vue.use(Vuetify); 5 | 6 | export default new Vuetify({ 7 | }); 8 | -------------------------------------------------------------------------------- /docker-files/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:1.22.0-alpine 2 | 3 | LABEL maintainer="cookeem" 4 | LABEL email="cookeem@qq.com" 5 | LABEL version="v1.0.3" 6 | 7 | COPY nginx.conf /etc/nginx/nginx.conf 8 | COPY dist /chatgpt-stream 9 | -------------------------------------------------------------------------------- /docker-files/README.md: -------------------------------------------------------------------------------- 1 | # 制作dory-frontend镜像 2 | 3 | ```bash 4 | rm -rf dist 5 | npm install && npm run build 6 | rm -rf docker-files/dist && mv dist docker-files && cd docker-files 7 | docker build -t doryengine/chatgpt-stream:v1.0.3 . 8 | docker push doryengine/chatgpt-stream:v1.0.3 9 | cd .. 10 | ``` 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /src/assets/logo.svg: -------------------------------------------------------------------------------- 1 | Artboard 46 2 | -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | chatgpt-stream: 4 | image: "doryengine/chatgpt-stream:v1.0.3" 5 | hostname: chatgpt-stream 6 | container_name: chatgpt-stream 7 | ports: 8 | - "3000:80" 9 | # - "443:443" 10 | depends_on: 11 | - chatgpt-service 12 | restart: always 13 | chatgpt-service: 14 | image: "doryengine/chatgpt-service:v1.0.3-alpine" 15 | hostname: chatgpt-service 16 | container_name: chatgpt-service 17 | ports: 18 | - "9000:9000" 19 | volumes: 20 | - ./config.yaml:/chatgpt-service/config.yaml 21 | - ./assets:/chatgpt-service/assets 22 | command: /chatgpt-service/chatgpt-service 23 | restart: always 24 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | import vuetify from './plugins/vuetify' 4 | 5 | Vue.config.productionTip = false 6 | 7 | if (process.env.VUE_APP_BASE_WS.indexOf('ws') === 0 || process.env.VUE_APP_BASE_WS.indexOf('wss') === 0) { 8 | Vue.prototype.BASE_WS = process.env.VUE_APP_BASE_WS 9 | } else { 10 | var baseUrl = window.location.origin 11 | if (baseUrl.indexOf('https') === 0) { 12 | Vue.prototype.BASE_WS = baseUrl.replace('https', 'wss') + process.env.VUE_APP_BASE_WS 13 | } else if (baseUrl.indexOf('http') === 0) { 14 | Vue.prototype.BASE_WS = baseUrl.replace('http', 'ws') + process.env.VUE_APP_BASE_WS 15 | } 16 | } 17 | 18 | new Vue({ 19 | vuetify, 20 | render: h => h(App) 21 | }).$mount('#app') 22 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ChatGPT Stream 9 | 10 | 11 | 12 | 13 | 16 |
17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /public/favicon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 SeeFlowerX 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /config.yaml: -------------------------------------------------------------------------------- 1 | # Your openai.com API key 2 | # openai的API Key 3 | apiKey: "xxxxxx" 4 | # Service port 5 | # 服务端口 6 | port: 9000 7 | # The time interval for sending questions cannot be less than how long, unit: second 8 | # 问题发送的时间间隔不能小于多长时间,单位:秒 9 | intervalSeconds: 5 10 | # GPT model, if you use the GPT4 model, please ensure that the corresponding openai account has the permission to use the GPT4 model 11 | # Available models include: gpt-4-32k-0314, gpt-4-32k, gpt-4-0314, gpt-4, gpt-3.5-turbo-0301, gpt-3.5-turbo, text-davinci-003, text-davinci-002, text-curie-001, text-babbage-001, text-ada-001, text-davinci-001, davinci-instruct-beta, davinci, curie-instruct-beta, curie, ada, babbage 12 | # GPT模型,如果使用GPT4模型,请保证对应的openai账号有GPT4模型的使用权限 13 | # 可用的模型包括: gpt-4-32k-0314, gpt-4-32k, gpt-4-0314, gpt-4, gpt-3.5-turbo-0301, gpt-3.5-turbo, text-davinci-003, text-davinci-002, text-curie-001, text-babbage-001, text-ada-001, text-davinci-001, davinci-instruct-beta, davinci, curie-instruct-beta, curie, ada, babbage 14 | model: gpt-3.5-turbo-0301 15 | # The maximum length of the returned answer 16 | # 返回答案的最大长度 17 | maxLength: 2000 18 | # Whether to allow cors cross-domain 19 | # 是否允许cors跨域 20 | cors: true 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chatgpt-stream", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "core-js": "^3.6.5", 12 | "vue": "^2.6.11", 13 | "vuetify": "^2.6.0" 14 | }, 15 | "devDependencies": { 16 | "@vue/cli-plugin-babel": "~4.5.4", 17 | "@vue/cli-plugin-eslint": "~4.5.4", 18 | "@vue/cli-service": "~4.5.4", 19 | "babel-eslint": "^10.1.0", 20 | "eslint": "^6.7.2", 21 | "eslint-plugin-vue": "^6.2.2", 22 | "sass": "~1.32.0", 23 | "sass-loader": "^10.0.0", 24 | "vue-cli-plugin-vuetify": "~2.5.8", 25 | "vue-template-compiler": "^2.6.11", 26 | "vuetify-loader": "^1.7.0" 27 | }, 28 | "eslintConfig": { 29 | "root": true, 30 | "env": { 31 | "node": true 32 | }, 33 | "extends": [ 34 | "plugin:vue/essential", 35 | "eslint:recommended" 36 | ], 37 | "parserOptions": { 38 | "parser": "babel-eslint" 39 | }, 40 | "rules": {} 41 | }, 42 | "browserslist": [ 43 | "> 1%", 44 | "last 2 versions", 45 | "not dead" 46 | ] 47 | } 48 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | # 实时ChatGPT服务,支持GPT3/GPT4,支持对话和通过句子生成图片 2 | 3 | - [English README](README.md) 4 | - [中文 README](README_CN.md) 5 | 6 | ## chatGPT-service和chatGPT-stream 7 | 8 | - chatGPT-service: [https://github.com/cookeem/chatgpt-service](https://github.com/cookeem/chatgpt-service) 9 | - chatGPT-service是一个后端服务,用于实时接收chatGPT的消息,并通过websocket的方式实时反馈给chatGPT-stream 10 | - chatGPT-stream: [https://github.com/cookeem/chatgpt-stream](https://github.com/cookeem/chatgpt-stream) 11 | - chatGPT-stream是一个前端服务,以websocket的方式实时接收chatGPT-service返回的消息 12 | 13 | ## gitee传送门 14 | 15 | - [https://gitee.com/cookeem/chatgpt-service](https://gitee.com/cookeem/chatgpt-service) 16 | - [https://gitee.com/cookeem/chatgpt-stream](https://gitee.com/cookeem/chatgpt-stream) 17 | 18 | ## 效果图 19 | 20 | - 实时对话模式 21 | 22 | ![](chatgpt-service.gif) 23 | 24 | - 通过句子生成图片模式 25 | 26 | ![](chatgpt-image.jpeg) 27 | 28 | ## 快速开始 29 | 30 | ```bash 31 | # 拉取代码 32 | git clone https://github.com/cookeem/chatgpt-stream.git 33 | cd chatgpt-stream 34 | 35 | # chatGPT的注册页面: https://beta.openai.com/signup 36 | # chatGPT的注册教程: https://www.cnblogs.com/damugua/p/16969508.html 37 | # chatGPT的APIkey管理界面: https://beta.openai.com/account/api-keys 38 | 39 | # 修改config.yaml配置文件,修改apiKey,改为你的openai.com的apiKey 40 | vi config.yaml 41 | # openai的apiKey,改为你的apiKey 42 | apiKey: "xxxxxx" 43 | 44 | # 创建生成的图片目录 45 | mkdir -p assets 46 | chown -R 1000:1000 assets 47 | 48 | # 使用docker-compose启动服务 49 | docker-compose up -d 50 | 51 | # 查看服务状态 52 | docker-compose ps 53 | Name Command State Ports 54 | ----------------------------------------------------------------------------------------------- 55 | chatgpt-service /chatgpt-service/chatgpt-s ... Up 0.0.0.0:59142->9000/tcp 56 | chatgpt-stream /docker-entrypoint.sh ngin ... Up 0.0.0.0:3000->80/tcp,:::3000->80/tcp 57 | 58 | 59 | # 访问页面,请保证你的服务器可以访问chatGPT的api接口 60 | # http://localhost:3000 61 | ``` 62 | 63 | - 直接输入问题,则调用ChatGPT接口返回答案 64 | - `/image `后边输入想要的图片描述,则调用DALL-E2接口,通过图片描述自动生成图片 65 | 66 | ## 如何编译 67 | 68 | ```bash 69 | # 注意本项目需要先运行chatgpt-service后端服务 70 | # .env.development为运行测试的配置文件 71 | # .env.production为正式构建的配置文件 72 | 73 | # 拉取构建依赖 74 | npm install 75 | # 运行测试 76 | npm run serve 77 | # 执行编译 78 | npm run build 79 | 80 | # 假如出现 ERR_OSSL_EVP_UNSUPPORTED 错误,请使用以下命令进行编译 81 | export NODE_OPTIONS=--openssl-legacy-provider && npm run build 82 | ``` -------------------------------------------------------------------------------- /docker-files/nginx.conf: -------------------------------------------------------------------------------- 1 | 2 | user nginx; 3 | worker_processes auto; 4 | 5 | error_log /var/log/nginx/error.log notice; 6 | pid /var/run/nginx.pid; 7 | 8 | 9 | events { 10 | worker_connections 1024; 11 | } 12 | 13 | 14 | http { 15 | include /etc/nginx/mime.types; 16 | default_type application/octet-stream; 17 | client_max_body_size 20M; 18 | 19 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 20 | '$status $body_bytes_sent "$http_referer" ' 21 | '"$http_user_agent" "$http_x_forwarded_for"'; 22 | 23 | access_log /var/log/nginx/access.log main; 24 | 25 | sendfile on; 26 | #tcp_nopush on; 27 | 28 | keepalive_timeout 65; 29 | 30 | #gzip on; 31 | 32 | server { 33 | listen 80; 34 | server_name localhost; 35 | 36 | root /chatgpt-stream; 37 | index index.html index.htm; 38 | #access_log /var/log/nginx/host.access.log main; 39 | 40 | 41 | location /api/ { 42 | proxy_set_header X-Real-IP $remote_addr; 43 | proxy_set_header X-Forwarded-For $remote_addr; 44 | proxy_set_header Host $host; 45 | proxy_http_version 1.1; 46 | proxy_set_header Upgrade $http_upgrade; 47 | proxy_set_header Connection "Upgrade"; 48 | proxy_pass http://chatgpt-service:9000; 49 | max_ranges 0; 50 | } 51 | 52 | #error_page 404 /404.html; 53 | 54 | # redirect server error pages to the static page /50x.html 55 | # 56 | error_page 500 502 503 504 /50x.html; 57 | location = /50x.html { 58 | root /usr/share/nginx/html; 59 | } 60 | 61 | # proxy the PHP scripts to Apache listening on 127.0.0.1:80 62 | # 63 | #location ~ \.php$ { 64 | # proxy_pass http://127.0.0.1; 65 | #} 66 | 67 | # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 68 | # 69 | #location ~ \.php$ { 70 | # root html; 71 | # fastcgi_pass 127.0.0.1:9000; 72 | # fastcgi_index index.php; 73 | # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 74 | # include fastcgi_params; 75 | #} 76 | 77 | # deny access to .htaccess files, if Apache's document root 78 | # concurs with nginx's one 79 | # 80 | #location ~ /\.ht { 81 | # deny all; 82 | #} 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Real-time ChatGPT service, support GPT3/GPT4, support conversation and generate pictures from sentences 2 | 3 | - [English README](README.md) 4 | - [中文 README](README_CN.md) 5 | 6 | ## About chatgpt-service and chatgpt-stream 7 | 8 | - chatgpt-service: [https://github.com/cookeem/chatgpt-service](https://github.com/cookeem/chatgpt-service) 9 | - chatgpt-service is a backend service, used to receive chatGPT messages in real time, and feed back to chatGPT-stream in real time through websocket 10 | - chatgpt-stream: [https://github.com/cookeem/chatgpt-stream](https://github.com/cookeem/chatgpt-stream) 11 | - chatgpt-stream is a front-end service that receives messages returned by chatGPT-service in real time through websocket 12 | 13 | ## gitee 14 | 15 | - [https://gitee.com/cookeem/chatgpt-service](https://gitee.com/cookeem/chatgpt-service) 16 | - [https://gitee.com/cookeem/chatgpt-stream](https://gitee.com/cookeem/chatgpt-stream) 17 | 18 | ## Demo 19 | 20 | - Real-time conversation mode 21 | 22 | ![](chatgpt-service.gif) 23 | 24 | - Generate picture patterns from sentences 25 | 26 | ![](chatgpt-image.jpeg) 27 | 28 | ## Quick start 29 | 30 | ```bash 31 | # Pull source code 32 | git clone https://github.com/cookeem/chatgpt-service.git 33 | cd chatgpt-service 34 | 35 | # ChatGPT's registration page: https://beta.openai.com/signup 36 | # ChatGPT registration tutorial: https://www.cnblogs.com/damugua/p/16969508.html 37 | # ChatGPT API key management page: https://beta.openai.com/account/api-keys 38 | 39 | # Modify the config.yaml configuration file, modify the apiKey, and change it to your openai.com API key 40 | vi config.yaml 41 | # your openai.com API key 42 | apiKey: "xxxxxx" 43 | 44 | # create pictures directory 45 | mkdir -p assets 46 | chown -R 1000:1000 assets 47 | 48 | # Start the service with docker-compose 49 | docker-compose up -d 50 | 51 | # Check service status 52 | docker-compose ps 53 | Name Command State Ports 54 | ----------------------------------------------------------------------------------------------- 55 | chatgpt-service /chatgpt-service/chatgpt-s ... Up 0.0.0.0:59142->9000/tcp 56 | chatgpt-stream /docker-entrypoint.sh ngin ... Up 0.0.0.0:3000->80/tcp,:::3000->80/tcp 57 | 58 | 59 | # To access the page, please ensure that your server can access the chatGPT API 60 | # http://localhost:3000 61 | ``` 62 | 63 | - Enter the question directly, it will call the ChatGPT interface to return the answer 64 | - Enter the picture description after `/image`, it will call the DALL-E2 interface to automatically generate pictures through the picture description 65 | 66 | ## How to build 67 | 68 | ```bash 69 | # Note that this project needs to run the chatgpt-service backend service first 70 | # .env.development is the configuration file for running tests 71 | # .env.production is the formally built configuration file 72 | 73 | # Pull build dependencies 74 | npm install 75 | # Test the project 76 | npm run serve 77 | # Compile the project 78 | npm run build 79 | 80 | # If ERR_OSSL_EVP_UNSUPPORTED error occurs, please use the following command to compile 81 | export NODE_OPTIONS=--openssl-legacy-provider && npm run build 82 | ``` -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 86 | 87 | --------------------------------------------------------------------------------