Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit f4aeab9

Browse files
committed
Initial Commit
1 parent c6f96c6 commit f4aeab9

File tree

3 files changed

+271
-1
lines changed

3 files changed

+271
-1
lines changed

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,35 @@
1-
# codegate
1+
# CodeGate
2+
3+
### Installation
4+
5+
#### Requirements
6+
7+
- [Docker](https://docs.docker.com/get-docker/)
8+
- [Docker Compose](https://docs.docker.com/compose/install/)
9+
- [jq](https://stedolan.github.io/jq/download/)
10+
- [vscode](https://code.visualstudio.com/download)
11+
12+
#### Steps
13+
14+
Download the installation script docker-compose.yml
15+
16+
Run the installation script
17+
18+
```bash
19+
chmod +x install.sh && ./install.sh
20+
```
21+
22+
The script will download the Continue VSCode extension, create
23+
a configuration file. The script will also create a docker-compose.yml file and start the services.
24+
25+
### Usage
26+
27+
Tap the Continue button in the VSCode editor to start the service
28+
to bring up a chat window. The chat window will be displayed in the
29+
VSCode editor.
30+
31+
![alt text]("static/image.png")
32+
33+
Follow the standard
34+
35+

install.sh

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
#!/bin/bash
2+
# List of extensions to install
3+
extensions=(
4+
"continue.continue"
5+
)
6+
7+
for extension in "${extensions[@]}"; do
8+
echo "Installing $extension..."
9+
code --install-extension "$extension" --force
10+
done
11+
12+
echo "Continue extension installed successfully!"
13+
echo
14+
echo "Setting up config to use stacklok-hosted model..."
15+
echo
16+
echo "Note: This script will modify the configuration file at $HOME/.continue/config.json."
17+
echo "If you have an existing configuration file, it will be backed up to $HOME/.continue/config.json.bak."
18+
echo "Please make sure to back up your configuration file before running this script."
19+
echo "If this script fails, you can add the following model manually to the configuration file:"
20+
echo
21+
echo '```json'
22+
echo '{
23+
"title": "stacklok-hosted",
24+
"provider": "vllm",
25+
"model": "Qwen/Qwen2.5-Coder-14B-Instruct",
26+
"apiKey": "key",
27+
"apiBase": "http://localhost:8989/vllm"
28+
}'
29+
echo '```'
30+
echo
31+
32+
# Path to the configuration file
33+
CONFIG_FILE="$HOME/.continue/config.json"
34+
35+
# New model to add
36+
NEW_MODEL=$(cat <<EOF
37+
{
38+
"title": "stacklok-hosted",
39+
"provider": "vllm",
40+
"model": "Qwen/Qwen2.5-Coder-14B-Instruct",
41+
"apiKey": "key",
42+
"apiBase": "http://localhost:8989/vllm"
43+
}
44+
EOF
45+
)
46+
47+
# Update for tabAutocompleteModel
48+
NEW_TAB_AUTOCOMPLETE_MODEL=$(cat <<EOF
49+
{
50+
"title": "stacklok-hosted",
51+
"provider": "vllm",
52+
"model": "Qwen/Qwen2.5-Coder-14B-Instruct",
53+
"apiKey": ""
54+
}
55+
EOF
56+
)
57+
58+
# Create config directory if it doesn't exist
59+
mkdir -p "$HOME/.continue"
60+
61+
# Ensure the configuration file exists
62+
if [[ ! -f "$CONFIG_FILE" ]]; then
63+
echo "Configuration file not found at $CONFIG_FILE. Creating a new configuration file."
64+
echo '{
65+
"models": [],
66+
"modelRoles": {
67+
"default": "stacklok-hosted"
68+
}
69+
}' > "$CONFIG_FILE"
70+
fi
71+
72+
# Backup the configuration file
73+
cp "$CONFIG_FILE" "$CONFIG_FILE.bak"
74+
75+
# Use jq to handle JSON
76+
if command -v jq >/dev/null 2>&1; then
77+
echo "Using jq for JSON manipulation..."
78+
79+
# Check if the model already exists
80+
MODEL_EXISTS=$(jq --arg title "stacklok-hosted" '.models[] | select(.title == $title)' "$CONFIG_FILE")
81+
if [[ -n "$MODEL_EXISTS" ]]; then
82+
echo "Model 'stacklok-hosted' already exists in the configuration file."
83+
else
84+
# Add the model
85+
jq --argjson newModel "$NEW_MODEL" '.models += [$newModel]' "$CONFIG_FILE" > "${CONFIG_FILE}.tmp" && mv "${CONFIG_FILE}.tmp" "$CONFIG_FILE"
86+
echo "Model added successfully."
87+
fi
88+
89+
# Ensure modelRoles exists and set default
90+
if ! jq -e '.modelRoles' "$CONFIG_FILE" >/dev/null 2>&1; then
91+
echo "Adding modelRoles section..."
92+
jq '. + {"modelRoles": {"default": "stacklok-hosted"}}' "$CONFIG_FILE" > "${CONFIG_FILE}.tmp" && mv "${CONFIG_FILE}.tmp" "$CONFIG_FILE"
93+
else
94+
echo "Updating modelRoles default..."
95+
jq '.modelRoles.default = "stacklok-hosted"' "$CONFIG_FILE" > "${CONFIG_FILE}.tmp" && mv "${CONFIG_FILE}.tmp" "$CONFIG_FILE"
96+
fi
97+
98+
# Update tabAutocompleteModel
99+
jq --argjson newTabAutoComplete "$NEW_TAB_AUTOCOMPLETE_MODEL" '.tabAutocompleteModel = $newTabAutoComplete' "$CONFIG_FILE" > "${CONFIG_FILE}.tmp" && mv "${CONFIG_FILE}.tmp" "$CONFIG_FILE"
100+
echo "Updated tabAutocompleteModel in the configuration."
101+
else
102+
echo "jq is not installed. Using basic text manipulation..."
103+
104+
# Create a temporary file for modifications
105+
TEMP_FILE="${CONFIG_FILE}.tmp"
106+
107+
# Read the entire file
108+
content=$(<"$CONFIG_FILE")
109+
110+
# Check if the model already exists
111+
if echo "$content" | grep -q '"title": "stacklok-hosted"'; then
112+
echo "Model 'stacklok-hosted' already exists in the configuration file."
113+
else
114+
# Insert the new model into the models array
115+
content=$(echo "$content" | sed '/"models": \[/a\
116+
'"$NEW_MODEL"',' )
117+
fi
118+
119+
# Check if modelRoles exists
120+
if ! echo "$content" | grep -q '"modelRoles"'; then
121+
# Add modelRoles section after the models array
122+
content=$(echo "$content" | sed '/"models": \[/,/\]/!b;/\]/a\
123+
,\n "modelRoles": {\n "default": "stacklok-hosted"\n }')
124+
else
125+
# Update existing modelRoles
126+
content=$(echo "$content" | sed -E 's/"default": "[^"]*"/"default": "stacklok-hosted"/')
127+
fi
128+
129+
# Update tabAutocompleteModel
130+
if echo "$content" | grep -q '"tabAutocompleteModel"'; then
131+
content=$(echo "$content" | sed '/"tabAutocompleteModel": {/,/}/c\
132+
"tabAutocompleteModel": '"$NEW_TAB_AUTOCOMPLETE_MODEL"'')
133+
else
134+
# Add tabAutocompleteModel after modelRoles
135+
content=$(echo "$content" | sed '/"modelRoles": {/,/}/!b;/}/a\
136+
,\n "tabAutocompleteModel": '"$NEW_TAB_AUTOCOMPLETE_MODEL"'')
137+
fi
138+
139+
# Write the modified content back to the file
140+
echo "$content" > "$CONFIG_FILE"
141+
echo "Configuration updated successfully."
142+
fi
143+
144+
echo "Done with configuration setup!"
145+
146+
# Function to check if a command exists
147+
check_command() {
148+
if ! command -v "$1" &>/dev/null; then
149+
echo "$1 is not installed. Please install it and try again."
150+
exit 1
151+
fi
152+
}
153+
154+
# Rest of the Docker setup remains the same...
155+
[Previous Docker setup code continues unchanged...]
156+
157+
# Check if Docker is installed
158+
echo "Checking if Docker is installed..."
159+
check_command "docker"
160+
161+
# Check if Docker Compose is installed (or included in Docker)
162+
echo "Checking if Docker Compose is installed..."
163+
if docker compose version &>/dev/null; then
164+
# Docker Compose is included in Docker
165+
COMPOSE_COMMAND="docker compose"
166+
elif command -v docker-compose &>/dev/null; then
167+
# Legacy Docker Compose is installed
168+
COMPOSE_COMMAND="docker-compose"
169+
else
170+
echo "Docker Compose is not installed. Please install it and try again."
171+
exit 1
172+
fi
173+
174+
echo "Docker and Docker Compose are installed."
175+
176+
# Define the docker-compose file path
177+
COMPOSE_FILE="./docker-compose.yml"
178+
179+
# Create the docker-compose.yml file
180+
echo "Creating docker-compose.yml file..."
181+
cat > "$COMPOSE_FILE" <<EOF
182+
version: "3.9"
183+
184+
services:
185+
codegate-proxy:
186+
networks:
187+
- codegatenet
188+
build:
189+
context: .
190+
dockerfile: docker/Dockerfile
191+
image: ghcr.io/stacklok/codegate:latest
192+
ports:
193+
- 8989:8989
194+
extra_hosts:
195+
- "host.docker.internal:host-gateway"
196+
command:
197+
- -vllm=https://inference.codegate.ai # For hosted LLM
198+
- -ollama-embed=http://host.docker.internal:11434
199+
- -package-index=/opt/rag-in-a-box/data/
200+
- -db=rag-db
201+
depends_on:
202+
- rag-qdrant-db
203+
204+
rag-qdrant-db:
205+
image: ghcr.io/stacklok/codegate/qdrant-codegate@sha256:fccd830f8eaf9079972fee1eb95908ffe42d4571609be8bffa32fd26610481f7
206+
container_name: rag-db
207+
ports:
208+
- "6333:6333"
209+
- "6334:6334"
210+
networks:
211+
- codegatenet
212+
213+
networks:
214+
codegatenet:
215+
driver: bridge
216+
EOF
217+
218+
echo "docker-compose.yml file created successfully."
219+
220+
# Run docker-compose up
221+
echo "Running docker-compose up -d with file: $COMPOSE_FILE"
222+
$COMPOSE_COMMAND -f "$COMPOSE_FILE" up -d
223+
224+
if [[ $? -eq 0 ]]; then
225+
echo "Containers started successfully."
226+
echo
227+
echo "You can now open Visual Studio Code and start using the Codegate extension."
228+
echo "If you have any issues, please check the logs of the containers using 'docker logs <container-name>'."
229+
echo
230+
echo "Last of all, you will need a key to use the stacklok inference model, please contact stacklok for a key."
231+
echo "You can add the key to the configuration file at $HOME/.continue/config.json."
232+
echo "In the apiKey field, replace 'key' with the actual key."
233+
else
234+
echo "Failed to start containers. Check the output above for errors."
235+
exit 1
236+
fi

static/image.png

67.5 KB
Loading

0 commit comments

Comments
 (0)