Skip to content

Commit c19fe7e

Browse files
adding importing from env
1 parent 0b5c513 commit c19fe7e

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

notebooks/GenAI/Gemini_Intro.ipynb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,22 @@
9595
"import vertexai\n",
9696
"from vertexai.generative_models import GenerativeModel, Image, GenerativeModel, ChatSession, Part, GenerationConfig\n",
9797
"\n",
98-
"# TODO(developer): Update and un-comment below lines\n",
99-
"project_id = \"<PROJECT_ID>\"\n",
100-
"location = \"<LOCATION>\" #(e.g., us-central1)\n",
98+
"import json\n",
99+
"# Load env.json\n",
100+
"try:\n",
101+
" with open(\"env.json\") as f:\n",
102+
" config = json.load(f)\n",
103+
"except FileNotFoundError:\n",
104+
" config = {}\n",
105+
"\n",
106+
"# Assign parameters from Env.\n",
107+
"project_id = config.get(\"NOTEBOOK_GCP_PROJECT_ID\")\n",
108+
"location = config.get(\"NOTEBOOK_GCP_LOCATION\")\n",
109+
"\n",
110+
"# TODO( FOR developer): If not defined in ENV earlier, uncomment and add it below\n",
111+
"#project_id = \"<PROJECT_ID>\"\n",
112+
"#location = \"<LOCATION>\" #(e.g., us-central1)\n",
113+
"\n",
101114
"vertexai.init(project=project_id, location=location)"
102115
]
103116
},

0 commit comments

Comments
 (0)