notes73 commited on
Commit
a068684
·
1 Parent(s): 49c5823

Use environment variable for OpenAI API key

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -1,8 +1,13 @@
1
  import streamlit as st
2
  import openai
3
 
4
- # Set OpenAI API key
5
- openai.api_key = "Replace with your actual API key"
 
 
 
 
 
6
 
7
  # Streamlit UI
8
  st.set_page_config(page_title="AI Job Interview Coach", layout="centered")
 
1
  import streamlit as st
2
  import openai
3
 
4
+ # Get the OpenAI API key from the environment variable
5
+ openai.api_key = os.getenv("OPENAI_API_KEY")
6
+
7
+ # Raise an error if the API key is missing
8
+ if not openai.api_key:
9
+ raise ValueError("⚠️ OpenAI API key is missing! Add it in Hugging Face environment variables.")
10
+
11
 
12
  # Streamlit UI
13
  st.set_page_config(page_title="AI Job Interview Coach", layout="centered")