Clarktribegames,LLC
GPT4All API Server with Watchdog是一款简单的HTTP服务器,可监视和重新启动Python应用程序,在这种情况下为Server.py,它是GPT4All兼容模型的接口。
Watchdog连续运行并重新启动Python应用程序。Watchdog检查申请状态并处理某些突发事件。GPT4All API与GPT4ALL兼容模型与API请求的接口,并从模型中发送回复Windows:克隆在您的用户(或服务帐户使用一个)的位置中,可以完全读/写入访问权限。
MACOS/Linux:如果您打算将其用作服务,建议将此存储库克隆到/usr/local/bin中。但是,您可以克隆并从任何地方运行。在您的终端中运行这些命令:
cd /path-to-wherever/
git clone https://github.com/AznIronMan/gpt4all_api.git我们还建议在虚拟Python环境中运行此操作:
注意:您也可以使用Anaconda。不建议使用虚拟Python环境。
# Windows
cd gpt4all_api
python.exe -m venv .venv
source .venv/Scripts/activate # macOS/Linux
cd gpt4all_api
python3 -m venv .venv
source .venv/bin/activate请务必安装PIP要求(确认您在新的.venv venv之前!)
pip install -r requirements.txt启动之前,请确保配置.env文件! (克隆.env.example并将其重命名.env并使用适当的信息上传)。
对于此应用程序,建议使用GGML模型。 ggml模型拥抱脸
注意:此应用程序仅通过WizardML GGML(非FALCON)模型测试。
从那里运行服务器,您可以:
# Windows
python.exe watchdog.py # mac/OS/Linux
sudo python3 watchdog.py或者,您可以使用包含的bundled start.bat (Windows)或start.sh (macOS/linux)来启动服务器。
MACOS/Linux用户 - 您可能需要在此之前运行此命令,以允许start.sh在OS上运行:
sudo chmod +x ./start.sh此应用程序的watchdog部分在您的计算机上运行,并监视gpt4all_api应用程序。它检查是否存在一个watchdog文件文件,该文件用作信号,以指示gpt4all_api服务器完成请求的处理。
每个请求完成后,重新启动gpt4all_api服务器。这样做是为了重置gpt4all_api服务器的状态,并确保它准备好处理下一个传入请求。 (这是为了确保模型的新响应。试验表明,不重新启动API服务器会导致重复性,有时还会引起不同模型的Hallunication答案。)
watchdog检查watchdog文件是否缺少超过5秒钟。 gpt4all_api服务器将在完成后删除watchdog文件,从而触发重新启动。如果watchdog文件缺少gpt4all_api对请求响应和/或如果在gpt4all_api进程中存在错误,则watchdog脚本假设出现问题并试图在将错误登录到logs文件夹后重新启动gpt4all_api服务器。
gpt4all_api服务器使用烧瓶接受传入的API请求。默认route为/gpt4all_api ,但您可以将其与.env中的几乎所有其他所有内容设置。您可以发送带有查询参数类型的发布请求以获取所需的消息。以下是如何获取所有消息的一些示例:
# Using curl:
curl -X POST http://serverhostname_or_ipaddress_here:5000/gpt4all_api -H " Content-Type: application/json " -d " { " prompt " : " your question or request goes here " , " persona " : " [your system prompt goes here] " } " # Using Postman:
Set the request type to POST.
Set the URL to http://serverhostname_or_ipaddress_here:5000/messages.
Under Params, add a key-value pair with
key: ' prompt '
value: ' your question or request goes here '
And
key: ' persona '
value: ' [your system prompt goes here] ' 如果您在设置方面遇到麻烦,则可以按照以下步骤操作:
# macOS/Linux
cp .env.example .env
nano .env # or use TextEdit, VIM, VS Code, etc.
touch requirements.txt
nano requirements.txt # Windows
copy .env.example .env
notepad .env # notepad is on everyone windows machine but vscode or notepad++ is recommended
(make edits to your .env)
# if you do not have a requirements.txt for some reason
notepad requirements.txt将这些内容粘贴到您的requirements.txt中。txt文件:
blinker= =1.6.2
certifi= =2023.5.7
charset-normalizer= =3.1.0
click= =8.1.3
colorama= =0.4.6
Flask= =2.3.2
gpt4all= =0.3.5
idna= =3.4
itsdangerous= =2.1.2
Jinja2= =3.1.2
MarkupSafe= =2.1.3
python-dotenv= =1.0.0
requests= =2.31.0
tqdm= =4.65.0
urllib3= =2.0.3
Werkzeug= =2.3.6然后安装要求:
pip install -r requirements.txt然后,您可以使用python3 start.sh (macOS/linux)或python.exe start.bat (windows)启动服务器。
如果您对设置有任何问题,请随时使用下面提供的详细信息与我们联系。
该项目已根据MIT许可获得许可。
不和谐: AznIronMan电子邮件: Clark Tribe Games dot Com at Geoff (没有空间,并用 @和Dot替换为。 )