Skip to content

Commit ec186b0

Browse files
authored
Paperless-AI: Add RAG chat (#4635)
* Add RAG * Oops
1 parent c7afd9c commit ec186b0

File tree

2 files changed

+49
-11
lines changed

2 files changed

+49
-11
lines changed

ct/paperless-ai.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ function update_script() {
2727
msg_error "No ${APP} Installation Found!"
2828
exit
2929
fi
30+
if ! dpkg -s python3-pip >/dev/null 2>&1; then
31+
$STD apt-get install -y python3-pip
32+
fi
3033
RELEASE=$(curl -fsSL https://api.github.com/repos/clusterzx/paperless-ai/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
3134
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
3235
msg_info "Stopping $APP"
@@ -42,6 +45,25 @@ function update_script() {
4245
mkdir -p /opt/paperless-ai/data
4346
cp -a /opt/paperless-ai_bak/data/. /opt/paperless-ai/data/
4447
cd /opt/paperless-ai
48+
if [[ ! -f /etc/systemd/system/paperless-rag.service ]]; then
49+
cat <<EOF >/etc/systemd/system/paperless-rag.service
50+
[Unit]
51+
Description=PaperlessAI-RAG Service
52+
After=network.target
53+
54+
[Service]
55+
WorkingDirectory=/opt/paperless-ai
56+
ExecStart=/usr/bin/python3 main.py --host 0.0.0.0 --port 8000 --initialize
57+
Restart=always
58+
59+
[Install]
60+
WantedBy=multi-user.target
61+
EOF
62+
echo "RAG_SERVICE_URL=http://localhost:8000" >>/opt/paperless-ai/data/.env
63+
echo "RAG_SERVICE_ENABLED=true" >>/opt/paperless-ai/data/.env
64+
fi
65+
$STD pip install --no-cache-dir -r requirements.txt
66+
mkdir -p data/chromadb
4567
$STD npm install
4668
echo "${RELEASE}" >/opt/${APP}_version.txt
4769
msg_ok "Updated $APP to v${RELEASE}"

install/paperless-ai-install.sh

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,15 @@ update_os
1515

1616
msg_info "Installing Dependencies"
1717
$STD apt-get install -y \
18-
gpg \
1918
build-essential
2019
msg_ok "Installed Dependencies"
2120

22-
msg_info "Setting up Node.js Repository"
23-
mkdir -p /etc/apt/keyrings
24-
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
25-
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" >/etc/apt/sources.list.d/nodesource.list
26-
msg_ok "Set up Node.js Repository"
21+
msg_info "Installing Python3"
22+
$STD apt-get install -y \
23+
python3-pip
24+
msg_ok "Installed Python3"
2725

28-
msg_info "Installing Node.js"
29-
$STD apt-get update
30-
$STD apt-get install -y nodejs
31-
msg_ok "Installed Node.js"
26+
install_node_and_modules
3227

3328
msg_info "Setup Paperless-AI"
3429
cd /opt
@@ -37,6 +32,8 @@ curl -fsSL "https://github.com/clusterzx/paperless-ai/archive/refs/tags/v${RELEA
3732
unzip -q v${RELEASE}.zip
3833
mv paperless-ai-${RELEASE} /opt/paperless-ai
3934
cd /opt/paperless-ai
35+
$STD pip install --no-cache-dir -r requirements.txt
36+
mkdir -p data/chromadb
4037
$STD npm install
4138
mkdir -p /opt/paperless-ai/data
4239
cat <<EOF >/opt/paperless-ai/data/.env
@@ -61,6 +58,8 @@ API_KEY=
6158
CUSTOM_API_KEY=
6259
CUSTOM_BASE_URL=
6360
CUSTOM_MODEL=
61+
RAG_SERVICE_URL=http://localhost:8000
62+
RAG_SERVICE_ENABLED=true
6463
EOF
6564
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
6665
msg_ok "Setup Paperless-AI"
@@ -69,7 +68,8 @@ msg_info "Creating Service"
6968
cat <<EOF >/etc/systemd/system/paperless-ai.service
7069
[Unit]
7170
Description=PaperlessAI Service
72-
After=network.target
71+
After=network.target paperless-rag.service
72+
Requires=paperless-rag.service
7373
7474
[Service]
7575
WorkingDirectory=/opt/paperless-ai
@@ -79,6 +79,22 @@ Restart=always
7979
[Install]
8080
WantedBy=multi-user.target
8181
EOF
82+
83+
cat <<EOF >/etc/systemd/system/paperless-rag.service
84+
[Unit]
85+
Description=PaperlessAI-RAG Service
86+
After=network.target
87+
88+
[Service]
89+
WorkingDirectory=/opt/paperless-ai
90+
ExecStart=/usr/bin/python3 main.py --host 0.0.0.0 --port 8000 --initialize
91+
Restart=always
92+
93+
[Install]
94+
WantedBy=multi-user.target
95+
EOF
96+
systemctl enable -q --now paperless-rag
97+
sleep 5
8298
systemctl enable -q --now paperless-ai
8399
msg_ok "Created Service"
84100

0 commit comments

Comments
 (0)