forked from Mozilla-Ocho/llamafile-rag-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.sh
executable file
·48 lines (39 loc) · 960 Bytes
/
app.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# Load config and virtualenv
. .env
if [ -z "${VIRTUAL_ENV}" ]; then source venv/bin/activate; fi
mkdir logs
# Start llamafiles
echo "Starting llamafile servers..."
"models/embedding_model.llamafile" \
--server \
--nobrowser \
--port "${EMBEDDING_MODEL_PORT}" > logs/embedding_model.log 2>&1 &
pid=$!
sleep 20
err=$?
if [ "${err}" -ne 0 ]; then
echo "Failed to start embedding model llamafile"
exit 1
fi
echo "${pid}" > .pid_embedding_model
echo "started embedding model"
"models/generation_model.llamafile" \
--server \
--nobrowser \
--port "${GENERATION_MODEL_PORT}" > logs/generation_model.log 2>&1 &
pid=$!
sleep 20
err=$?
if [ "${err}" -ne 0 ]; then
echo "Failed to start generation model llamafile"
exit 1
fi
echo "${pid}" > .pid_generation_model
echo "started generation model"
# Run RAG app
python app.py "$@"
# Shut down the llamafiles
kill "$(cat .pid_embedding_model)"
kill "$(cat .pid_generation_model)"
echo "exited."