Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update app.py #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 57 additions & 32 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,75 @@
from dotenv import load_dotenv
import json

load_dotenv() ## load all our environment variables
load_dotenv() # Load all our environment variables

genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))

def get_gemini_repsonse(input):
model=genai.GenerativeModel('gemini-pro')
response=model.generate_content(input)
def get_gemini_response(input_prompt):
model = genai.GenerativeModel('gemini-pro')
response = model.generate_content(input_prompt)
return response.text

def input_pdf_text(uploaded_file):
reader=pdf.PdfReader(uploaded_file)
text=""
for page in range(len(reader.pages)):
page=reader.pages[page]
text+=str(page.extract_text())
return text

#Prompt Template

input_prompt="""
Hey Act Like a skilled or very experience ATS(Application Tracking System)
with a deep understanding of tech field,software engineering,data science ,data analyst
try:
reader = pdf.PdfReader(uploaded_file)
text = ""
for page in range(len(reader.pages)):
page = reader.pages[page]
text += str(page.extract_text())
return text
except Exception as e:
return None, str(e)

# Prompt Template
input_prompt_template = """
Hey Act Like a skilled or very experienced ATS(Application Tracking System)
with a deep understanding of tech field, software engineering, data science, data analyst
and big data engineer. Your task is to evaluate the resume based on the given job description.
You must consider the job market is very competitive and you should provide
best assistance for improving thr resumes. Assign the percentage Matching based
on Jd and
the missing keywords with high accuracy
resume:{text}
description:{jd}
best assistance for improving the resumes. Assign the percentage matching based
on JD and the missing keywords with high accuracy.

resume: {text}
description: {jd}

I want the response in one single string having the structure
{{"JD Match":"%","MissingKeywords:[]","Profile Summary":""}}
{{"JD Match":"%","MissingKeywords":[],"Profile Summary":""}}
"""

## streamlit app
# Streamlit app
st.title("Smart ATS")
st.text("Improve Your Resume ATS")
jd=st.text_area("Paste the Job Description")
uploaded_file=st.file_uploader("Upload Your Resume",type="pdf",help="Please uplaod the pdf")
st.text("Improve Your Resume for ATS")

jd = st.text_area("Paste the Job Description")
uploaded_file = st.file_uploader("Upload Your Resume", type="pdf", help="Please upload a PDF file")

if st.button("Submit"):
if uploaded_file is not None and jd:
with st.spinner("Processing..."):
text, error = input_pdf_text(uploaded_file)
if text:
input_prompt = input_prompt_template.format(text=text, jd=jd)
response = get_gemini_response(input_prompt)
try:
response_json = json.loads(response)
st.subheader("Job Description Match Percentage")
st.text(response_json.get("JD Match", "N/A"))
st.subheader("Missing Keywords")
st.text(", ".join(response_json.get("MissingKeywords", [])))
st.subheader("Profile Summary")
st.text(response_json.get("Profile Summary", "N/A"))
except json.JSONDecodeError:
st.error("Failed to decode response from the AI model.")
else:
st.error(f"Error reading PDF file: {error}")
else:
st.error("Please upload a PDF file and provide a job description.")


submit = st.button("Submit")

if submit:
if uploaded_file is not None:
text=input_pdf_text(uploaded_file)
response=get_gemini_repsonse(input_prompt)
st.subheader(response)
'''Features Added:
Error Handling: Added error handling for PDF reading.
Response Parsing: Improved parsing and display of JSON response.
User Feedback: Added spinners and error messages for better user experience.
Validation: Added validation to ensure both JD and PDF are provided.'''