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

相关推荐
正义的彬彬侠16 分钟前
举例说明计算一个矩阵的秩的完整步骤
人工智能·机器学习·矩阵·回归
ariesjzj28 分钟前
图说GPT网络结构(参数量与计算量估计)
gpt·llm·flops·参数量·计算量
十有久诚36 分钟前
E2VPT: An Effective and Efficient Approach for Visual Prompt Tuning
人工智能·深度学习·提示学习·视觉语言模型
卓_尔_不_凡1 小时前
Pytorch学习---基于经典网络架构ResNet训练花卉图像分类模型
人工智能·分类·数据挖掘
神奇夜光杯1 小时前
Python酷库之旅-第三方库Pandas(123)
开发语言·人工智能·python·excel·pandas·标准库及第三方库·学习与成长
SEU-WYL1 小时前
基于神经网络的光线追踪
人工智能·神经网络·计算机视觉
Bill661 小时前
OpenCV GUI常用函数详解
人工智能·opencv·计算机视觉
DisonTangor1 小时前
OpenAI面向开发者继续提高o1系列模型的调用速率 最高每分钟可调用1000次
人工智能
zhangbin_2371 小时前
【Python机器学习】NLP信息提取——提取人物/事物关系
开发语言·人工智能·python·机器学习·自然语言处理
王豫翔1 小时前
OpenAl o1论文:Let’s Verify Step by Step 快速解读
人工智能·深度学习·机器学习·chatgpt