安装GPT4Free(也就是g4f)的最新版:g4f-6.5.7
GPT4Free(也就是g4f)版本更新很快啊,转到到了6.5.7版本了!
升级到g4f-6.5.7
升级还是那么简单:
pip install pip -U
pip install g4f -U
更新完毕:
Downloading g4f-6.5.7-py3-none-any.whl (572 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 572.2/572.2 kB 5.2 MB/s 0:00:01
Installing collected packages: g4fAttempting uninstall: g4fFound existing installation: g4f 0.6.4.3Uninstalling g4f-0.6.4.3:Successfully uninstalled g4f-0.6.4.3
Successfully installed g4f-6.5.7
如果是想安装g4f所有软件包,那么加上[all]参数,使用这句:
pip install g4f[all] -U
比如可能会更新这两个包
Installing collected packages: caio, aiofile
Successfully installed aiofile-3.9.0 caio-0.9.24
启动api服务
启动默认1337端口的web和api服务
g4f api
输出
g4f api
/home/skywalk/.local/lib/python3.10/site-packages/pydub/utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not workwarn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
Starting server... [g4f v-6.5.7]
INFO: Started server process [3865440]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:1337 (Press CTRL+C to quit)
edgeone转发
发现昨天设置的edgeone加速,今天连域名+1337端口,连不上。
思考:可能是不加速1337端口?
还是因为域名没有认证直接不能web加速?那样不就变成只能ping加速了吗?
我要你ping加速有何用!
做了测试,发现是对1337不转发,只支持80端口的加速转发。这就对了么!
这样至少确实gui模式速度快一点了
也就是1337端口api不进行转发,走普通通道。
设置nginx转发1337端口,转到80端口
g4f 的1337端口转到80端口(使用nginx将1337端口转发到80端口),这样才能走edgeone加速,以提高网页使用体验。原来ping值200ms,可以减少到90ms左右。
g4f的nginx转发配置文件,g4f.conf文件
upstream g4f.xxxx.org{ip_hash;server 127.0.0.1:1337;#server 192.168.0.9:5001;
}server {listen 80;# optional ssl configurationlisten 443 ssl;#ssl_certificate /path/to/ssl/pem_file;#ssl_certificate_key /path/to/ssl/certificate_key;# end of optional ssl configurationserver_name g4f.xxxx.org;access_log /var/log/nginx/access.log;location / {proxy_set_header X-Forwarded-Proto $scheme;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Host $host:$server_port;proxy_set_header X-Forwarded-Port $server_port;proxy_set_header Host $host:$server_port;client_max_body_size 10m;client_body_buffer_size 128k;proxy_connect_timeout 60s;proxy_send_timeout 90s;proxy_read_timeout 90s;proxy_buffering off;proxy_temp_file_write_size 64k;proxy_pass http://g4f.xxxx.org;proxy_redirect off;}
}
当然需要在nginx.conf文件中加入incloude
include /etc/nginx/g4f.xxxx.org;
edgeone里加入证书
使用http浏览没问题,但是用https的时候,会报证书不安全的问题,因此需要到edgeone里去添加证书。点击edit即可:

这样就没有报错了。
注意前面的nginx配置文件里,要打开443端口
listen 443 ssl;
否则nginx那边不会侦听,会导致出现nginx的默认页面。
