-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_docuchat.bat
More file actions
369 lines (331 loc) · 12.1 KB
/
Copy pathsetup_docuchat.bat
File metadata and controls
369 lines (331 loc) · 12.1 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
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
@echo off
setlocal enabledelayedexpansion
REM =============================================================================
REM DocuChat Agent - Windows Setup Script
REM =============================================================================
REM This script provides Windows setup for DocuChat Agent.
REM For full functionality, we recommend using WSL2 with the bash script.
REM
REM Usage:
REM setup_docuchat.bat [OPTIONS]
REM
REM Options:
REM /auto Run automated setup
REM /help Show this help message
REM
REM Requirements:
REM - Windows 10/11 with WSL2 enabled
REM - Docker Desktop for Windows
REM - Python 3.10+ installed
REM =============================================================================
set "SCRIPT_VERSION=1.0.0"
set "SCRIPT_NAME=DocuChat Windows Setup"
REM Colors (limited on Windows CMD)
set "RED=[91m"
set "GREEN=[92m"
set "YELLOW=[93m"
set "BLUE=[94m"
set "CYAN=[96m"
set "WHITE=[97m"
set "NC=[0m"
REM Unicode symbols (may not display correctly on all systems)
set "CHECK=✓"
set "CROSS=✗"
set "INFO=i"
set "WARN=!"
echo.
echo %WHITE%╔══════════════════════════════════════════════════════════════════════════════╗%NC%
echo %WHITE%║ ║%NC%
echo %WHITE%║ ██████╗ ██████╗ ██████╗██╗ ██╗ ██████╗██╗ ██╗ █████╗ ████████╗ ║%NC%
echo %WHITE%║ ██╔══██╗██╔═══██╗██╔════╝██║ ██║██╔════╝██║ ██║██╔══██╗╚══██╔══╝ ║%NC%
echo %WHITE%║ ██║ ██║██║ ██║██║ ██║ ██║██║ ███████║███████║ ██║ ║%NC%
echo %WHITE%║ ██║ ██║██║ ██║██║ ██║ ██║██║ ██╔══██║██╔══██║ ██║ ║%NC%
echo %WHITE%║ ██████╔╝╚██████╔╝╚██████╗╚██████╔╝╚██████╗██║ ██║██║ ██║ ██║ ║%NC%
echo %WHITE%║ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ║%NC%
echo %WHITE%║ WINDOWS SETUP - Installation Helper ║%NC%
echo %WHITE%╚══════════════════════════════════════════════════════════════════════════════╝%NC%
echo.
REM Parse command line arguments
set "AUTO_MODE=false"
:parse_args
if "%~1"=="/auto" (
set "AUTO_MODE=true"
shift
goto parse_args
)
if "%~1"=="/help" (
goto show_help
)
if "%~1"=="/?" (
goto show_help
)
if not "%~1"=="" (
echo %RED%%CROSS% Unknown option: %1%NC%
goto show_help
)
echo %CYAN%Welcome to DocuChat Agent Windows Setup!%NC%
echo.
echo %YELLOW%For the best experience, we recommend using WSL2 with our Linux setup script.%NC%
echo This Windows script provides basic setup and guidance.
echo.
REM Check for WSL2
echo %BLUE%%INFO% Checking for WSL2...%NC%
wsl --version >nul 2>&1
if %errorlevel% equ 0 (
echo %GREEN%%CHECK% WSL2 is available%NC%
echo.
echo %CYAN%Would you like to run the full Linux setup script in WSL2? [Y/n]%NC%
if "%AUTO_MODE%"=="false" (
set /p "response="
if /i "!response!"=="n" goto windows_setup
if /i "!response!"=="no" goto windows_setup
)
echo %BLUE%%INFO% Running Linux setup script in WSL2...%NC%
wsl bash -c "cd /mnt/c$(echo '%cd%' | tr '\' '/' | cut -c3-) && ./setup_docuchat.sh"
if !errorlevel! equ 0 (
echo.
echo %GREEN%%CHECK% Setup completed successfully in WSL2!%NC%
goto completion
) else (
echo %RED%%CROSS% WSL2 setup failed. Falling back to Windows setup.%NC%
goto windows_setup
)
) else (
echo %YELLOW%%WARN% WSL2 not found. Proceeding with Windows setup.%NC%
goto windows_setup
)
:windows_setup
echo.
echo %BLUE%%INFO% Starting Windows setup...%NC%
echo.
REM Check Python
echo %BLUE%%INFO% Checking Python installation...%NC%
python --version >nul 2>&1
if %errorlevel% neq 0 (
echo %RED%%CROSS% Python not found. Please install Python 3.10+ from https://python.org%NC%
goto error_exit
)
for /f "tokens=2" %%i in ('python --version 2^>^&1') do set "PYTHON_VERSION=%%i"
echo %GREEN%%CHECK% Found Python %PYTHON_VERSION%%NC%
REM Check Python version (basic check)
python -c "import sys; exit(0 if sys.version_info >= (3, 10) else 1)" 2>nul
if %errorlevel% neq 0 (
echo %RED%%CROSS% Python 3.10+ required. Current version: %PYTHON_VERSION%%NC%
goto error_exit
)
REM Check Docker
echo %BLUE%%INFO% Checking Docker Desktop...%NC%
docker --version >nul 2>&1
if %errorlevel% neq 0 (
echo %RED%%CROSS% Docker Desktop not found.%NC%
echo Please install Docker Desktop from: https://www.docker.com/products/docker-desktop
echo After installation, restart this script.
goto error_exit
)
echo %GREEN%%CHECK% Docker Desktop found%NC%
REM Check if Docker is running
docker info >nul 2>&1
if %errorlevel% neq 0 (
echo %YELLOW%%WARN% Docker Desktop is not running. Please start Docker Desktop and try again.%NC%
goto error_exit
)
echo %GREEN%%CHECK% Docker Desktop is running%NC%
REM Create virtual environment
echo %BLUE%%INFO% Creating Python virtual environment...%NC%
if not exist "venv" (
python -m venv venv
if %errorlevel% neq 0 (
echo %RED%%CROSS% Failed to create virtual environment%NC%
goto error_exit
)
echo %GREEN%%CHECK% Virtual environment created%NC%
) else (
echo %GREEN%%CHECK% Virtual environment already exists%NC%
)
REM Activate virtual environment and install dependencies
echo %BLUE%%INFO% Installing Python dependencies...%NC%
call venv\Scripts\activate.bat
python -m pip install --upgrade pip
if exist "requirements.txt" (
pip install -r requirements.txt
if %errorlevel% neq 0 (
echo %RED%%CROSS% Failed to install requirements%NC%
goto error_exit
)
) else (
pip install -e .
if %errorlevel% neq 0 (
echo %RED%%CROSS% Failed to install package%NC%
goto error_exit
)
)
echo %GREEN%%CHECK% Python dependencies installed%NC%
REM Install spaCy model
echo %BLUE%%INFO% Installing spaCy language model...%NC%
python -m spacy download en_core_web_sm
if %errorlevel% neq 0 (
echo %YELLOW%%WARN% spaCy model installation failed (non-critical)%NC%
) else (
echo %GREEN%%CHECK% spaCy model installed%NC%
)
REM Setup Neo4j container
echo %BLUE%%INFO% Setting up Neo4j database container...%NC%
REM Stop existing container if running
docker stop docuchat-neo4j >nul 2>&1
docker rm docuchat-neo4j >nul 2>&1
REM Create data directories
if not exist "data\neo4j\data" mkdir "data\neo4j\data"
if not exist "data\neo4j\logs" mkdir "data\neo4j\logs"
if not exist "data\neo4j\import" mkdir "data\neo4j\import"
if not exist "data\neo4j\plugins" mkdir "data\neo4j\plugins"
REM Start Neo4j container
echo %BLUE%%INFO% Starting Neo4j container (this may take a moment)...%NC%
docker run -d ^
--name docuchat-neo4j ^
--restart unless-stopped ^
-p 7474:7474 ^
-p 7687:7687 ^
-v "%cd%\data\neo4j\data":/data ^
-v "%cd%\data\neo4j\logs":/logs ^
-v "%cd%\data\neo4j\import":/var/lib/neo4j/import ^
-v "%cd%\data\neo4j\plugins":/plugins ^
-e NEO4J_AUTH=neo4j/docuchat123 ^
-e "NEO4J_PLUGINS=[\"apoc\"]" ^
-e NEO4J_dbms_security_procedures_unrestricted=apoc.* ^
-e NEO4J_dbms_memory_heap_initial__size=1G ^
-e NEO4J_dbms_memory_heap_max__size=2G ^
neo4j:5.15-community
if %errorlevel% neq 0 (
echo %RED%%CROSS% Failed to start Neo4j container%NC%
goto error_exit
)
echo %GREEN%%CHECK% Neo4j container started%NC%
REM Wait for Neo4j to be ready
echo %BLUE%%INFO% Waiting for Neo4j to start (this may take up to 60 seconds)...%NC%
set /a "attempts=0"
:neo4j_wait
set /a "attempts+=1"
timeout /t 2 /nobreak >nul
curl -s http://localhost:7474 >nul 2>&1
if %errorlevel% equ 0 (
echo %GREEN%%CHECK% Neo4j is ready!%NC%
goto neo4j_ready
)
if %attempts% lss 30 goto neo4j_wait
echo %RED%%CROSS% Neo4j failed to start within 60 seconds%NC%
docker logs docuchat-neo4j --tail 20
goto error_exit
:neo4j_ready
REM Create other data directories
echo %BLUE%%INFO% Creating data directories...%NC%
if not exist "data\documents" mkdir "data\documents"
if not exist "data\feedback" mkdir "data\feedback"
if not exist "data\graph_db" mkdir "data\graph_db"
if not exist "data\model_cache" mkdir "data\model_cache"
if not exist "data\vector_db" mkdir "data\vector_db"
if not exist "chroma" mkdir "chroma"
REM Test DocuChat CLI
echo %BLUE%%INFO% Testing DocuChat installation...%NC%
python -m docuchat --version >nul 2>&1
if %errorlevel% neq 0 (
echo %RED%%CROSS% DocuChat CLI test failed%NC%
goto error_exit
)
python -m docuchat --version
echo %GREEN%%CHECK% DocuChat CLI is working%NC%
REM Create test document
echo %BLUE%%INFO% Creating test documents...%NC%
if not exist "test_documents" mkdir "test_documents"
(
echo # DocuChat Test Document
echo.
echo This is a sample document for testing DocuChat Agent on Windows.
echo.
echo ## Key Features
echo - Document ingestion and processing
echo - Knowledge graph creation
echo - Natural language querying
echo - Local processing for privacy
echo.
echo ## Technology Stack
echo - Python 3.10+
echo - Neo4j for graph database
echo - ChromaDB for vector storage
echo - Local LLM integration
echo.
echo This document can be used to test the ingestion pipeline.
) > "test_documents\sample.txt"
echo %GREEN%%CHECK% Test documents created%NC%
goto completion
:show_help
echo.
echo %WHITE%%SCRIPT_NAME% v%SCRIPT_VERSION%%NC%
echo.
echo %CYAN%USAGE:%NC%
echo %0 [OPTIONS]
echo.
echo %CYAN%OPTIONS:%NC%
echo /auto Run automated setup
echo /help Show this help message
echo.
echo %CYAN%REQUIREMENTS:%NC%
echo - Windows 10/11
echo - Python 3.10+ from https://python.org
echo - Docker Desktop from https://docker.com
echo - 8GB+ RAM recommended
echo - 10GB+ free disk space
echo.
echo %CYAN%RECOMMENDED:%NC%
echo For full functionality, enable WSL2 and use the Linux setup script:
echo 1. Install WSL2: wsl --install
echo 2. Restart your computer
echo 3. Run: ./setup_docuchat.sh
echo.
goto end
:completion
echo.
echo %GREEN%%CHECK% DocuChat Agent Windows setup completed!%NC%
echo.
echo %CYAN%Quick Start Guide:%NC%
echo.
echo %WHITE%1. Activate the Python environment:%NC%
echo %CYAN%venv\Scripts\activate.bat%NC%
echo.
echo %WHITE%2. Test the installation:%NC%
echo %CYAN%python -m docuchat --version%NC%
echo %CYAN%python -m docuchat status%NC%
echo.
echo %WHITE%3. Ingest some documents:%NC%
echo %CYAN%python -m docuchat ingest test_documents%NC%
echo.
echo %WHITE%4. Start chatting:%NC%
echo %CYAN%python -m docuchat chat%NC%
echo.
echo %YELLOW%Services:%NC%
echo • Neo4j Web UI: %CYAN%http://localhost:7474%NC% (neo4j/docuchat123)
echo.
echo %YELLOW%Important Notes:%NC%
echo • For Ollama LLM support, install from: https://ollama.ai
echo • For OCR support, install Tesseract: https://tesseract-ocr.github.io
echo • Consider using WSL2 for full Linux compatibility
echo.
echo %WHITE%For help and documentation:%NC%
echo %CYAN%https://github.com/your-org/docuchat-agent%NC%
echo.
goto end
:error_exit
echo.
echo %RED%%CROSS% Setup failed. Please check the error messages above.%NC%
echo.
echo %YELLOW%Common solutions:%NC%
echo • Ensure Python 3.10+ is installed from python.org
echo • Install Docker Desktop and ensure it's running
echo • Check your internet connection
echo • Run as Administrator if needed
echo.
echo %WHITE%For full support, consider using WSL2 with the Linux setup script.%NC%
echo.
exit /b 1
:end
pause
exit /b 0