Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,9 +5,9 @@ import spacy
|
|
5 |
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
|
6 |
from docx import Document
|
7 |
import re
|
8 |
-
from nltk.corpus import words
|
9 |
import dateparser
|
10 |
from datetime import datetime
|
|
|
11 |
|
12 |
# Load SpaCy model for dependency parsing
|
13 |
nlp_spacy = spacy.load('en_core_web_sm')
|
@@ -17,13 +17,15 @@ tokenizer = AutoTokenizer.from_pretrained("Babelscape/wikineural-multilingual-ne
|
|
17 |
model = AutoModelForTokenClassification.from_pretrained("Babelscape/wikineural-multilingual-ner")
|
18 |
nlp_ner = pipeline('ner', model=model, tokenizer=tokenizer, aggregation_strategy="simple")
|
19 |
|
20 |
-
english_words = set(words.words())
|
21 |
-
|
22 |
# Function to authenticate with Gemini API
|
23 |
-
def authenticate_gemini(
|
|
|
|
|
|
|
|
|
24 |
try:
|
25 |
genai.configure(api_key=api_key)
|
26 |
-
model = genai.GenerativeModel(model_name="gemini-
|
27 |
st.success("Gemini API successfully configured.")
|
28 |
return model
|
29 |
except Exception as e:
|
@@ -120,19 +122,16 @@ def main():
|
|
120 |
st.title("Comprehensive Resume Analyzer")
|
121 |
st.write("Upload a resume to extract information, generate a summary, and analyze details.")
|
122 |
|
123 |
-
#
|
124 |
-
|
|
|
|
|
125 |
|
126 |
# File uploader for resume input
|
127 |
uploaded_file = st.file_uploader("Choose a PDF or DOCX file", type=["pdf", "docx", "doc"])
|
128 |
|
129 |
-
if uploaded_file is not None
|
130 |
try:
|
131 |
-
# Authenticate with Google Gemini API
|
132 |
-
model = authenticate_gemini(api_key)
|
133 |
-
if model is None:
|
134 |
-
return
|
135 |
-
|
136 |
# Extract text from the uploaded resume
|
137 |
file_ext = uploaded_file.name.split('.')[-1].lower()
|
138 |
if file_ext == 'pdf':
|
|
|
5 |
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
|
6 |
from docx import Document
|
7 |
import re
|
|
|
8 |
import dateparser
|
9 |
from datetime import datetime
|
10 |
+
import os
|
11 |
|
12 |
# Load SpaCy model for dependency parsing
|
13 |
nlp_spacy = spacy.load('en_core_web_sm')
|
|
|
17 |
model = AutoModelForTokenClassification.from_pretrained("Babelscape/wikineural-multilingual-ner")
|
18 |
nlp_ner = pipeline('ner', model=model, tokenizer=tokenizer, aggregation_strategy="simple")
|
19 |
|
|
|
|
|
20 |
# Function to authenticate with Gemini API
|
21 |
+
def authenticate_gemini():
|
22 |
+
api_key = os.environ.get("GOOGLE_GEMINI_API_KEY")
|
23 |
+
if not api_key:
|
24 |
+
st.error("Google Gemini API key not found. Please set it in the Hugging Face Spaces secrets.")
|
25 |
+
return None
|
26 |
try:
|
27 |
genai.configure(api_key=api_key)
|
28 |
+
model = genai.GenerativeModel(model_name="gemini-pro")
|
29 |
st.success("Gemini API successfully configured.")
|
30 |
return model
|
31 |
except Exception as e:
|
|
|
122 |
st.title("Comprehensive Resume Analyzer")
|
123 |
st.write("Upload a resume to extract information, generate a summary, and analyze details.")
|
124 |
|
125 |
+
# Authenticate with Gemini API
|
126 |
+
model = authenticate_gemini()
|
127 |
+
if model is None:
|
128 |
+
return
|
129 |
|
130 |
# File uploader for resume input
|
131 |
uploaded_file = st.file_uploader("Choose a PDF or DOCX file", type=["pdf", "docx", "doc"])
|
132 |
|
133 |
+
if uploaded_file is not None:
|
134 |
try:
|
|
|
|
|
|
|
|
|
|
|
135 |
# Extract text from the uploaded resume
|
136 |
file_ext = uploaded_file.name.split('.')[-1].lower()
|
137 |
if file_ext == 'pdf':
|