免费使用GPT4,Windows一键启动脚本及解析

开源了,免费使用GPT4(Windows一键启动脚本)

大家好,我打算每日花1小时来写一篇文章,这一小时包括文章主题思考和实现,连续日更几天,看看能不能被官方推荐。(帮我点点赞哦~)

今天的主题是:给之前写的文章开源了,免费使用GPT4,添加一个Windows一键启动脚本,这篇文章如果对你帮助极大,欢迎你分享给你的朋友、她、他,一起成长。

也欢迎大家留言,说说自己想看什么主题的Python文章,留言越具体,我写的越快,比如留言:我想看Python 自动操作Excel 相关文章。

如果你有具体的需求想通过使用Python实现自动化,那将更好,欢迎私聊我微信,一起交流探讨。

Windows 一键启动脚本

我看开源了,免费使用GPT4文章有很多朋友留言说想要对应启动脚本的 Windows 版本,所以这篇文章给大家这个脚本,顺便介绍下如何写Windows脚本。

脚本分为2个,第一个 install_env.bat,内容如下,主要功能是安装 conda 和创建环境,只需要运行一遍即可。

bat 复制代码
@echo off

echo Installing Miniconda...
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -o miniconda.exe
start /wait "" miniconda.exe /SILENT /AddToPath=1
del miniconda.exe

echo Installing Git for Windows...
curl -L https://mirror.ghproxy.com/https://github.com/git-for-windows/git/releases/download/v2.43.0.windows.1/Git-2.43.0-64-bit.exe -o git-install.exe
start /wait "" git-install.exe /SILENT /AddToPath=1
del git-install.exe

echo Cloning the repository...
git clone https://mirror.ghproxy.com/https://github.com/xtekky/gpt4free
cd gpt4free
conda  activate gpt4free && pip install -r requirements.txt && pip install g4f

第二个 start.bat,内容如下,主要功能是启动服务,需要启动的时候点击运行。

bat 复制代码
@echo off

echo Setting G4F_PROXY environment variable...
setx G4F_PROXY "http://127.0.0.1:7890"

echo Running the application...
cd gpt4free
conda activate gpt4free && python g4f/gui/run.py

浏览器访问:http://127.0.0.1:8080 即可。

Linux/Mac 一键启动脚本

顺便完善下 Linux/Mac 的脚本内容。

第一个 install_env.sh,内容如下,主要功能是安装 conda 和创建环境,只需要运行一遍即可。

bash 复制代码
#! /bin/bash

wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py38_22.11.1-1-Linux-x86_64.sh 
chmod +x Miniconda3-py38_22.11.1-1-Linux-x86_64.sh
./Miniconda3-py38_22.11.1-1-Linux-x86_64.sh -b && /root/miniconda3/bin/conda init bash && /root/miniconda3/bin/conda clean -ya
# 安装 gpt4free 环境
git clone https://mirror.ghproxy.com/https://github.com/xtekky/gpt4free
cd gpt4free
conda create -n gpt4free python=3.9
source activate gpt4free && pip install -r requirements.txt && pip install g4f

第二个 start.sh,内容如下,主要功能是启动服务,需要启动的时候运行。

bash 复制代码
#! /bin/bash
cd gpt4free
export G4F_PROXY=http://127.0.0.1:7890
source activate gpt4free && python g4f/gui/run.py

Linux/Mac .sh 脚本运行方法:

bash 复制代码
# 给予可执行权限
chmod +x install_env.sh start.sh 
# 运行一遍即可
bash install_env.sh
# 启动服务运行它
bash start.sh 

大家也可以输入以下指令git clone 我修改过的项目。

bash 复制代码
git clone https://mirror.ghproxy.com/https://github.com/XksA-me/gpt4free

我在源项目 etc 下新建了一个 script 文件夹存放了本文提到的四个一键启动脚本。

Windwos 脚本解析(感兴趣可以看看)

其实都很简单,脚本的作用就是把一连串人工操作让机器去操作,提前需要给机器对应的操作指令。

这个Windows批处理脚本的每一行都有其特定的关键词和含义。以下是每行的关键词和含义:

  1. @echo off - Windows 脚本开头,用于关闭脚本的命令回显,执行命令不会在命令提示符中显示脚本的具体命令。

  2. echo Installing Miniconda... - Windows脚本里可以使用 echo 指令打印文本,提示脚本执行进度。

  3. curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -o miniconda.exe - 使用curl工具从指定的URL下载Miniconda安装程序(.exe文件)并将其保存为miniconda.exe。

  4. start /wait "" miniconda.exe /SILENT /AddToPath=1 - 用于启动Miniconda安装程序,并使用/SILENT参数以安静模式运行,以及/AddToPath=1参数以将Miniconda添加到系统的PATH环境变量中。/wait参数会等待安装程序完成。

  5. del miniconda.exe - 用于删除之前下载的Miniconda安装程序(miniconda.exe),以节省空间。

  6. git clone https://mirror.ghproxy.com/https://github.com/xtekky/gpt4free - 用于使用 git 下载gpt4free仓库代码,其中https://mirror.ghproxy.com/是一个国内源,用于加速下载github内容。

  7. cd gpt4free - cd 指令切换到gpt4free目录。

  8. conda activate gpt4free && pip install -r requirements.txt && pip install g4f - 首先激活名为"gpt4free"的Conda环境,然后使用pip安装gpt4free目录下requirements.txt文件中列出的Python包,最后使用pip安装g4f包。

  9. setx G4F_PROXY "http://127.0.0.1:7890" - 设置环境变量,Windows 里使用的是setx指令,linux/mac 是 export 指令。

  10. conda activate gpt4free && python g4f/gui/run.py - conda 激活环境,然后运行案例代码启动服务。

整体来说和 linux 启动脚本差不多,有一些细微的差别,更详细的编写说明大家可以浏览器查官方教程,有任何问题可以评论或者私聊交流。

相关推荐
奔跑中的小象5 小时前
统信UOS + 天数AI卡部署SGLang服务手册
人工智能·uos·sglang·天数智芯
DevSecOps选型指南5 小时前
中国版Mythos,为何是悬镜安全灵脉CodeAI?
人工智能·安全
Shockang5 小时前
LangGraph 状态机实战
人工智能
刹那芳华19925 小时前
循环神经网络的从零开始实现(RNN)
人工智能·rnn·深度学习
阿童木写作5 小时前
跨境图片翻译工具多合一,批量图片视频字幕翻译加智能抠图
人工智能·python·音视频·语音识别
科技之门5 小时前
AI3D从建模到贴图、绑骨和动画的完整流程怎么做?V2Fun完整工作流指南
人工智能·3d·贴图
宇宙第一小趴菜5 小时前
二、机器学习的应用领域和发展史
人工智能·机器学习
前端开发江鸟5 小时前
我写过 MCP Server,却一直以为 MCP 只有 Tool
人工智能
天国梦6 小时前
自习室智能化升级避坑指南:天学网AI智习室方案实测与选型建议
大数据·人工智能
阿里云云原生6 小时前
可用性从 99.9% 跃升至 99.995%:畅捷通如何用 AI 重塑运维底座?
运维·网络·人工智能