add rag service
This commit is contained in:
@@ -8,8 +8,8 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV
|
|||||||
APP="LibreChat"
|
APP="LibreChat"
|
||||||
var_tags="${var_tags:-ai;chat}"
|
var_tags="${var_tags:-ai;chat}"
|
||||||
var_cpu="${var_cpu:-4}"
|
var_cpu="${var_cpu:-4}"
|
||||||
var_ram="${var_ram:-4096}"
|
var_ram="${var_ram:-6144}"
|
||||||
var_disk="${var_disk:-12}"
|
var_disk="${var_disk:-20}"
|
||||||
var_os="${var_os:-debian}"
|
var_os="${var_os:-debian}"
|
||||||
var_version="${var_version:-13}"
|
var_version="${var_version:-13}"
|
||||||
var_unprivileged="${var_unprivileged:-1}"
|
var_unprivileged="${var_unprivileged:-1}"
|
||||||
@@ -30,9 +30,9 @@ function update_script() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if check_for_gh_tag "librechat" "danny-avila/LibreChat" "v"; then
|
if check_for_gh_tag "librechat" "danny-avila/LibreChat" "v"; then
|
||||||
msg_info "Stopping Service"
|
msg_info "Stopping Services"
|
||||||
systemctl stop librechat
|
systemctl stop librechat rag-api
|
||||||
msg_ok "Stopped Service"
|
msg_ok "Stopped Services"
|
||||||
|
|
||||||
msg_info "Backing up Configuration"
|
msg_info "Backing up Configuration"
|
||||||
cp /opt/librechat/.env /opt/librechat.env.bak
|
cp /opt/librechat/.env /opt/librechat.env.bak
|
||||||
@@ -47,6 +47,8 @@ function update_script() {
|
|||||||
|
|
||||||
msg_info "Building Frontend"
|
msg_info "Building Frontend"
|
||||||
$STD npm run frontend
|
$STD npm run frontend
|
||||||
|
$STD npm prune --production
|
||||||
|
$STD npm cache clean --force
|
||||||
msg_ok "Built Frontend"
|
msg_ok "Built Frontend"
|
||||||
|
|
||||||
msg_info "Restoring Configuration"
|
msg_info "Restoring Configuration"
|
||||||
@@ -54,10 +56,37 @@ function update_script() {
|
|||||||
rm -f /opt/librechat.env.bak
|
rm -f /opt/librechat.env.bak
|
||||||
msg_ok "Restored Configuration"
|
msg_ok "Restored Configuration"
|
||||||
|
|
||||||
msg_info "Starting Service"
|
msg_info "Starting Services"
|
||||||
systemctl start librechat
|
systemctl start rag-api librechat
|
||||||
msg_ok "Started Service"
|
msg_ok "Started Services"
|
||||||
msg_ok "Updated Successfully!"
|
msg_ok "Updated LibreChat Successfully!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if check_for_gh_release "rag-api" "danny-avila/rag_api"; then
|
||||||
|
msg_info "Stopping RAG API"
|
||||||
|
systemctl stop rag-api
|
||||||
|
msg_ok "Stopped RAG API"
|
||||||
|
|
||||||
|
msg_info "Backing up RAG API Configuration"
|
||||||
|
cp /opt/rag-api/.env /opt/rag-api.env.bak
|
||||||
|
msg_ok "Backed up RAG API Configuration"
|
||||||
|
|
||||||
|
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "rag-api" "danny-avila/rag_api" "tarball"
|
||||||
|
|
||||||
|
msg_info "Updating RAG API Dependencies"
|
||||||
|
cd /opt/rag-api
|
||||||
|
$STD uv pip install --python .venv/bin/python -r requirements.lite.txt
|
||||||
|
msg_ok "Updated RAG API Dependencies"
|
||||||
|
|
||||||
|
msg_info "Restoring RAG API Configuration"
|
||||||
|
cp /opt/rag-api.env.bak /opt/rag-api/.env
|
||||||
|
rm -f /opt/rag-api.env.bak
|
||||||
|
msg_ok "Restored RAG API Configuration"
|
||||||
|
|
||||||
|
msg_info "Starting RAG API"
|
||||||
|
systemctl start rag-api
|
||||||
|
msg_ok "Started RAG API"
|
||||||
|
msg_ok "Updated RAG API Successfully!"
|
||||||
fi
|
fi
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,14 +15,18 @@ update_os
|
|||||||
|
|
||||||
MONGO_VERSION="8.0" setup_mongodb
|
MONGO_VERSION="8.0" setup_mongodb
|
||||||
setup_meilisearch
|
setup_meilisearch
|
||||||
|
PG_VERSION="17" setup_postgresql
|
||||||
|
PG_DB_NAME="ragapi" PG_DB_USER="ragapi" PG_DB_EXTENSIONS="vector" setup_postgresql_db
|
||||||
NODE_VERSION="22" setup_nodejs
|
NODE_VERSION="22" setup_nodejs
|
||||||
|
UV_PYTHON="3.11" setup_uv
|
||||||
|
|
||||||
fetch_and_deploy_gh_tag "librechat" "danny-avila/LibreChat"
|
fetch_and_deploy_gh_tag "librechat" "danny-avila/LibreChat"
|
||||||
|
fetch_and_deploy_gh_release "rag-api" "danny-avila/rag_api" "tarball"
|
||||||
|
|
||||||
msg_info "Installing Dependencies"
|
msg_info "Installing LibreChat Dependencies"
|
||||||
cd /opt/librechat
|
cd /opt/librechat
|
||||||
$STD npm ci
|
$STD npm ci
|
||||||
msg_ok "Installed Dependencies"
|
msg_ok "Installed LibreChat Dependencies"
|
||||||
|
|
||||||
msg_info "Building Frontend"
|
msg_info "Building Frontend"
|
||||||
$STD npm run frontend
|
$STD npm run frontend
|
||||||
@@ -30,6 +34,13 @@ $STD npm prune --production
|
|||||||
$STD npm cache clean --force
|
$STD npm cache clean --force
|
||||||
msg_ok "Built Frontend"
|
msg_ok "Built Frontend"
|
||||||
|
|
||||||
|
msg_info "Installing RAG API Dependencies"
|
||||||
|
cd /opt/rag-api
|
||||||
|
$STD uv venv .venv
|
||||||
|
$STD uv pip install --python .venv/bin/python -r requirements.lite.txt
|
||||||
|
mkdir -p /opt/rag-api/uploads
|
||||||
|
msg_ok "Installed RAG API Dependencies"
|
||||||
|
|
||||||
msg_info "Configuring LibreChat"
|
msg_info "Configuring LibreChat"
|
||||||
JWT_SECRET=$(openssl rand -hex 32)
|
JWT_SECRET=$(openssl rand -hex 32)
|
||||||
JWT_REFRESH_SECRET=$(openssl rand -hex 32)
|
JWT_REFRESH_SECRET=$(openssl rand -hex 32)
|
||||||
@@ -59,15 +70,32 @@ SEARCH=true
|
|||||||
MEILI_NO_ANALYTICS=true
|
MEILI_NO_ANALYTICS=true
|
||||||
MEILI_HOST=http://127.0.0.1:7700
|
MEILI_HOST=http://127.0.0.1:7700
|
||||||
MEILI_MASTER_KEY=${MEILISEARCH_MASTER_KEY}
|
MEILI_MASTER_KEY=${MEILISEARCH_MASTER_KEY}
|
||||||
|
RAG_PORT=8000
|
||||||
|
RAG_API_URL=http://127.0.0.1:8000
|
||||||
APP_TITLE=LibreChat
|
APP_TITLE=LibreChat
|
||||||
EOF
|
EOF
|
||||||
msg_ok "Configured LibreChat"
|
msg_ok "Configured LibreChat"
|
||||||
|
|
||||||
msg_info "Creating Service"
|
msg_info "Configuring RAG API"
|
||||||
|
cat <<EOF >/opt/rag-api/.env
|
||||||
|
VECTOR_DB_TYPE=pgvector
|
||||||
|
DB_HOST=127.0.0.1
|
||||||
|
DB_PORT=5432
|
||||||
|
POSTGRES_DB=${PG_DB_NAME}
|
||||||
|
POSTGRES_USER=${PG_DB_USER}
|
||||||
|
POSTGRES_PASSWORD=${PG_DB_PASS}
|
||||||
|
RAG_HOST=0.0.0.0
|
||||||
|
RAG_PORT=8000
|
||||||
|
JWT_SECRET=${JWT_SECRET}
|
||||||
|
RAG_UPLOAD_DIR=/opt/rag-api/uploads/
|
||||||
|
EOF
|
||||||
|
msg_ok "Configured RAG API"
|
||||||
|
|
||||||
|
msg_info "Creating Services"
|
||||||
cat <<EOF >/etc/systemd/system/librechat.service
|
cat <<EOF >/etc/systemd/system/librechat.service
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=LibreChat
|
Description=LibreChat
|
||||||
After=network.target mongod.service
|
After=network.target mongod.service meilisearch.service rag-api.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
@@ -81,8 +109,25 @@ RestartSec=5
|
|||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
systemctl enable -q --now librechat
|
cat <<EOF >/etc/systemd/system/rag-api.service
|
||||||
msg_ok "Created Service"
|
[Unit]
|
||||||
|
Description=LibreChat RAG API
|
||||||
|
After=network.target postgresql.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=root
|
||||||
|
WorkingDirectory=/opt/rag-api
|
||||||
|
EnvironmentFile=/opt/rag-api/.env
|
||||||
|
ExecStart=/opt/rag-api/.venv/bin/uvicorn main:app --host 0.0.0.0 --port 8000
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
systemctl enable -q --now rag-api librechat
|
||||||
|
msg_ok "Created Services"
|
||||||
|
|
||||||
motd_ssh
|
motd_ssh
|
||||||
customize
|
customize
|
||||||
|
|||||||
@@ -20,8 +20,8 @@
|
|||||||
"script": "ct/librechat.sh",
|
"script": "ct/librechat.sh",
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": 4,
|
"cpu": 4,
|
||||||
"ram": 4096,
|
"ram": 6144,
|
||||||
"hdd": 12,
|
"hdd": 20,
|
||||||
"os": "Debian",
|
"os": "Debian",
|
||||||
"version": "13"
|
"version": "13"
|
||||||
}
|
}
|
||||||
@@ -39,6 +39,10 @@
|
|||||||
{
|
{
|
||||||
"text": "Configure your AI provider API keys in /opt/librechat/.env and restart the service.",
|
"text": "Configure your AI provider API keys in /opt/librechat/.env and restart the service.",
|
||||||
"type": "info"
|
"type": "info"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "RAG API is included and running on port 8000. Set RAG_OPENAI_API_KEY in /opt/rag-api/.env to enable document Q&A.",
|
||||||
|
"type": "info"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user