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替換為。 )