DocsGPT/setup.sh

85 lines
2.7 KiB
Bash
Raw Normal View History

#!/bin/bash
2023-10-01 16:20:47 +00:00
# Function to prompt the user for their choice
prompt_user() {
echo "Do you want to:"
echo "1. Download the language model locally (12GB)"
echo "2. Use the OpenAI API"
read -p "Enter your choice (1/2): " choice
}
# Function to handle the choice to download the model locally
download_locally() {
echo "LLM_NAME=llama.cpp" > .env
echo "VITE_API_STREAMING=true" >> .env
echo "EMBEDDINGS_NAME=huggingface_sentence-transformers/all-mpnet-base-v2" >> .env
echo "The .env file has been created with LLM_NAME set to llama.cpp."
# Creating the directory if it does not exist
mkdir -p models
# Downloading the model to the specific directory
echo "Downloading the model..."
# check if docsgpt-7b-f16.gguf does not exist
if [ ! -f models/docsgpt-7b-f16.gguf ]; then
echo "Downloading the model..."
2023-10-01 18:55:11 +00:00
wget -P models https://d3dg1063dc54p9.cloudfront.net/models/docsgpt-7b-f16.gguf
2023-10-01 16:20:47 +00:00
echo "Model downloaded to models directory."
else
echo "Model already exists."
fi
docker-compose -f docker-compose-local.yaml build && docker-compose -f docker-compose-local.yaml up -d
2023-11-21 10:16:54 +00:00
#python -m venv venv
#source venv/bin/activate
2023-11-21 10:16:10 +00:00
pip install -r application/requirements.txt
pip install llama-cpp-python
pip install sentence-transformers
2023-10-01 19:05:13 +00:00
export LLM_NAME=llama.cpp
export EMBEDDINGS_NAME=huggingface_sentence-transformers/all-mpnet-base-v2
2023-10-01 16:20:47 +00:00
export FLASK_APP=application/app.py
export FLASK_DEBUG=true
2023-10-01 18:55:11 +00:00
export CELERY_BROKER_URL=redis://localhost:6379/0
export CELERY_RESULT_BACKEND=redis://localhost:6379/1
2023-10-01 16:20:47 +00:00
echo "The application is now running on http://localhost:5173"
echo "You can stop the application by running the following command:"
echo "Ctrl + C and then"
2023-10-01 19:05:13 +00:00
echo "Then pkill -f 'flask run' and then"
2023-10-01 16:20:47 +00:00
echo "docker-compose down"
2023-10-01 18:16:13 +00:00
flask run --host=0.0.0.0 --port=7091 &
celery -A application.app.celery worker -l INFO
2023-10-01 16:20:47 +00:00
}
# Function to handle the choice to use the OpenAI API
use_openai() {
read -p "Please enter your OpenAI API key: " api_key
echo "API_KEY=$api_key" > .env
echo "LLM_NAME=openai" >> .env
echo "VITE_API_STREAMING=true" >> .env
echo "The .env file has been created with API_KEY set to your provided key."
docker-compose build && docker-compose up -d
2023-10-03 19:18:15 +00:00
echo "The application will run on http://localhost:5173"
2023-10-01 16:20:47 +00:00
echo "You can stop the application by running the following command:"
echo "docker-compose down"
}
# Prompt the user for their choice
prompt_user
# Handle the user's choice
case $choice in
1)
download_locally
;;
2)
use_openai
;;
*)
echo "Invalid choice. Please choose either 1 or 2."
;;
esac