Hashim998 commited on
Commit
c722feb
·
verified ·
1 Parent(s): c71f825

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -26,15 +26,19 @@ 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
- # === Load API Key ===
30
- # os.environ["GOOGLE_API_KEY"] = os.getenv["GEMINI_API_KEY"]
31
 
32
  GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
33
  if not GEMINI_API_KEY:
34
- raise ValueError("GEMINI_API_KEY is missing. Set it as an environment variable or Hugging Face Secret.")
35
 
 
 
 
 
36
  genai.configure(api_key=GEMINI_API_KEY)
37
 
 
38
  # === Chat Storage ===
39
  HISTORY_FILE = "chat_history.json"
40
 
 
26
  logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
27
  logger = logging.getLogger(__name__)
28
 
29
+ # Load Gemini API key from Hugging Face secret or local .env
 
30
 
31
  GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
32
  if not GEMINI_API_KEY:
33
+ raise ValueError("Missing GEMINI_API_KEY (check Hugging Face secrets or local .env)")
34
 
35
+ # Set it in the expected Google API env var
36
+ os.environ["GOOGLE_API_KEY"] = GEMINI_API_KEY
37
+
38
+ # Configure generativeai
39
  genai.configure(api_key=GEMINI_API_KEY)
40
 
41
+
42
  # === Chat Storage ===
43
  HISTORY_FILE = "chat_history.json"
44