Skip to content

Commit e66bc73

Browse files
Automatically choose the copilot endpoint in the codespace if it's available.
1 parent 4bced23 commit e66bc73

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

.devcontainer/env-copilot

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Uncomment the endpoint that you want to use:
2+
#AI_API_ENDPOINT=https://models.github.ai/inference
3+
AI_API_ENDPOINT=https://api.githubcopilot.com
4+
#AI_API_ENDPOINT=https://api.openai.com/v1
5+
6+
# Uncomment to set the model temperature
7+
#MODEL_TEMP=1.0
8+
9+
# Optional data storage directories. By default, ~/.local is used.
10+
#MEMCACHE_STATE_DIR=/app/data
11+
#CODEQL_DBS_BASE_PATH=/app/data
12+
#DATA_DIR=/app/data
13+
#LOG_DIR=/app/logs

.devcontainer/env-default

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#AI_API_ENDPOINT=https://api.githubcopilot.com
44
#AI_API_ENDPOINT=https://api.openai.com/v1
55

6+
# Uncomment to set the model temperature
7+
#MODEL_TEMP=1.0
8+
69
# Optional data storage directories. By default, ~/.local is used.
710
#MEMCACHE_STATE_DIR=/app/data
811
#CODEQL_DBS_BASE_PATH=/app/data

.devcontainer/post-attach.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@ fi
1515
# Create .env file if it doesn't exist
1616
if [ ! -f .env ]; then
1717
echo "📝 Creating .env template..."
18-
cp .devcontainer/env-default .env || { echo "Error creating .env"; exit 1; }
18+
# Test whether a simple curl command to api.githubcopilot.com works. If so
19+
# install the Copilot version of .env, otherwise install the default version.
20+
ENV_VERSION="env-default"
21+
if [ -v AI_API_TOKEN ]; then
22+
if curl --fail https://api.githubcopilot.com/models -H "Authorization: Bearer $AI_API_TOKEN" -H "Copilot-Integration-Id: vscode-chat"; then
23+
ENV_VERSION="env-copilot"
24+
fi
25+
fi
26+
cp .devcontainer/${ENV_VERSION} .env || { echo "Error creating .env"; exit 1; }
1927
code .env || echo "ℹ️ Unable to open .env in VS Code. Please open and review the .env file manually."
2028
echo "⚠️ Defaults can be changed by editing the auto-generated .env file."
2129
fi

0 commit comments

Comments
 (0)