jarvisfriday commited on
Commit
afca4f8
·
verified ·
1 Parent(s): 75b677f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -12,21 +12,21 @@ import os
12
  # Add your API key to .streamlit/secrets.toml like this:
13
  # GEMINI_API_KEY = "YOUR_API_KEY_HERE"
14
  # For local testing, you might also set it as an environment variable.
15
- try:
16
- # Prefer Streamlit secrets if available
17
- if "GEMINI_API_KEY" in st.secrets:
18
- genai.configure(api_key=st.secrets["GEMINI_API_KEY"])
19
- st.success("Gemini API key loaded from secrets.")
20
- elif os.getenv("GEMINI_API_KEY"):
21
- # Fallback to environment variable (useful for local dev without secrets)
22
- genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
23
- st.warning("Gemini API key loaded from environment variable. Use Streamlit Secrets for deployment.")
24
- else:
25
- st.error("GEMINI_API_KEY not found in Streamlit secrets or environment variables.")
26
- st.stop() # Stop execution if API key is missing
27
- except Exception as e:
28
- st.error(f"Failed to configure Gemini API: {e}")
29
- st.stop()
30
 
31
  # Note: The system_instruction and safety_settings are defined but commented
32
  # out in the actual API call configuration in the original code.
 
12
  # Add your API key to .streamlit/secrets.toml like this:
13
  # GEMINI_API_KEY = "YOUR_API_KEY_HERE"
14
  # For local testing, you might also set it as an environment variable.
15
+ # try:
16
+ # # Prefer Streamlit secrets if available
17
+ # if "GEMINI_API_KEY" in st.secrets:
18
+ # genai.configure(api_key=st.secrets["GEMINI_API_KEY"])
19
+ # st.success("Gemini API key loaded from secrets.")
20
+ # elif os.getenv("GEMINI_API_KEY"):
21
+ # # Fallback to environment variable (useful for local dev without secrets)
22
+ # genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
23
+ # st.warning("Gemini API key loaded from environment variable. Use Streamlit Secrets for deployment.")
24
+ # else:
25
+ # st.error("GEMINI_API_KEY not found in Streamlit secrets or environment variables.")
26
+ # st.stop() # Stop execution if API key is missing
27
+ # except Exception as e:
28
+ # st.error(f"Failed to configure Gemini API: {e}")
29
+ # st.stop()
30
 
31
  # Note: The system_instruction and safety_settings are defined but commented
32
  # out in the actual API call configuration in the original code.