-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOpenDevinWindowsInstall.ps1
More file actions
288 lines (231 loc) · 9 KB
/
Copy pathOpenDevinWindowsInstall.ps1
File metadata and controls
288 lines (231 loc) · 9 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
###############################################
# OpenDevin Windows Install #
# #
# Created for Windows 10 and 11 #
# #
# github.com/OpenDevin/OpenDevin #
# #
# github.com/risingsunomi/OpenDevinPowerShell #
###############################################
# --- helper functions ---- #
# Get-FullPath
# return full path to folder relative to powershell script
function Get-FullPath {
param (
[string]$relativePath
)
if ([System.IO.Path]::IsPathRooted($relativePath)) {
$fullPath = $relativePath
} else {
$fullPath = Join-Path -Path $PSScriptRoot -ChildPath $relativePath
}
# Escape backslashes
$escapedPath = $fullPath -replace '\\', '\\'
Write-Output $escapedPath
}
# --- script variables --- #
$defaultModel = "gpt-4o"
$pythonVersion = python --version
$envFolder = Get-FullPath -relativePath "opendevin_env"
$openDevinBase = Get-FullPath -relativePath "opendevin_env/OpenDevin"
$defaultWorkspaceDir = Get-FullPath -relativePath "opendevin_env/OpenDevin/workspace"
$defaultCache = Get-FullPath -relativePath "opendevin_env/OpenDevin/opendevin/.cache"
$configFile = Get-FullPath -relativePath "opendevin_env/OpenDevin/config.toml"
# --- script --- #
Write-Host @"
###############################################
# OpenDevin Windows Install #
# #
# Created for Windows 10 and 11 #
# #
# github.com/OpenDevin/OpenDevin #
# #
# github.com/risingsunomi/OpenDevinPowerShell #
###############################################
"@ -ForegroundColor Cyan
$confirmInstall = Read-Host "Proceed? (yes/no)"
if ($confirmInstall -ne "yes") {
Write-Host "!! Installation aborted. Exiting." -ForegroundColor Red
exit
}
#############################
# check if running as admin #
#############################
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Host "!! Please run this PowerShell script in an administrator PowerShell window to perform needed operations. Exiting." -ForegroundColor Red
exit
}
########################
# check python version #
########################
if ($pythonVersion -notmatch "Python 3\.[1-9][1-9]") {
Write-Host "!! Python version 3.11 or higher is required. Please install the correct version and try again. Exiting." -ForegroundColor Red
exit
}
##########################
# create opendevin pyenv #
##########################
Write-Host "Creating and activating a Python virtual environment called 'opendevin_env'" -ForegroundColor Green
if (Test-Path $envFolder) {
Write-Host "The 'opendevin_env' folder already exists. Skipping virtual environment creation."
} else {
python -m venv opendevin_env
}
Set-Location $envFolder
Write-Host "Activating the virtual environment" -ForegroundColor Green
.\Scripts\Activate.ps1
##########################
# clone opendevin github #
##########################
Write-Host "Cloning the OpenDevin project from github.com/OpenDevin/OpenDevin via HTTPS" -ForegroundColor Green
if (Test-Path $openDevinBase) {
Write-Host "OpenDevin project already cloned. Skipping."
} else {
git clone https://github.com/OpenDevin/OpenDevin.git
}
Set-Location OpenDevin
##############
# setup toml #
##############
Write-Host "Setting up config.toml" -ForegroundColor Green
###############
# core config #
###############
$workspaceBase = Read-Host "Enter your workspace directory (as absolute path) or press enter for default [default: $defaultWorkspaceDir]"
if($workspaceBase -eq "") {
$workspaceBase = $defaultWorkspaceDir;
} else {
$workspaceBase = Get-FullPath -relativePath $workspaceBase;
}
# create workspace folder if needed
if($null -eq $workspaceBase -or $workspaceBase -eq "") {
if (!(Test-Path -Path $workspaceBase)) {
# Create the folder if it doesn't exist
Write-Host "Creating workspace directory at $workspaceBase" -ForegroundColor DarkYellow
New-Item -ItemType Directory -Path $workspaceBase | Out-Null
}
}
$presistSandbox = Read-Host "Do you want to persist the sandbox container? [true/false] [default: false]"
try {
$presistSandbox = [System.Convert]::ToBoolean($presistSandbox)
if ($presistSandbox -eq $true) {
$sshPassword = Read-Host "Enter a password for the sandbox container"
$presistSandbox = "true"
} else {
$sshPassword = ""
$presistSandbox = "false"
}
} catch [System.FormatException] {
$presistSandbox = "false"
}
##############
# llm config #
##############
$llmModel = Read-Host "Enter your LLM Model name (see https://docs.litellm.ai/docs/providers for full list) [default: $defaultModel]"
$llmModel = ($llmModel | Where-Object { $_ -eq "" })
if ($null -eq $llmModel -or $llmModel -eq "") {
$llmModel = $defaultModel
}
$llmAPIKey = Read-Host "Enter your LLM API key, press enter if none"
$llmBaseUrl = Read-Host "Enter your LLM base URL (mostly used for local LLMs, press enter if not needed - example: http://localhost:5001/v1/)"
Write-Host "Enter your LLM Embedding Model"
Write-Host "Choices are:
- openai
- azureopenai
- Embeddings available only with OllamaEmbedding:
- llama2
- mxbai-embed-large
- nomic-embed-text
- all-minilm
- stable-code
- Leave blank to default to 'BAAI/bge-small-en-v1.5' via huggingface"
$llmEmbeddingModel = Read-Host "> "
if ($llmEmbeddingModel -eq "llama2" -or $llmEmbeddingModel -eq "mxbai-embed-large" -or $llmEmbeddingModel -eq "nomic-embed-text" -or $llmEmbeddingModel -eq "all-minilm" -or $llmEmbeddingModel -eq "stable-code") {
$llmEmbeddingBaseUrl = Read-Host "Enter the local model URL for the embedding model (will set llm.embedding_base_url)"
}
elseif ($llmEmbeddingModel -eq "azureopenai") {
$llmBaseUrl = Read-Host "Enter the Azure endpoint URL"
$llmDeploymentName = Read-Host "Enter the Azure LLM Deployment Name"
$llmApiVersion = Read-Host "Enter the Azure API Version"
} else {
$llmEmbeddingModel = "BAAI/bge-small-en-v1.5"
}
######################
# create config file #
######################
$content = @"
[core]
workspace_dir=`"$workspaceBase`"
persist_sandbox=$presistSandbox
ssh_password=`"$sshPassword`"
[llm]
model=`"$llmModel`"
api_key=`"$llmAPIKey`"
base_url=`"$llmBaseUrl`"
llm_embedding_model=`"$llmEmbeddingModel`"
embedding_base_url=`"$llmEmbeddingBaseUrl`"
embedding_deploment_name=`"$llmDeploymentName`"
api_version=`"$llmApiVersion`"
"@
Write-Host "Saving $configFile"
[System.IO.File]::WriteAllLines($configFile, $content)
#######################
# pull sandbox docker #
#######################
Write-Host "Pulling docker image ghcr.io/opendevin/sandbox" -ForegroundColor Green
docker pull ghcr.io/opendevin/sandbox
##################
# install poetry #
##################
Write-Host "Installing poetry with pip" -ForegroundColor Green
pip install poetry
###############################
# install python dependencies #
###############################
Write-Host "Starting poetry install of dependencies" -ForegroundColor Green
poetry install --without evaluation
############################
# install pre-commit hooks #
############################
Write-Host "Installing git pre-commit hooks via poetry" -ForegroundColor Green
poetry run pre-commit install --config ./dev_config/python/.pre-commit-config.yaml
####################################
# change to the frontend directory #
####################################
Write-Host "Setting up frontend" -ForegroundColor Green
Set-Location frontend
######################################
# check if npm corepack is installed #
######################################
Write-Host "Enabling corepack" -ForegroundColor Green
if (-not (Get-Command -Name "corepack" -ErrorAction SilentlyContinue)) {
# Install npm corepack globally
Write-Host "corepack not found, installing corepack via npm" -ForegroundColor DarkYellow
npm install -g corepack
}
#######################################
# enable corepack #
# (requires administrator privileges) #
#######################################
corepack enable
############################
# install NPM dependencies #
############################
# Change the execution policy to allow running npm
Write-Host "Setting ExecutionPolicy to RemoteSigned for npm install" -ForegroundColor Green
Set-ExecutionPolicy RemoteSigned -Scope Process -Force
Write-Host "Running npm install and run make-i18n" -ForegroundColor Green
npm install
npm run make-i18n
###############
# clear cache #
###############
if (Test-Path $defaultCache) {
Write-Host "Cleaning cache `"$defaultCache`"" -ForegroundColor DarkYellow
Remove-Item -LiteralPath $defaultCache -Force -Recurse
}
#######
# end #
#######
Write-Host "Installation of OpenDevin Completed" -ForegroundColor Green
Set-Location $PSScriptRoot