-
Notifications
You must be signed in to change notification settings - Fork 250
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·98 lines (84 loc) · 3.01 KB
/
install.sh
File metadata and controls
executable file
·98 lines (84 loc) · 3.01 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
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
# Function to print error messages
error_exit() {
echo "Error: $1" >&2
exit 1
}
# 1. Check for existing Ollama installation
if ! command -v ollama &> /dev/null
then
echo "Ollama not found. Installing Ollama..."
curl -fsSL https://ollama.com/install.sh | sh || error_exit "Ollama installation failed."
echo "Ollama installed successfully."
else
echo "Ollama is already installed."
fi
# 2. Install Python dependencies
echo "Installing Python dependencies..."
if ! command -v pip &> /dev/null && ! command -v pip3 &> /dev/null; then
echo "pip is not installed. Please install it using your system's package manager."
echo "For example, on Debian/Ubuntu, you can use: sudo apt install python3-pip"
error_exit "pip not found."
fi
# Try pip3 first, then pip
PIP_COMMAND=""
if command -v pip3 &> /dev/null; then
PIP_COMMAND="pip3"
elif command -v pip &> /dev/null; then
PIP_COMMAND="pip"
else
# This case should ideally be caught by the check above, but as a fallback:
echo "pip is not installed. Please install it using your system's package manager."
echo "For example, on Debian/Ubuntu, you can use: sudo apt install python3-pip"
error_exit "pip not found."
fi
if [ -f "requirements.txt" ]; then
$PIP_COMMAND install -r requirements.txt || error_exit "Failed to install Python dependencies from requirements.txt."
echo "Python dependencies installed successfully."
else
echo "requirements.txt not found. Skipping Python dependency installation."
fi
# 3. Set Environment Variables
echo "Setting environment variables in .env file..."
ENV_FILE=".env"
OLLAMA_API_URL="OLLAMA_API_URL=http://localhost:11434"
MODEL="MODEL=huihui-ai/Qwen3-1.7B-abliterated"
# Create .env file if it doesn't exist
touch $ENV_FILE
# Update or add OLLAMA_API_URL
if grep -q "^OLLAMA_API_URL=" "$ENV_FILE"; then
sed -i "s|^OLLAMA_API_URL=.*|$OLLAMA_API_URL|" "$ENV_FILE"
else
echo "$OLLAMA_API_URL" >> "$ENV_FILE"
fi
# Update or add MODEL
if grep -q "^MODEL=" "$ENV_FILE"; then
sed -i "s|^MODEL=.*|$MODEL|" "$ENV_FILE"
else
echo "$MODEL" >> "$ENV_FILE"
fi
echo ".env file updated successfully."
# 4. Pull the Ollama model
echo "Pulling Ollama model: huihui-ai/Qwen3-1.7B-abliterated..."
if command -v ollama &> /dev/null; then
ollama pull huihui-ai/Qwen3-1.7B-abliterated || error_exit "Failed to pull Ollama model."
echo "Ollama model pulled successfully."
else
error_exit "Ollama command not found. Cannot pull model."
fi
# 5. Provide Execution Instructions
echo ""
echo "Installation and setup complete!"
echo "To activate the environment variables, run:"
echo " source .env"
echo ""
echo "Then, you can run the application, for example:"
echo " streamlit run app.py"
echo ""
# 6. Make the script executable (This step will be done by the user or a separate command)
# However, we can inform the user.
echo "Note: If you haven't already, make this script executable by running:"
echo " chmod +x install.sh"
exit 0