Update app.py
Browse files
app.py
CHANGED
@@ -5,9 +5,7 @@ import time
|
|
5 |
import gradio as gr
|
6 |
import logging
|
7 |
|
8 |
-
|
9 |
-
from dotenv import load_dotenv
|
10 |
-
load_dotenv()
|
11 |
|
12 |
import google.generativeai as genai
|
13 |
|
@@ -26,16 +24,16 @@ from langchain_google_genai import ChatGoogleGenerativeAI
|
|
26 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
|
27 |
logger = logging.getLogger(__name__)
|
28 |
|
29 |
-
#
|
|
|
30 |
|
31 |
-
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
|
32 |
if not GEMINI_API_KEY:
|
33 |
-
raise
|
34 |
|
35 |
-
#
|
36 |
os.environ["GOOGLE_API_KEY"] = GEMINI_API_KEY
|
37 |
|
38 |
-
# Configure
|
39 |
genai.configure(api_key=GEMINI_API_KEY)
|
40 |
|
41 |
|
|
|
5 |
import gradio as gr
|
6 |
import logging
|
7 |
|
8 |
+
|
|
|
|
|
9 |
|
10 |
import google.generativeai as genai
|
11 |
|
|
|
24 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
|
25 |
logger = logging.getLogger(__name__)
|
26 |
|
27 |
+
# Pull from Hugging Face Secrets
|
28 |
+
GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY")
|
29 |
|
|
|
30 |
if not GEMINI_API_KEY:
|
31 |
+
raise RuntimeError("GEMINI_API_KEY not found in Hugging Face Secrets")
|
32 |
|
33 |
+
# Ensure it's accessible globally
|
34 |
os.environ["GOOGLE_API_KEY"] = GEMINI_API_KEY
|
35 |
|
36 |
+
# Configure Google GenAI
|
37 |
genai.configure(api_key=GEMINI_API_KEY)
|
38 |
|
39 |
|