Michael Rey commited on
Commit
973b88e
·
1 Parent(s): d61a8ec

modified code for HS secrets

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -3,9 +3,18 @@ import os
3
  import google.generativeai as genai
4
  from dotenv import load_dotenv
5
 
6
- # Load API key from .env file
7
- load_dotenv()
8
- genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
 
 
 
 
 
 
 
 
 
9
 
10
  # Title of the app
11
  st.title("KAI Chat")
 
3
  import google.generativeai as genai
4
  from dotenv import load_dotenv
5
 
6
+ # # Load API key from .env file
7
+ # load_dotenv()
8
+ # genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
9
+
10
+ # Retrieve API key from Hugging Face Secrets
11
+ api_key = os.getenv("GEMINI_API_KEY")
12
+
13
+ if not api_key:
14
+ raise ValueError("API key not found. Make sure it is set in Hugging Face Secrets.")
15
+
16
+ # Configure Gemini API
17
+ genai.configure(api_key=api_key)
18
 
19
  # Title of the app
20
  st.title("KAI Chat")