Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,28 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import cv2
|
| 3 |
-
import numpy as np
|
| 4 |
-
import tempfile
|
| 5 |
import os
|
|
|
|
|
|
|
| 6 |
import easyocr
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
from langchain.prompts import PromptTemplate
|
| 8 |
from langchain.chains import LLMChain
|
| 9 |
from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
|
| 10 |
|
|
|
|
| 11 |
st.set_page_config(page_title="Resume Validator", layout="centered", page_icon="π")
|
| 12 |
st.title("π AI Resume Validator")
|
| 13 |
st.write("Upload your resume and get instant feedback on its quality and suggestions to improve.")
|
|
|
|
|
|
|
| 14 |
uploaded_file = st.file_uploader("Upload Resume (PDF or DOCX)", type=["pdf", "docx"])
|
|
|
|
|
|
|
| 15 |
if uploaded_file:
|
| 16 |
-
|
|
|
|
| 17 |
from pdfminer.high_level import extract_text
|
| 18 |
resume_text = extract_text(uploaded_file)
|
| 19 |
else:
|
|
@@ -22,32 +31,43 @@ if uploaded_file:
|
|
| 22 |
|
| 23 |
st.markdown("### π Extracted Resume Text")
|
| 24 |
st.code(resume_text)
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
-
|
| 41 |
-
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
st.markdown("### π Feedback")
|
| 53 |
-
st.
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
| 2 |
import os
|
| 3 |
+
import tempfile
|
| 4 |
+
import numpy as np
|
| 5 |
import easyocr
|
| 6 |
+
|
| 7 |
+
# Only needed if you're doing any OCR or OpenCV processing
|
| 8 |
+
# import cv2
|
| 9 |
+
|
| 10 |
from langchain.prompts import PromptTemplate
|
| 11 |
from langchain.chains import LLMChain
|
| 12 |
from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
|
| 13 |
|
| 14 |
+
# Set page config
|
| 15 |
st.set_page_config(page_title="Resume Validator", layout="centered", page_icon="π")
|
| 16 |
st.title("π AI Resume Validator")
|
| 17 |
st.write("Upload your resume and get instant feedback on its quality and suggestions to improve.")
|
| 18 |
+
|
| 19 |
+
# File uploader
|
| 20 |
uploaded_file = st.file_uploader("Upload Resume (PDF or DOCX)", type=["pdf", "docx"])
|
| 21 |
+
|
| 22 |
+
# Only run logic if a file is uploaded
|
| 23 |
if uploaded_file:
|
| 24 |
+
# Extract text based on file type
|
| 25 |
+
if uploaded_file.name.endswith(".pdf"):
|
| 26 |
from pdfminer.high_level import extract_text
|
| 27 |
resume_text = extract_text(uploaded_file)
|
| 28 |
else:
|
|
|
|
| 31 |
|
| 32 |
st.markdown("### π Extracted Resume Text")
|
| 33 |
st.code(resume_text)
|
| 34 |
+
|
| 35 |
+
# Prompt template for evaluation
|
| 36 |
+
template = """
|
| 37 |
+
You are an expert HR recruiter.
|
| 38 |
+
|
| 39 |
+
Here is the content of a resume:
|
| 40 |
+
{resume_text}
|
| 41 |
+
|
| 42 |
+
Evaluate the resume on the following criteria:
|
| 43 |
+
1. Clarity and grammar
|
| 44 |
+
2. Relevance of skills and keywords
|
| 45 |
+
3. Structure (sections like Education, Experience, Projects, etc.)
|
| 46 |
+
4. Overall impact
|
| 47 |
+
|
| 48 |
+
Provide:
|
| 49 |
+
- A rating out of 10
|
| 50 |
+
- Key strengths
|
| 51 |
+
- Weaknesses
|
| 52 |
+
- Actionable suggestions to improve
|
| 53 |
+
"""
|
| 54 |
+
prompt = PromptTemplate(input_variables=["resume_text"], template=template)
|
| 55 |
+
|
| 56 |
+
# Initialize the model
|
| 57 |
+
llm = HuggingFaceEndpoint(
|
| 58 |
+
repo_id="mistralai/Mistral-7B-Instruct-v0.3",
|
| 59 |
+
temperature=0.5,
|
| 60 |
+
max_new_tokens=300,
|
| 61 |
+
task="conversational"
|
| 62 |
+
)
|
| 63 |
+
model = ChatHuggingFace(llm=llm)
|
| 64 |
+
chain = LLMChain(llm=model, prompt=prompt)
|
| 65 |
+
|
| 66 |
+
# Analyze resume on button click
|
| 67 |
+
if st.button("β
Validate Resume"):
|
| 68 |
+
with st.spinner("Analyzing your resume..."):
|
| 69 |
+
result = chain.run(resume_text=resume_text)
|
| 70 |
st.markdown("### π Feedback")
|
| 71 |
+
st.success(result)
|
| 72 |
+
else:
|
| 73 |
+
st.info("Please upload a resume file (PDF or DOCX) to start the validation.")
|