forked from Josh-XT/AGiXT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AGiXT.sh
executable file
·402 lines (381 loc) · 15.3 KB
/
AGiXT.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
#!/bin/bash
# Define colors and formatting
BOLD=$(tput bold)
GREEN=$(tput setaf 2)
CYAN=$(tput setaf 6)
YELLOW=$(tput setaf 3)
RED=$(tput setaf 1)
MAGENTA=$(tput setaf 5)
BLUE=$(tput setaf 4)
RESET=$(tput sgr0)
# Check if .env file exists
environment_setup() {
if [[ ! -f ".env" ]]; then
clear
echo "${BOLD}${CYAN}"
echo " ___ _______ _ ________"
echo " / | / ____(_) |/ /_ __/"
echo " / /| |/ / __/ /| / / / "
echo " / ___ / /_/ / // | / / "
echo "/_/ |_\____/_//_/|_|/_/ "
echo " "
echo "----------------------------------------------------${RESET}"
echo "${BOLD}${MAGENTA}Visit our documentation at https://AGiXT.com ${RESET}"
echo "${BOLD}${MAGENTA}Welcome to the AGiXT Environment Setup!${RESET}"
read -p "Quick Setup without advanced configuration? (Y for yes, N for No): " quick_setup
if [[ "$quick_setup" == [Yy]* ]]; then
auto_update = true
agixt_uri = "http://localhost:7437"
api_key = ""
agixt_workers = 10
else
read -p "Do you want AGiXT to automatically update when launched? (Y for yes, N for No): " auto_update
if [[ "$auto_update" == [Yy]* ]]; then
auto_update="true"
else
auto_update="false"
fi
read -p "Do you want to set an API key for AGiXT? (Y for yes, N for No): " use_api_key
if [[ "$use_api_key" == [Yy]* ]]; then
read -p "Enter API key: " api_key
fi
read -p "Enter the number of AGiXT workers to run with, default is 10: " workers
if [[ "$workers" != "" ]]; then
if [[ $workers =~ ^[0-9]+$ && $workers -gt 0 ]]; then
agixt_workers=$workers
else
echo "Invalid number of workers, defaulting to 10"
agixt_workers=10
fi
fi
read -p "Do you intend to run Oobabooga Text Generation Web UI with AGiXT using this installer? (Only works with NVIDIA currently) Choose no if you do not need this or are already running it locally. (Y for yes, N for No): " local_models
if [[ "$local_models" == [Yy]* ]]; then
read -p "Enter your GPU Compute Capability, you can find it here: https://developer.nvidia.com/cuda-gpus (Example: RTX2000 series are 7.5): " cuda_version
if [[ "$cuda_version" != "" ]]; then
if [[ $cuda_version =~ ^[0-9]+\.[0-9]+$ ]]; then
echo "TORCH_CUDA_ARCH_LIST=${cuda_version:-7.5}" >> .env
fi
fi
cli_args_default='--listen --listen-host 0.0.0.0 --api'
read -p "Default Text generation web UI startup parameters: ${cli_args_default} (press Enter for defaults or overwrite with yours): " local_textgen_startup_params
echo "CLI_ARGS='${local_textgen_startup_params:-${cli_args_default}}'" >> .env
fi
fi
echo "AGIXT_AUTO_UPDATE=${auto_update:-true}" >> .env
echo "AGIXT_URI=${agixt_uri:-http://localhost:7437}" >> .env
echo "AGIXT_API_KEY=${api_key:-}" >> .env
echo "UVICORN_WORKERS=${agixt_workers:-10}" >> .env
fi
source .env
}
# Function to display the menu
display_menu() {
clear
echo "${BOLD}${CYAN}"
echo " ___ _______ _ ________"
echo " / | / ____(_) |/ /_ __/"
echo " / /| |/ / __/ /| / / / "
echo " / ___ / /_/ / // | / / "
echo "/_/ |_\____/_//_/|_|/_/ "
echo " "
echo "----------------------------------------------------${RESET}"
echo "${BOLD}${MAGENTA}Visit our documentation at https://AGiXT.com ${RESET}"
echo "${BOLD}${MAGENTA}Welcome to the AGiXT Installer!${RESET}"
echo "${BOLD}${GREEN}Please choose an option:${RESET}"
echo " ${BOLD}${YELLOW}1.${RESET} ${YELLOW}Run AGiXT (Recommended)${RESET}"
echo " ${BOLD}${YELLOW}2.${RESET} ${YELLOW}Run AGiXT with Text Generation Web UI (NVIDIA Only)${RESET}"
echo " ${BOLD}${YELLOW}3.${RESET} ${YELLOW}Run AGiXT with Text Generation Web UI and Stable Diffusion (NVIDIA Only)${RESET}"
echo "${BOLD}${GREEN}Developer Only Options (Not recommended or supported):${RESET}"
echo " ${BOLD}${YELLOW}4.${RESET} ${YELLOW}Run AGiXT from Main Branch${RESET}"
echo " ${BOLD}${YELLOW}5.${RESET} ${YELLOW}Run AGiXT Backend Only${RESET}"
echo " ${BOLD}${YELLOW}6.${RESET} ${YELLOW}Run AGiXT without Docker${RESET}"
echo "${BOLD}${GREEN}Manage:${RESET}"
if [[ "$AGIXT_AUTO_UPDATE" == "true" ]]; then
echo " ${BOLD}${YELLOW}7.${RESET} ${YELLOW}Disable Automatic Updates${RESET}"
else
echo " ${BOLD}${YELLOW}7.${RESET} ${YELLOW}Enable Automatic Updates${RESET}"
fi
echo " ${BOLD}${RED}8.${RESET} ${RED}Exit${RESET}"
echo ""
}
# Function to perform the Update
update_local() {
echo "${BOLD}${GREEN}Running Updates...${RESET}"
echo "${BOLD}${YELLOW}Updating AGiXT Core...${RESET}"
git pull
echo "${BOLD}${YELLOW}Updating AGiXT Streamlit Web UI...${RESET}"
if [ ! -d "streamlit" ]; then
git clone https://github.com/AGiXT/streamlit
fi
cd streamlit
git pull
cd ..
# Check if TORCH_CUDA_ARCH_LIST is defined from the env, only update Text generation web UI if it is.
if [[ -z "${TORCH_CUDA_ARCH_LIST}" ]]; then
echo "${BOLD}${YELLOW}Please wait...${RESET}"
else
if [ ! -d "text-generation-webui" ]; then
echo "${BOLD}${YELLOW}Updating Oobabooga Text generation web UI Repository...${RESET}"
git clone https://github.com/oobabooga/text-generation-webui
fi
cd text-generation-webui
git pull
cd ..
fi
echo "${BOLD}${YELLOW}Updates Completed...${RESET}"
}
update_docker() {
echo "${BOLD}${GREEN}Running Updates...${RESET}"
echo "${BOLD}${YELLOW}Updating AGiXT Core...${RESET}"
git pull
# Check if TORCH_CUDA_ARCH_LIST is defined from the env, only update Text generation web UI if it is.
if [[ -z "${TORCH_CUDA_ARCH_LIST}" ]]; then
echo "${BOLD}${YELLOW}Please wait...${RESET}"
else
if [ ! -d "text-generation-webui" ]; then
echo "${BOLD}${YELLOW}Updating Oobabooga Text generation web UI Repository...${RESET}"
git clone https://github.com/oobabooga/text-generation-webui
fi
cd text-generation-webui
git pull
echo "${BOLD}${YELLOW}Updating Text generation web UI Docker image...${RESET}"
cd ..
docker-compose -f docker-compose-local-nvidia.yml build text-generation-webui
fi
echo "${BOLD}${YELLOW}Current directory: ${PWD}${RESET}"
docker-compose pull
echo "${BOLD}${YELLOW}Updates Completed...${RESET}"
}
# Function to perform the Docker install
docker_install() {
sed -i '/^AGIXT_URI=/d' .env
echo "AGIXT_URI=http://agixt:7437" >> .env
source .env
if [[ "$AGIXT_AUTO_UPDATE" == "true" ]]; then
docker-compose pull
fi
echo "${BOLD}${YELLOW}Starting Docker Compose...${RESET}"
docker-compose up
}
docker_install_dev() {
sed -i '/^AGIXT_URI=/d' .env
echo "AGIXT_URI=http://agixt:7437" >> .env
sed -i '/^TEXTGEN_URI=/d' .env
echo "TEXTGEN_URI=http://text-generation-webui:5000" >> .env
source .env
if [[ "$AGIXT_AUTO_UPDATE" == "true" ]]; then
docker-compose -f docker-compose-dev.yml pull
fi
echo "${BOLD}${YELLOW}Starting Docker Compose...${RESET}"
docker-compose -f docker-compose-dev.yml up
}
backend_only() {
sed -i '/^AGIXT_URI=/d' .env
echo "AGIXT_URI=http://agixt:7437" >> .env
source .env
if [[ "$AGIXT_AUTO_UPDATE" == "true" ]]; then
echo "${BOLD}${YELLOW}Updating Containers...${RESET}"
docker-compose -f backend.yml pull
fi
echo "${BOLD}${GREEN}Running Docker install...${RESET}"
echo "${BOLD}${YELLOW}Starting Docker Compose...${RESET}"
docker-compose -f backend.yml up
}
# Function to perform the Docker install
docker_install_local_nvidia() {
sed -i '/^AGIXT_URI=/d' .env
echo "AGIXT_URI=http://agixt:7437" >> .env
sed -i '/^TEXTGEN_URI=/d' .env
echo "TEXTGEN_URI=http://text-generation-webui:5000" >> .env
source .env
# Check if TORCH_CUDA_ARCH_LIST is defined from the env, ask user to enter it if not.
if [[ -z "${TORCH_CUDA_ARCH_LIST}" ]]; then
read -p "Enter your GPU Compute Capability, you can find it here: https://developer.nvidia.com/cuda-gpus (Example: RTX2000 series are 7.5): " cuda_version
if [[ "$cuda_version" != "" ]]; then
if [[ $cuda_version =~ ^[0-9]+\.[0-9]+$ ]]; then
echo "TORCH_CUDA_ARCH_LIST=${cuda_version:-7.5}" >> .env
fi
fi
cli_args_default='--listen --listen-host 0.0.0.0 --api'
read -p "Default Text generation web UI startup parameters: ${cli_args_default} (prese Enter for defaults or overwrite with yours): " local_textgen_startup_params
echo "CLI_ARGS='${local_textgen_startup_params:-${cli_args_default}}'" >> .env
fi
# Check if nvidia-container-toolkit is installed
if dpkg -l | grep -iq "nvidia-container-toolkit"; then
echo "Confirmed NVIDIA Container Toolkit is installed."
else
echo "NVIDIA Container Toolkit is not installed. Installing now..."
# Install a new GPU Docker container
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
sudo systemctl restart docker
echo "NVIDIA Container Toolkit has been installed."
fi
if [ ! -d "text-generation-webui" ]; then
echo "${BOLD}${YELLOW}Cloning Oobabooga Text generation web UI Repository...${RESET}"
git clone https://github.com/oobabooga/text-generation-webui
fi
echo "${BOLD}${GREEN}Running Docker install...${RESET}"
echo "${BOLD}${YELLOW}Starting Docker Compose...${RESET}"
if [[ "$AGIXT_AUTO_UPDATE" == "true" ]]; then
docker-compose -f docker-compose-local-nvidia.yml pull
fi
docker-compose -f docker-compose-local-nvidia.yml up
}
docker_install_local_nvidia_sd() {
sed -i '/^AGIXT_URI=/d' .env
echo "AGIXT_URI=http://agixt:7437" >> .env
sed -i '/^TEXTGEN_URI=/d' .env
echo "TEXTGEN_URI=http://text-generation-webui:5000" >> .env
source .env
# Check if TORCH_CUDA_ARCH_LIST is defined from the env, ask user to enter it if not.
if [[ -z "${TORCH_CUDA_ARCH_LIST}" ]]; then
read -p "Enter your GPU Compute Capability, you can find it here: https://developer.nvidia.com/cuda-gpus (Example: RTX2000 series are 7.5): " cuda_version
if [[ "$cuda_version" != "" ]]; then
if [[ $cuda_version =~ ^[0-9]+\.[0-9]+$ ]]; then
echo "TORCH_CUDA_ARCH_LIST=${cuda_version:-7.5}" >> .env
fi
fi
cli_args_default='--listen --listen-host 0.0.0.0 --api'
read -p "Default Text generation web UI startup parameters: ${cli_args_default} (prese Enter for defaults or overwrite with yours): " local_textgen_startup_params
echo "CLI_ARGS='${local_textgen_startup_params:-${cli_args_default}}'" >> .env
fi
# Check if nvidia-container-toolkit is installed
if dpkg -l | grep -iq "nvidia-container-toolkit"; then
echo "Confirmed NVIDIA Container Toolkit is installed."
else
echo "NVIDIA Container Toolkit is not installed. Installing now..."
# Install a new GPU Docker container
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
sudo systemctl restart docker
echo "NVIDIA Container Toolkit has been installed."
fi
if [ ! -d "text-generation-webui" ]; then
echo "${BOLD}${YELLOW}Cloning Oobabooga Text generation web UI Repository...${RESET}"
git clone https://github.com/oobabooga/text-generation-webui
fi
echo "${BOLD}${GREEN}Running Docker install...${RESET}"
echo "${BOLD}${YELLOW}Starting Docker Compose...${RESET}"
if [[ "$AGIXT_AUTO_UPDATE" == "true" ]]; then
docker-compose -f docker-compose-local-nvidia-sd.yml pull
fi
docker-compose -f docker-compose-local-nvidia-sd.yml up
}
# Function to perform the local install
local_install() {
sed -i '/^AGIXT_URI=/d' .env
echo "AGIXT_URI=http://localhost:7437" >> .env
sed -i '/^TEXTGEN_URI=/d' .env
echo "TEXTGEN_URI=http://localhost:5000" >> .env
source .env
echo "${BOLD}${YELLOW}Updating the repository...${RESET}"
if [[ "$AGIXT_AUTO_UPDATE" == "true" ]]; then
echo "${BOLD}${YELLOW}Upgrading pip...${RESET}"
pip install --upgrade pip
sleep 1
echo "${BOLD}${YELLOW}Checking for updates...${RESET}"
git pull
echo "${BOLD}${YELLOW}Installing requirements...${RESET}"
pip install -r static-requirements.txt --upgrade
pip install -r requirements.txt --upgrade
sleep 1
if [ ! -d "streamlit" ]; then
echo "${BOLD}${YELLOW}Installing Streamlit dependencies...${RESET}"
git clone https://github.com/AGiXT/streamlit
fi
cd streamlit
git pull
pip install -r requirements.txt --upgrade
cd ..
fi
echo "${BOLD}${GREEN}Running local install...${RESET}"
git pull
sleep 1
# Check if the directory exists
if [ ! -d "agixt/extensions" ]; then
echo "${BOLD}${YELLOW}Upgrading pip...${RESET}"
pip install --upgrade pip
sleep 1
echo "${BOLD}${YELLOW}Installing requirements...${RESET}"
pip install -r static-requirements.txt --upgrade
pip install -r requirements.txt --upgrade
sleep 1
echo "${BOLD}${YELLOW}Installing Playwright dependencies...${RESET}"
playwright install --with-deps
sleep 1
fi
if [ ! -d "streamlit" ]; then
echo "${BOLD}${YELLOW}Installing Streamlit dependencies...${RESET}"
git clone https://github.com/AGiXT/streamlit
cd streamlit
pip install -r requirements.txt --upgrade
sleep 1
fi
echo "${BOLD}${YELLOW}Running AGiXT Core...${RESET}"
cd agixt && ./launch-backend.sh &
echo "${BOLD}${YELLOW}Please wait...${RESET}"
sleep 10
echo "${BOLD}${YELLOW}Running Streamlit Web UI...${RESET}"
cd streamlit && streamlit run Main.py
}
toggle_updates () {
if [[ "$AGIXT_AUTO_UPDATE" == "true" ]]; then
sed -i '/^AGIXT_AUTO_UPDATE=/d' .env
echo "AGIXT_AUTO_UPDATE=false" >> .env
source .env
echo "${BOLD}${YELLOW}Automatic Updates have been disabled.${RESET}"
else
sed -i '/^AGIXT_AUTO_UPDATE=/d' .env
echo "AGIXT_AUTO_UPDATE=true" >> .env
source .env
echo "${BOLD}${YELLOW}Automatic Updates have been enabled.${RESET}"
fi
}
environment_setup
if [[ -z "${WORKING_DIRECTORY}" ]]; then
echo "WORKING_DIRECTORY=${PWD}/agixt/WORKSPACE" >> .env
fi
# Main loop to display the menu and handle user input
while true; do
display_menu
read -p "${BOLD}${CYAN}Enter your choice:${RESET} " choice
case "$choice" in
1)
docker_install
break
;;
2)
docker_install_local_nvidia
break
;;
3)
docker_install_local_nvidia_sd
break
;;
4)
docker_install_dev
break
;;
5)
backend_only
break
;;
6)
local_install
break
;;
7)
toggle_updates
sleep 2
;;
*)
echo "${BOLD}${MAGENTA}Thank you for using AGiXT Installer. Goodbye!${RESET}"
break
;;
esac
done