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

相关推荐
仗剑_走天涯1 小时前
基于pytorch.nn模块实现线性模型
人工智能·pytorch·python·深度学习
cnbestec2 小时前
协作机器人UR7e与UR12e:轻量化设计与高负载能力助力“小而美”智造升级
人工智能·机器人·协作机器人·ur协作机器人·ur7e·ur12e
zskj_zhyl2 小时前
毫米波雷达守护银发安全:七彩喜跌倒检测仪重构居家养老防线
人工智能·安全·重构
gaosushexiangji3 小时前
利用sCMOS科学相机测量激光散射强度
大数据·人工智能·数码相机·计算机视觉
ai小鬼头4 小时前
AIStarter新版重磅来袭!永久订阅限时福利抢先看
人工智能·开源·github
说私域4 小时前
从品牌附庸到自我表达:定制开发开源AI智能名片S2B2C商城小程序赋能下的营销变革
人工智能·小程序
飞哥数智坊5 小时前
新版定价不够用,Cursor如何退回旧版定价
人工智能·cursor
12点一刻5 小时前
搭建自动化工作流:探寻解放双手的有效方案(2)
运维·人工智能·自动化·deepseek
未来之窗软件服务5 小时前
东方仙盟AI数据中间件使用教程:开启数据交互与自动化应用新时代——仙盟创梦IDE
运维·人工智能·自动化·仙盟创梦ide·东方仙盟·阿雪技术观
JNU freshman6 小时前
计算机视觉速成 之 概述
人工智能·计算机视觉