Katieearl1513 commited on
Commit
a4a92ab
·
verified ·
1 Parent(s): dbf07b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -3,7 +3,11 @@ from google.colab import userdata
3
  import google.generativeai as genai
4
 
5
  # Configure Gemini AI
6
- api_key = userdata.get('GEMINI_API') # Fetch the Gemini API key securely
 
 
 
 
7
  genai.configure(api_key=api_key)
8
 
9
  # Define the model with desired generation configuration
 
3
  import google.generativeai as genai
4
 
5
  # Configure Gemini AI
6
+ try:
7
+ api_key = userdata.get('GEMINI_API') # Fetch the Gemini API key securely
8
+ except NameError:
9
+ api_key = os.environ.get("GEMINI_API") # Get from environment variable if not in Colab
10
+
11
  genai.configure(api_key=api_key)
12
 
13
  # Define the model with desired generation configuration