源自:
http://chat.openai.com 经常性抽风,自建ChatGPT镜像服务器
Debian 10 安装 Python
root@vps:~# python --version Python 2.7.16 root@vps:~#
升级为新版本Python 3.7.3
root@vps:~# apt update root@vps:~# apt-get install python 3.7 root@vps:~# python3 Python 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> quit() root@vps:~# root@vps:~# echo "alias python='/usr/bin/python3.7'" >> ~/.bashrc root@vps:~# source ~/.bashrc root@vps:~# python -V Python 3.7.3 root@vps:~#
安装python版本的zhile-io/pandora ChatGPT
https://github.com/zhile-io/pandora
root@vps:~# apt-get install python-dev python3-dev build-essential libssl-dev libffi-dev libxml2-dev libxslt1-dev zlib1g-dev root@vps:~# apt install python3-pip root@vps:/# ln -sv /usr/bin/pip3 /usr/bin/pip '/usr/bin/pip' -> '/usr/bin/pip3' root@vps:/# pip -V pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7) root@vps:/# pip install --upgrade pip Collecting pip Downloading https://files.pythonhosted.org/packages/47/6a/453160888fab7c6a432a6e25f8afe6256d0d9f2cbd25971021da6491d899/pip-23.3.1-py3-none-any.whl (2.1MB) 100% |████████████████████████████████| 2.1MB 309kB/s Installing collected packages: pip Found existing installation: pip 18.1 Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr Can't uninstall 'pip'. No files were found to uninstall. Successfully installed pip-23.3.1 root@vps:/# pip install 'pandora-chatgpt[cloud]' root@vps:/# pandora-cloud Pandora-Cloud - A web interface to ChatGPT Github: https://github.com/zhile-io/pandora Version: 1.3.5, Mode: cloud, Engine: free 2023-11-02 08:41:02.220 | WARNING | pandora_cloud.server:run:72 - Serving on http://127.0.0.1:8018 root@vps:~# whereis pandora-cloud pandora-cloud: /usr/local/bin/pandora-cloud
#改用服务的形式运行chatgpt服务器
root@vps:~# vi /etc/init.d/chatgpt #!/bin/bash # #https://wiki.debian.org/LSBInitScripts ### BEGIN INIT INFO # Provides: chatgpt # Required-Start: $local_fs $remote_fs $network # Required-Stop: $local_fs $remote_fs $network # Should-Start: $named # Should-Stop: $named # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start chatgpt. # Description: Start the Tomcat servlet engine. ### END INIT INFO start() { echo "=========================" echo "chatgpt AutoStart" sleep 10 /usr/local/bin/pandora-cloud& echo "=========================" } stop() { echo "chatgpt Stop!!!!!" /bin/su pkill pandora } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; *) echo "Usage: chatgpt {start|stop|restart}" ;; esac exit 0 "/etc/init.d/chatgpt" [New] 48L, 995C written root@vps:~# chmod 755 /etc/init.d/chatgpt root@vps:~# systemctl daemon-reload root@vps:~# update-rc.d chatgpt defaults root@vps:~# service chatgpt status ● chatgpt.service - LSB: Start chatgpt. Loaded: loaded (/etc/init.d/chatgpt; generated) Active: inactive (dead) Docs: man:systemd-sysv-generator(8) root@vps:~# root@vps:~# service chatgpt restart root@vps:~# service chatgpt status ● dropbox.service - LSB: Start dropbox. Loaded: loaded (/etc/init.d/dropbox; generated) Active: active (exited) since Sat 2023-10-28 16:30:28 CST; 6s ago Docs: man:systemd-sysv-generator(8) Process: 1110 ExecStart=/etc/init.d/dropbox start (code=exited, status=0/SUCCE Oct 28 16:30:18 vps systemd[1]: Starting LSB: Start dropbox.... Oct 28 16:30:18 vps dropbox[1110]: ========================= Oct 28 16:30:18 vps dropbox[1110]: dropbox AutoStart Oct 28 16:30:28 vps dropbox[1110]: Dropbox is already running! Oct 28 16:30:28 vps dropbox[1110]: ========================= Oct 28 16:30:28 vps systemd[1]: Started LSB: Start dropbox.. root@vps:~#
在nginx中使用proxy_pass指向 http://127.0.0.1:8018 就可以了。
location / { proxy_pass http://127.0.0.1:8018; }
在模板中添加openai Token获取链接:
root@vps:~# vi /usr/local/lib/python3.7/dist-packages/pandora_cloud/flask/templates/login.html #在"</footer>"前面添加<a href="http://chat.openai.com/api/auth/session"target="_blank">OpenAI session Token</a> #重启服务使更改生效 root@vps:~# service chatgpt restart
获取自己的 Access TOKEN: http://chat.openai.com/api/auth/session