免费使用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 启动脚本差不多,有一些细微的差别,更详细的编写说明大家可以浏览器查官方教程,有任何问题可以评论或者私聊交流。

相关推荐
jndingxin4 分钟前
OPenCV CUDA模块光流处理------利用Nvidia GPU的硬件加速能力来计算光流类cv::cuda::NvidiaHWOpticalFlow
人工智能·opencv·计算机视觉
计算机小手13 分钟前
开源大模型网关:One API实现主流AI模型API的统一管理与分发
人工智能·语言模型·oneapi
kk57919 分钟前
保姆级教程:在无网络无显卡的Windows电脑的vscode本地部署deepseek
人工智能·windows·vscode·chatgpt
柠檬味拥抱38 分钟前
融合CLIP与语言规划的大规模具身智能系统设计探索
人工智能
‘’林花谢了春红‘’38 分钟前
高等三角函数大全
人工智能
敲键盘的小夜猫38 分钟前
大模型智能体核心技术:CoT与ReAct深度解析
人工智能·python
a1235k1 小时前
成都鼎讯硬核科技!雷达目标与干扰模拟器,以卓越性能制胜电磁频谱战
人工智能
AIwenIPgeolocation1 小时前
热烈祝贺埃文科技正式加入可信数据空间发展联盟
人工智能·科技
华硕广东1 小时前
华硕a豆14 Air香氛版,美学与科技的馨香融合
人工智能·科技
l1t1 小时前
DeepSeek辅助实现的DuckDB copy to自定义函数
数据库·c++·人工智能