Skip to content

Commit

Permalink
fix: add key prompt to samples
Browse files Browse the repository at this point in the history
  • Loading branch information
i2amsam committed Feb 3, 2025
1 parent edf9960 commit dd3a690
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
8 changes: 7 additions & 1 deletion samples/js-character-generator/.idx/dev.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@
};
# Runs when the workspace is (re)started
onStart = {
run-server = "npm run dev";
run-server = "if [ -z \"\${GOOGLE_GENAI_API_KEY}\" ]; then \
echo 'No Gemini API key detected, enter a Gemini API key from https://aistudio.google.com/app/apikey:' && \
read -s GOOGLE_GENAI_API_KEY && \
echo 'You can also add to .idx/dev.nix to automatically add to your workspace'
export GOOGLE_GENAI_API_KEY; \
fi && \
npm run genkit:dev";
};
};
};
Expand Down
2 changes: 1 addition & 1 deletion samples/js-character-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "A simple Firebase Genkit app to generate fantasy characters",
"main": "index.js",
"scripts": {
"dev": "genkit start -- npx tsx --watch index.ts"
"genkit:dev": "genkit start -- npx tsx --watch index.ts"
},
"keywords": [],
"author": "",
Expand Down
12 changes: 9 additions & 3 deletions samples/js-coffee-shop/.idx/dev.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# Sets environment variables in the workspace
env = {
#TODO Get a API key from https://g.co/ai/idxGetGeminiKey
GOOGLE_GENAI_API_KEY = "TODO";
GOOGLE_GENAI_API_KEY = "";
};
idx = {
# Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
Expand All @@ -30,8 +30,14 @@
};
# Runs when the workspace is (re)started
onStart = {
run-server = "npm run genkit:dev";
};
run-server = "if [ -z \"\${GOOGLE_GENAI_API_KEY}\" ]; then \
echo 'No Gemini API key detected, enter a Gemini API key from https://aistudio.google.com/app/apikey:' && \
read -s GOOGLE_GENAI_API_KEY && \
echo 'You can also add to .idx/dev.nix to automatically add to your workspace'
export GOOGLE_GENAI_API_KEY; \
fi && \
npm run genkit:dev";
};
};
};
}
10 changes: 8 additions & 2 deletions samples/js-schoolAgent/.idx/dev.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# Sets environment variables in the workspace
env = {
#TODO Get a API key from https://g.co/ai/idxGetGeminiKey
GOOGLE_GENAI_API_KEY = "TODO";
GOOGLE_GENAI_API_KEY = "";
};
idx = {
# Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
Expand All @@ -30,7 +30,13 @@
};
# Runs when the workspace is (re)started
onStart = {
run-server = "npm run genkit:dev";
run-server = "if [ -z \"\${GOOGLE_GENAI_API_KEY}\" ]; then \
echo 'No Gemini API key detected, enter a Gemini API key from https://aistudio.google.com/app/apikey:' && \
read -s GOOGLE_GENAI_API_KEY && \
echo 'You can also set the key in .idx/dev.nix to automatically add to your workspace'
export GOOGLE_GENAI_API_KEY; \
fi && \
npm run genkit:dev";
};
};
};
Expand Down

0 comments on commit dd3a690

Please sign in to comment.