-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·113 lines (96 loc) · 5.15 KB
/
install.sh
File metadata and controls
executable file
·113 lines (96 loc) · 5.15 KB
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
#!/bin/bash
# =============================================================================
# CloverDX LLM Chat - Installation Script
# =============================================================================
# This script sets up the Python virtual environment and installs dependencies.
#
# Usage:
# ./install.sh # Install with default Python
# ./install.sh python3.11 # Install with specific Python version
# =============================================================================
set -e # Exit on error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Configuration
VENV_DIR="venv"
REQUIREMENTS_FILE="requirements.txt"
PYTHON_CMD="${1:-python3}"
echo -e "${GREEN}"
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ CloverDX LLM Chat - Installation Script ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo -e "${NC}"
# Check if Python is available
echo -e "${YELLOW}Checking Python installation...${NC}"
if ! command -v "$PYTHON_CMD" &> /dev/null; then
echo -e "${RED}Error: $PYTHON_CMD not found. Please install Python 3.9+ first.${NC}"
exit 1
fi
# Check Python version
PYTHON_VERSION=$("$PYTHON_CMD" -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
PYTHON_MAJOR=$("$PYTHON_CMD" -c 'import sys; print(sys.version_info.major)')
PYTHON_MINOR=$("$PYTHON_CMD" -c 'import sys; print(sys.version_info.minor)')
echo -e "Found Python ${GREEN}$PYTHON_VERSION${NC}"
if [ "$PYTHON_MAJOR" -lt 3 ] || ([ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -lt 9 ]); then
echo -e "${RED}Error: Python 3.9 or higher is required. Found $PYTHON_VERSION${NC}"
exit 1
fi
# Check if requirements.txt exists
if [ ! -f "$REQUIREMENTS_FILE" ]; then
echo -e "${RED}Error: $REQUIREMENTS_FILE not found. Please run this script from the project root.${NC}"
exit 1
fi
# Create virtual environment if it doesn't exist
if [ -d "$VENV_DIR" ]; then
echo -e "${YELLOW}Virtual environment already exists at ./$VENV_DIR${NC}"
read -p "Do you want to recreate it? (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo -e "${YELLOW}Removing existing virtual environment...${NC}"
rm -rf "$VENV_DIR"
echo -e "${GREEN}Creating new virtual environment...${NC}"
"$PYTHON_CMD" -m venv "$VENV_DIR"
fi
else
echo -e "${GREEN}Creating virtual environment...${NC}"
"$PYTHON_CMD" -m venv "$VENV_DIR"
fi
# Activate virtual environment
echo -e "${GREEN}Activating virtual environment...${NC}"
source "$VENV_DIR/bin/activate"
# Upgrade pip
echo -e "${GREEN}Upgrading pip...${NC}"
pip install --upgrade pip
# Install dependencies
echo -e "${GREEN}Installing dependencies from $REQUIREMENTS_FILE...${NC}"
pip install -r "$REQUIREMENTS_FILE"
# Check if CUDA is available (optional)
echo -e "${YELLOW}Checking GPU availability...${NC}"
python -c "import torch; print(f'PyTorch version: {torch.__version__}'); print(f'CUDA available: {torch.cuda.is_available()}'); print(f'MPS available: {torch.backends.mps.is_available()}')" 2>/dev/null || echo "Could not check GPU (torch may still be installing)"
# Create .env file if it doesn't exist
if [ ! -f ".env" ] && [ -f ".env.example" ]; then
echo -e "${GREEN}Creating .env file from .env.example...${NC}"
cp .env.example .env
echo -e "${YELLOW}Please edit .env to configure your settings.${NC}"
fi
# Create data directory
mkdir -p data/conversations
echo -e "${GREEN}"
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ Installation Complete! ║"
echo "╠══════════════════════════════════════════════════════════════╣"
echo "║ ║"
echo "║ To activate the environment: ║"
echo "║ source venv/bin/activate ║"
echo "║ ║"
echo "║ To configure settings: ║"
echo "║ Edit .env file ║"
echo "║ ║"
echo "║ To start the server: ║"
echo "║ python run.py ║"
echo "║ ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo -e "${NC}"