forked from zxypro1/algolocal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-local.bat
More file actions
191 lines (174 loc) · 7.1 KB
/
Copy pathstart-local.bat
File metadata and controls
191 lines (174 loc) · 7.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
@echo off
echo Offline LeetCode Practice System - Local Startup
echo ===================================================
echo.
REM Support a non-interactive mode for automation/CI
REM Usage: start-local.bat --yes OR set START_LOCAL_NONINTERACTIVE=1 && start-local.bat
set NONINTERACTIVE=0
if /I "%1"=="--yes" set NONINTERACTIVE=1
if /I "%1"=="-y" set NONINTERACTIVE=1
if defined START_LOCAL_NONINTERACTIVE (
if "%START_LOCAL_NONINTERACTIVE%"=="1" set NONINTERACTIVE=1
)
REM First-run check: interactive AI configuration for .env (or copy from .env.example in non-interactive)
if not exist ".env" (
if "%NONINTERACTIVE%"=="1" (
echo No .env file found - non-interactive mode enabled.
if exist ".env.example" (
copy /Y ".env.example" ".env" >nul
echo .env created from .env.example (non-interactive). Edit .env to change settings.
) else (
echo No .env.example found - creating minimal .env with defaults and empty keys.
>.env echo # Generated by start-local.bat (non-interactive)
>>.env echo # AI provider configuration
>>.env echo OPENAI_MODEL=gpt-4-turbo
>>.env echo OPENAI_API_KEY=
>>.env echo DEEPSEEK_MODEL=deepseek-chat
>>.env echo DEEPSEEK_API_KEY=
>>.env echo QWEN_MODEL=qwen-turbo
>>.env echo QWEN_API_KEY=
>>.env echo CLAUDE_MODEL=claude-3-haiku-20240307
>>.env echo CLAUDE_API_KEY=
>>.env echo OLLAMA_ENDPOINT=http://localhost:11434
>>.env echo OLLAMA_MODEL=llama3
>>.env echo # Note: To change AI configuration later, edit the .env file.
)
) else (
echo No .env file found - first time startup.
set /p enable_ai="Would you like to enable AI features? [Y/n]: "
if "%enable_ai%"=="" set enable_ai=Y
for /f "tokens=*" %%A in ('echo %enable_ai%') do set enable_ai=%%A
if /I "%enable_ai%"=="Y" (
echo Creating .env and configuring AI providers...
>.env echo # Generated by start-local.bat
>>.env echo # AI provider configuration
REM OpenAI
set /p use_openai="Enable OpenAI? [Y/n]: "
if "%use_openai%"=="" set use_openai=Y
if /I "%use_openai%"=="Y" (
set /p openai_model="OpenAI model (default: gpt-4-turbo): "
if "%openai_model%"=="" set openai_model=gpt-4-turbo
set /p openai_key="OpenAI API key (paste and press Enter): "
>>.env echo OPENAI_MODEL=%openai_model%
>>.env echo OPENAI_API_KEY=%openai_key%
) else (
>>.env echo OPENAI_API_KEY=
)
REM DeepSeek
set /p use_deepseek="Enable DeepSeek? [y/N]: "
if "%use_deepseek%"=="" set use_deepseek=N
if /I "%use_deepseek%"=="Y" (
set /p deepseek_model="DeepSeek model (default: deepseek-chat): "
if "%deepseek_model%"=="" set deepseek_model=deepseek-chat
set /p deepseek_key="DeepSeek API key (paste and press Enter): "
>>.env echo DEEPSEEK_MODEL=%deepseek_model%
>>.env echo DEEPSEEK_API_KEY=%deepseek_key%
) else (
>>.env echo DEEPSEEK_API_KEY=
)
REM Qwen
set /p use_qwen="Enable Qwen? [y/N]: "
if "%use_qwen%"=="" set use_qwen=N
if /I "%use_qwen%"=="Y" (
set /p qwen_model="Qwen model (default: qwen-turbo): "
if "%qwen_model%"=="" set qwen_model=qwen-turbo
set /p qwen_key="Qwen API key (paste and press Enter): "
>>.env echo QWEN_MODEL=%qwen_model%
>>.env echo QWEN_API_KEY=%qwen_key%
) else (
>>.env echo QWEN_API_KEY=
)
REM Claude
set /p use_claude="Enable Claude (Anthropic)? [y/N]: "
if "%use_claude%"=="" set use_claude=N
if /I "%use_claude%"=="Y" (
set /p claude_model="Claude model (default: claude-3-haiku-20240307): "
if "%claude_model%"=="" set claude_model=claude-3-haiku-20240307
set /p claude_key="Claude API key (paste and press Enter): "
>>.env echo CLAUDE_MODEL=%claude_model%
>>.env echo CLAUDE_API_KEY=%claude_key%
) else (
>>.env echo CLAUDE_API_KEY=
)
REM Ollama (endpoint + model)
set /p use_ollama="Enable Ollama? [y/N]: "
if "%use_ollama%"=="" set use_ollama=N
if /I "%use_ollama%"=="Y" (
set /p ollama_endpoint="Ollama endpoint (default: http://localhost:11434): "
if "%ollama_endpoint%"=="" set ollama_endpoint=http://localhost:11434
set /p ollama_model="Ollama model (default: llama3): "
if "%ollama_model%"=="" set ollama_model=llama3
>>.env echo OLLAMA_ENDPOINT=%ollama_endpoint%
>>.env echo OLLAMA_MODEL=%ollama_model%
) else (
>>.env echo OLLAMA_ENDPOINT=
>>.env echo OLLAMA_MODEL=
)
>>.env echo.
>>.env echo # Note: To change AI configuration later, edit the .env file.
echo AI configuration complete. .env created.
) else (
echo AI features will be disabled. Creating empty .env file.
>.env echo # Generated by start-local.bat - AI disabled
>>.env echo # To enable AI later, edit this .env and add API keys and models.
)
)
) else (
echo .env exists - skipping AI configuration step. If you want to change AI settings, edit the .env file.
)
REM Check if Node.js is installed
node --version >nul 2>&1
if %errorlevel% neq 0 (
echo Error: Node.js not found
echo Please install Node.js: https://nodejs.org
pause
exit /b 1
)
echo Node.js installed:
node --version
REM Check if npm is installed
where npm >nul 2>&1
if %errorlevel% neq 0 (
echo Error: npm not found
echo Please install npm
pause
exit /b 1
)
echo npm installed:
npm --version
REM Check if dependencies are installed
if not exist "node_modules\" (
echo Installing dependencies...
npm install
if %errorlevel% neq 0 (
echo Failed to install dependencies
pause
exit /b 1
)
echo Dependencies installed successfully
)
REM Check if project is built
if not exist ".next\" (
echo Building application...
npm run build
if %errorlevel% neq 0 (
echo Build failed
pause
exit /b 1
)
echo Build completed successfully
)
echo.
echo Starting application...
echo URL: http://localhost:3000
echo.
echo Usage Instructions:
echo - Open http://localhost:3000 in your browser
echo - Fully local execution, no external network required
echo - Press Ctrl+C to stop the server
echo - To add problems: Edit public/problems.json (see MODIFY-PROBLEMS-GUIDE.md)
echo - To change AI settings: Edit the .env file
echo - Changes take effect immediately without rebuilding!
echo.
REM Start the application
npm start