AI private deployment (nanny-level tutorial)

Table of contents

Preface

Material preparation

Environmental preparation

Install git tools

 Clone gpt application

Prepare deployment environment

Set up startup script and configure environment variables


Preface

        I updated again after four months. The last article was published more casually and many steps were not described in detail. This time we will deploy our privatized chatgpt platform based on the open source chatgpt third-party project on github. The steps should be as detailed as possible.

Material preparation

        The server can be built on a public network server. If there is an intranet server, it can also be deployed on the intranet to provide intranet user access.

Linux system Configuration details
Centos7 2h4h
apikey of Chatgpt account key acquisition

Each chatgpt account has a free $5 limit. If it is for private use, it can be used for a few months. If it is plus, you can also use the key of the plus account.


Environmental preparation

Install git tools

[root@yyt ~]# yum install -y git

[root@yyt ~]# git version
git version 1.8.3.1

 Clone gpt application

There are already many Chatgpts on github or gitee. I use ChatGPT-Next-Web here , or you can go to github to find other gpt applications.

[root@yyt ~]# git clone https://github.com/Yidadaa/ChatGPT-Next-Web.git
Cloning into 'ChatGPT-Next-Web'...
remote: Enumerating objects: 7145, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 7145 (delta 0), reused 3 (delta 0), pack-reused 7140
Receiving objects: 100% (7145/7145), 7.25 MiB | 5.58 MiB/s, done.
Resolving deltas: 100% (4650/4650), done.

 If you encounter unable to access 'https://github.com/Yidadaa/ChatGPT-Next-Web.git/': Encountered end of file, you can download the package to your computer and then use lrzsz to transfer the command

Prepare deployment environment

        Here I am going to use local deployment and add yarn and nodejs dependencies to deploy the application. If you just want to simply deploy gpt, you can use docker deployment and pull the image for deployment with one click. docker deployment  note: docker version must be greater than 20

        If you want to carry out secondary development, you can deploy the application locally

Install nodejs. Nodejs requires 18 or above. You can use snap to install nodejs18.

[root@yyt ~]# yum install snapd -y

[root@yyt ~]# systemctl enable --now snapd.socket  

[root@yyt ~]# ln -s /var/lib/snapd/snap /snap 

[root@yyt ~]# snap install node --classic --channel=18

#This means the installation is complete. Reconnect to the terminal and enter node -v to view
node (18/stable) 18.17.1 from OpenJS Foundation (iojs✓) installed

[root@yyt ~]# npm -v
9.6.7

Install yarn

[root@yyt ~]# npm install yarn

added 1 package in 5s

[root@yyt ~]# yarn -v
1.22.19

 At this point, the operating environment is ready

Set up startup script and configure environment variables

        There is a .env.template file in the project, in which the environment can be modified.

[root@yyt ChatGPT-Next-Web]# cat  .env.template |grep -v "#"

OPENAI_API_KEY=sk-xxxx

CODE=your-password

PROXY_URL=http://localhost:7890

BASE_URL=api.openai-proxy.com

OPENAI_ORG_ID=

HIDE_USER_API_KEY=

DISABLE_GPT4=

HIDE_BALANCE_QUERY=

After modification, name the file .env.local

OPENAI_API_KEY (必填项)
OpanAI 密钥,你在 openai 账户页面申请的 api key。

CODE (可选)
访问密码,可选,可以使用逗号隔开多个密码。

警告:如果不填写此项,则任何人都可以直接使用你部署后的网站,可能会导致你的 token 被急速消耗完毕,建议填写此选项。

BASE_URL (可选)
Default: https://api.openai.com

Examples: http://your-openai-proxy.com

OpenAI 接口代理 URL,如果你手动配置了 openai 接口代理,请填写此选项。

如果遇到 ssl 证书问题,请将 BASE_URL 的协议设置为 http。

OPENAI_ORG_ID (可选)
指定 OpenAI 中的组织 ID。

HIDE_USER_API_KEY (可选)
如果你不想让用户自行填入 API Key,将此环境变量设置为 1 即可。

DISABLE_GPT4 (可选)
如果你不想让用户使用 GPT-4,将此环境变量设置为 1 即可。

HIDE_BALANCE_QUERY (可选)
如果你不想让用户查询余额,将此环境变量设置为 1 即可。

After starting the corresponding port, if it is a public cloud server, remember to open the corresponding port. 

 Run service

[root@yyt ChatGPT-Next-Web]# yarn install && yarn build 

[root@TttRark ChatGPT-Next-Web-main]# cat start.sh 
#!/bin/bash
PORT=Enter the port to be started
PORT=$PORT yarn start > /var/log/chatgpt.log 2>&1 & 

#Run logs can be viewed at /var/log/chatgpt.log

The port is started successfully and the page access test is carried out. 

 Access successful

Guess you like

Origin blog.csdn.net/TttRark/article/details/132734328