-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
289 lines (132 loc) · 10.6 KB
/
setup.ps1
File metadata and controls
289 lines (132 loc) · 10.6 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
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
# Babocument Server Setup Script# Babocument Server Setup Script
# This script automates the initial setup of the Babocument server# This script automates the initial setup of the Babocument server
Write-Host "==================================" -ForegroundColor CyanWrite-Host "==================================" -ForegroundColor Cyan
Write-Host "Babocument Server Setup" -ForegroundColor CyanWrite-Host "Babocument Server Setup" -ForegroundColor Cyan
Write-Host "==================================" -ForegroundColor CyanWrite-Host "==================================" -ForegroundColor Cyan
Write-Host ""Write-Host ""
# Check Python installation# Check Python installation
Write-Host "Checking Python installation..." -ForegroundColor YellowWrite-Host "Checking Python installation..." -ForegroundColor Yellow
try {try {
$pythonVersion = python --version 2>&1 $pythonVersion = python --version 2>&1
Write-Host "Success $pythonVersion" -ForegroundColor Green Write-Host "✓ $pythonVersion" -ForegroundColor Green
}}
catch {catch {
Write-Host "X Python not found. Please install Python 3.11+ from https://python.org" -ForegroundColor Red Write-Host "✗ Python not found. Please install Python 3.11+ from https://python.org" -ForegroundColor Red
exit 1 exit 1
}}
# Check if we're in the server directory# Check if we're in the server directory
if (-not (Test-Path "app/main.py")) {if (-not (Test-Path "app/main.py")) {
Write-Host "X Please run this script from the server directory" -ForegroundColor Red Write-Host "✗ Please run this script from the server directory" -ForegroundColor Red
exit 1 exit 1
}}
# Create virtual environment# Create virtual environment
Write-Host ""Write-Host ""
Write-Host "Creating virtual environment..." -ForegroundColor YellowWrite-Host "Creating virtual environment..." -ForegroundColor Yellow
if (Test-Path "venv") {if (Test-Path "venv") {
Write-Host "Success Virtual environment already exists" -ForegroundColor Green Write-Host "✓ Virtual environment already exists" -ForegroundColor Green
}}
else {else {
python -m venv venv python -m venv venv
Write-Host "Success Virtual environment created" -ForegroundColor Green Write-Host "✓ Virtual environment created" -ForegroundColor Green
}}
# Activate virtual environment# Activate virtual environment
Write-Host ""Write-Host ""
Write-Host "Activating virtual environment..." -ForegroundColor YellowWrite-Host "Activating virtual environment..." -ForegroundColor Yellow
& ".\venv\Scripts\Activate.ps1"& ".\venv\Scripts\Activate.ps1"
# Upgrade pip# Upgrade pip
Write-Host ""Write-Host ""
Write-Host "Upgrading pip..." -ForegroundColor YellowWrite-Host "Upgrading pip..." -ForegroundColor Yellow
python -m pip install --upgrade pip --quietpython -m pip install --upgrade pip --quiet
# Install dependencies# Install dependencies
Write-Host ""Write-Host ""
Write-Host "Installing dependencies (this may take a few minutes)..." -ForegroundColor YellowWrite-Host "Installing dependencies (this may take a few minutes)..." -ForegroundColor Yellow
pip install -r requirements.txt --quietpip install -r requirements.txt --quiet
Write-Host "Success Dependencies installed" -ForegroundColor GreenWrite-Host "✓ Dependencies installed" -ForegroundColor Green
# Create data directories# Create data directories
Write-Host ""Write-Host ""
Write-Host "Creating data directories..." -ForegroundColor YellowWrite-Host "Creating data directories..." -ForegroundColor Yellow
New-Item -ItemType Directory -Force -Path "data/chroma" | Out-NullNew-Item -ItemType Directory -Force -Path "data/chroma" | Out-Null
Write-Host "Success Data directories created" -ForegroundColor GreenWrite-Host "✓ Data directories created" -ForegroundColor Green
# Create models directory if it doesn't exist# Create models directory if it doesn't exist
Write-Host ""Write-Host ""
Write-Host "Checking model storage directory..." -ForegroundColor YellowWrite-Host "Checking model storage directory..." -ForegroundColor Yellow
if (-not (Test-Path "d:\models")) {if (-not (Test-Path "d:\models")) {
Write-Host "Creating d:\models directory..." -ForegroundColor Yellow Write-Host "Creating d:\models directory..." -ForegroundColor Yellow
try { try {
New-Item -ItemType Directory -Force -Path "d:\models" | Out-Null New-Item -ItemType Directory -Force -Path "d:\models" | Out-Null
Write-Host "Success Model storage directory created at d:\models" -ForegroundColor Green Write-Host "✓ Model storage directory created at d:\models" -ForegroundColor Green
} }
catch { catch {
Write-Host "Warning Could not create d:\models. You may need to create it manually or update .env" -ForegroundColor Yellow Write-Host "⚠ Could not create d:\models. You may need to create it manually or update .env" -ForegroundColor Yellow
} }
}}
else {else {
Write-Host "Success Model storage directory exists at d:\models" -ForegroundColor Green Write-Host "✓ Model storage directory exists at d:\models" -ForegroundColor Green
}}
# Check if .env exists# Check if .env exists
Write-Host ""Write-Host ""
Write-Host "Checking configuration..." -ForegroundColor YellowWrite-Host "Checking configuration..." -ForegroundColor Yellow
if (Test-Path ".env") {if (Test-Path ".env") {
Write-Host "Success .env file already exists" -ForegroundColor Green Write-Host "✓ .env file already exists" -ForegroundColor Green
}}
else {else {
Write-Host "X .env file not found - using .env.example as template" -ForegroundColor Yellow Write-Host "✗ .env file not found - using .env.example as template" -ForegroundColor Yellow
}}
# Check Ollama installation# Check Ollama installation
Write-Host ""Write-Host ""
Write-Host "Checking Ollama installation..." -ForegroundColor YellowWrite-Host "Checking Ollama installation..." -ForegroundColor Yellow
try {try {
$ollamaVersion = ollama --version 2>&1 $ollamaVersion = ollama --version 2>&1
Write-Host "Success Ollama is installed" -ForegroundColor Green Write-Host "✓ Ollama is installed" -ForegroundColor Green
# Check if Ollama is running # Check if Ollama is running
try { try {
$response = Invoke-WebRequest -Uri "http://localhost:11434/api/tags" -Method Get -TimeoutSec 2 2>&1 $response = Invoke-WebRequest -Uri "http://localhost:11434/api/tags" -Method Get -TimeoutSec 2 2>&1
Write-Host "Success Ollama is running" -ForegroundColor Green Write-Host "✓ Ollama is running" -ForegroundColor Green
# Check for models # Check for models
Write-Host "" Write-Host ""
Write-Host "Checking downloaded models..." -ForegroundColor Yellow Write-Host "Checking downloaded models..." -ForegroundColor Yellow
ollama list ollama list
}
catch { }
Write-Host "Warning Ollama is not running. Start it with: ollama serve" -ForegroundColor Yellow catch {
} Write-Host "⚠ Ollama is not running. Start it with: ollama serve" -ForegroundColor Yellow
} }
catch {}
Write-Host "X Ollama not found. Install from: https://ollama.com/download" -ForegroundColor Redcatch {
Write-Host " Or use: winget install Ollama.Ollama" -ForegroundColor Yellow Write-Host "✗ Ollama not found. Install from: https://ollama.com/download" -ForegroundColor Red
} Write-Host " Or use: winget install Ollama.Ollama" -ForegroundColor Yellow
}
# Check Redis installation
Write-Host ""# Check Redis installation
Write-Host "Checking Redis..." -ForegroundColor YellowWrite-Host ""
try {Write-Host "Checking Redis..." -ForegroundColor Yellow
$dockerPs = docker ps --filter "name=babocument-redis" --format "{{.Names}}" 2>&1try {
if ($dockerPs -match "babocument-redis") { $dockerPs = docker ps --filter "name=babocument-redis" --format "{{.Names}}" 2>&1
Write-Host "Success Redis container is running" -ForegroundColor Green if ($dockerPs -match "babocument-redis") {
} Write-Host "✓ Redis container is running" -ForegroundColor Green
else { }
Write-Host "Warning Redis container not found" -ForegroundColor Yellow else {
Write-Host " Start with: docker run -d -p 6379:6379 --name babocument-redis redis:7-alpine" -ForegroundColor Yellow Write-Host "⚠ Redis container not found" -ForegroundColor Yellow
} Write-Host " Start with: docker run -d -p 6379:6379 --name babocument-redis redis:7-alpine" -ForegroundColor Yellow
} }
catch {}
Write-Host "Warning Docker not found or not running" -ForegroundColor Yellowcatch {
Write-Host " Install Docker Desktop or use Windows Redis port" -ForegroundColor Yellow Write-Host "⚠ Docker not found or not running" -ForegroundColor Yellow
} Write-Host " Install Docker Desktop or use Windows Redis port" -ForegroundColor Yellow
}
# Setup complete
Write-Host ""# Setup complete
Write-Host "==================================" -ForegroundColor CyanWrite-Host ""
Write-Host "Setup Complete!" -ForegroundColor GreenWrite-Host "==================================" -ForegroundColor Cyan
Write-Host "==================================" -ForegroundColor CyanWrite-Host "Setup Complete!" -ForegroundColor Green
Write-Host ""Write-Host "==================================" -ForegroundColor Cyan
Write-Host "Next steps:" -ForegroundColor YellowWrite-Host ""
Write-Host "1. Ensure Ollama is running: ollama serve" -ForegroundColor WhiteWrite-Host "Next steps:" -ForegroundColor Yellow
Write-Host "2. Download models: ollama pull llama3.2:3b" -ForegroundColor WhiteWrite-Host "1. Ensure Ollama is running: " -NoNewline; Write-Host "ollama serve" -ForegroundColor White
Write-Host "3. Start Redis: docker run -d -p 6379:6379 --name babocument-redis redis:7-alpine" -ForegroundColor WhiteWrite-Host "2. Download models: " -NoNewline; Write-Host "ollama pull llama3.2:3b" -ForegroundColor White
Write-Host "4. Run the server: python app/main.py" -ForegroundColor WhiteWrite-Host "3. Start Redis: " -NoNewline; Write-Host "docker run -d -p 6379:6379 --name babocument-redis redis:7-alpine" -ForegroundColor White
Write-Host "5. View API docs: http://localhost:8000/docs" -ForegroundColor WhiteWrite-Host "4. Run the server: " -NoNewline; Write-Host "python app/main.py" -ForegroundColor White
Write-Host ""Write-Host "5. View API docs: " -NoNewline; Write-Host "http://localhost:8000/docs" -ForegroundColor White
Write-Host "For detailed instructions, see SETUP.md" -ForegroundColor CyanWrite-Host ""
Write-Host ""Write-Host "For detailed instructions, see SETUP.md" -ForegroundColor Cyan
Write-Host ""