Update src/streamlit_app.py
Browse files- src/streamlit_app.py +3 -12
src/streamlit_app.py
CHANGED
|
@@ -88,15 +88,6 @@ def calculate_experience(work_history):
|
|
| 88 |
|
| 89 |
return round(total_experience, 1)
|
| 90 |
|
| 91 |
-
def get_api_key():
|
| 92 |
-
"""Safely get API key from secrets or user input."""
|
| 93 |
-
try:
|
| 94 |
-
# Try to get from Streamlit secrets
|
| 95 |
-
return st.secrets["GEMINI_API_KEY"]
|
| 96 |
-
except (KeyError, FileNotFoundError, st.errors.StreamlitSecretNotFoundError):
|
| 97 |
-
# If secrets don't exist or key is not found, ask user for input
|
| 98 |
-
return st.text_input("Enter Gemini API Key", type="password")
|
| 99 |
-
|
| 100 |
def parse_resume(file_uploaded, api_key):
|
| 101 |
"""Parse resume and extract information."""
|
| 102 |
genai.configure(api_key=api_key)
|
|
@@ -195,12 +186,12 @@ def main():
|
|
| 195 |
st.title("Resume Parser")
|
| 196 |
st.write("Upload a resume (PDF, DOCX, or Image) to extract information")
|
| 197 |
|
| 198 |
-
# Get API key from secrets
|
| 199 |
-
api_key =
|
| 200 |
|
| 201 |
uploaded_file = st.file_uploader("Choose a resume file", type=["pdf", "docx", "doc", "jpg", "jpeg", "png"])
|
| 202 |
|
| 203 |
-
if uploaded_file:
|
| 204 |
with st.spinner('Analyzing resume...'):
|
| 205 |
result = parse_resume(uploaded_file, api_key)
|
| 206 |
|
|
|
|
| 88 |
|
| 89 |
return round(total_experience, 1)
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
def parse_resume(file_uploaded, api_key):
|
| 92 |
"""Parse resume and extract information."""
|
| 93 |
genai.configure(api_key=api_key)
|
|
|
|
| 186 |
st.title("Resume Parser")
|
| 187 |
st.write("Upload a resume (PDF, DOCX, or Image) to extract information")
|
| 188 |
|
| 189 |
+
# Get API key from secrets or user input
|
| 190 |
+
api_key = st.secrets["GEMINI_API_KEY"] if "GEMINI_API_KEY" in st.secrets else st.text_input("Enter Gemini API Key", type="password")
|
| 191 |
|
| 192 |
uploaded_file = st.file_uploader("Choose a resume file", type=["pdf", "docx", "doc", "jpg", "jpeg", "png"])
|
| 193 |
|
| 194 |
+
if uploaded_file and api_key:
|
| 195 |
with st.spinner('Analyzing resume...'):
|
| 196 |
result = parse_resume(uploaded_file, api_key)
|
| 197 |
|