JeCabrera commited on
Commit
dd06ef3
·
verified ·
1 Parent(s): 3375e1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -6,11 +6,19 @@ from typing import List, Tuple, Optional, Dict, Union
6
  import google.generativeai as genai
7
  import gradio as gr
8
  from PIL import Image
 
 
 
 
9
 
10
  print("google-generativeai:", genai.__version__)
11
 
12
- # Cargar la clave de API de las variables de entorno
13
- GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY")
 
 
 
 
14
 
15
  TITLE = """<h1 align="center">Gemini Playground 💬</h1>"""
16
  SUBTITLE = """<h2 align="center">Play with Gemini Pro and Gemini Pro Vision</h2>"""
 
6
  import google.generativeai as genai
7
  import gradio as gr
8
  from PIL import Image
9
+ from dotenv import load_dotenv
10
+
11
+ # Cargar las variables de entorno desde el archivo .env
12
+ load_dotenv()
13
 
14
  print("google-generativeai:", genai.__version__)
15
 
16
+ # Obtener la clave de la API de las variables de entorno
17
+ GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
18
+
19
+ # Verificar que la clave de la API esté configurada
20
+ if not GOOGLE_API_KEY:
21
+ raise ValueError("GOOGLE_API_KEY is not set in environment variables.")
22
 
23
  TITLE = """<h1 align="center">Gemini Playground 💬</h1>"""
24
  SUBTITLE = """<h2 align="center">Play with Gemini Pro and Gemini Pro Vision</h2>"""