Ai Server Set-Up
First Let's update and upgrade the system
apt-get update apt-get upgrade
Next let's let's install Python
apt install python3.9
Now let's update Pip
python3.9 -m pip install --upgrade pip
note that during develpment it is required to create a virtual environment.
apt install python3.9-venv
python3.9 -m venv venv # a popup wil apear if you are goint to use the venv created just click yes.
source ./venv/bin/activate
Install the below python packages:
pip install wheel
To know the required python packages, install "pipreqs" package and then run below command from project main directory.
python3.9 -m pip install pipreqs
To create and save all required packages to requirements.txt:
pipreqs --force
Install git
sudo apt-get install git
Check if ctypesgen is installed, if not, Install ctypesgen
ctypesgen --version
Install ctypesgen
pip install ctypesgen
To Install all packages from requirements.txt:
python3.9 -m pip install -r requirements.txt
NOTE: If at any stage you get a disk full error you need to increase the cache
sudo mount -o remount,size=4G /tmp
Some .pdf files require poppler and tesseract to read them.
sudo apt install poppler-utils sudo apt intall tesseract-ocr
Install uvicorn
pip install uvicorn
Start API
uvicorn engine:app --host 0.0.0.0 --port 8502 --reload
Start UI
streamlit run home.py --server.port 5173?
If error change home.py wording to :
from llama_index.core import Document
openai update required
openai migrate
Guide how to run app on A2Hosting Alma Linux permanently
Navigate to "/etc/systemd/system"
Create new service file executing command
nano <service file name>.service
Note. how to get the "username" and "working directory path" navigate to where the app where extracted run command
pwd
ex result: /home/blobstormimreal/www/BlogEngine_v4 username: blobstormimreal path: /home/blobstormimreal/www/BlogEngine_v4
Blank file will open and paste config below for UI config
[Unit]
Description=blog engine client
After=network.target
[Service]
User=
WorkingDirectory=
ExecStart=/usr/local/bin/streamlit run Home.py --server.port
Restart=always
[Install]
WantedBy=multi-user.target
Blank file will open and paste config below for API server config
[Unit]
Description=blog engine server
After=network.target
[Service]
User=
WorkingDirectory=
ExecStart=/usr/bin/env python3.9 -m uvicorn main:app --host 0.0.0.0 --port
Restart=always
[Install]
WantedBy=multi-user.target
Don't forget to change below to the correct data
(allowed port range 30000 to 50000)
Check .env file for modifications
OPENAI_API_KEY="" FLAST_API_URL="" SECRET_KEY="" ENGINE_ENDPOINT=""
after above is done save the file and run command
systemctl enable <service file name>.service
systemctl start <service file name>.service
systemctl status <service file name>.service
final command do this to all files and folders (pages, prompts, Home.py, main.py)
chmod -R 644 // 644 or 755 or 777??