Spaces:
Sleeping
Sleeping
Commit
•
eca0481
1
Parent(s):
41f817e
Update app.py
Browse files
app.py
CHANGED
@@ -9,8 +9,6 @@ from llama_index import ServiceContext
|
|
9 |
from llama_index.schema import NodeWithScore
|
10 |
from llama_index.response_synthesizers import TreeSummarize
|
11 |
from pydantic import BaseModel
|
12 |
-
import PyPDF2
|
13 |
-
import io
|
14 |
|
15 |
# Load environment variables from .env file
|
16 |
load_dotenv()
|
@@ -67,12 +65,12 @@ class ResumeScreenerPack(BaseLlamaPack):
|
|
67 |
"""Get modules."""
|
68 |
return {"synthesizer": self.synthesizer}
|
69 |
|
70 |
-
def run(self,
|
71 |
"""Run pack."""
|
72 |
node_with_score_input = {
|
73 |
"metadata": {}, # Provide any necessary metadata
|
74 |
-
"content":
|
75 |
-
"type": "
|
76 |
}
|
77 |
|
78 |
output = self.synthesizer.synthesize(
|
@@ -87,36 +85,17 @@ def main():
|
|
87 |
# Sidebar for user input
|
88 |
job_description = st.text_area("Job Description")
|
89 |
criteria = st.text_area("Screening Criteria (separate each criterion by a new line)")
|
90 |
-
|
91 |
-
uploaded_file = st.file_uploader("Upload Resume (PDF)", type=["pdf"])
|
92 |
|
93 |
if st.button("Submit"):
|
94 |
-
if job_description and criteria and
|
95 |
-
resume_text = extract_text_from_pdf(uploaded_file)
|
96 |
-
|
97 |
screener_pack = ResumeScreenerPack(job_description=job_description, criteria=criteria.split("\n"))
|
98 |
|
99 |
-
with st.spinner("Analyzing the
|
100 |
-
result = screener_pack.run(
|
101 |
|
102 |
st.subheader("Screening Results")
|
103 |
st.json(result)
|
104 |
|
105 |
-
def extract_text_from_pdf(uploaded_file):
|
106 |
-
if uploaded_file is not None:
|
107 |
-
try:
|
108 |
-
# Read PDF content using PyPDF2's PdfReader
|
109 |
-
pdf_reader = PyPDF2.PdfReader(uploaded_file)
|
110 |
-
text = ""
|
111 |
-
for page in pdf_reader.pages:
|
112 |
-
text += page.extract_text()
|
113 |
-
return text
|
114 |
-
except Exception as e:
|
115 |
-
st.error(f"Error extracting text from PDF: {str(e)}")
|
116 |
-
return ""
|
117 |
-
else:
|
118 |
-
st.error("Please upload a PDF file.")
|
119 |
-
return ""
|
120 |
-
|
121 |
if __name__ == "__main__":
|
122 |
main()
|
|
|
9 |
from llama_index.schema import NodeWithScore
|
10 |
from llama_index.response_synthesizers import TreeSummarize
|
11 |
from pydantic import BaseModel
|
|
|
|
|
12 |
|
13 |
# Load environment variables from .env file
|
14 |
load_dotenv()
|
|
|
65 |
"""Get modules."""
|
66 |
return {"synthesizer": self.synthesizer}
|
67 |
|
68 |
+
def run(self, qualification: str) -> Any:
|
69 |
"""Run pack."""
|
70 |
node_with_score_input = {
|
71 |
"metadata": {}, # Provide any necessary metadata
|
72 |
+
"content": qualification, # Use qualification as content
|
73 |
+
"type": "qualification", # Define the type as per your schema
|
74 |
}
|
75 |
|
76 |
output = self.synthesizer.synthesize(
|
|
|
85 |
# Sidebar for user input
|
86 |
job_description = st.text_area("Job Description")
|
87 |
criteria = st.text_area("Screening Criteria (separate each criterion by a new line)")
|
88 |
+
qualification = st.text_area("Qualification")
|
|
|
89 |
|
90 |
if st.button("Submit"):
|
91 |
+
if job_description and criteria and qualification:
|
|
|
|
|
92 |
screener_pack = ResumeScreenerPack(job_description=job_description, criteria=criteria.split("\n"))
|
93 |
|
94 |
+
with st.spinner("Analyzing the qualification..."):
|
95 |
+
result = screener_pack.run(qualification)
|
96 |
|
97 |
st.subheader("Screening Results")
|
98 |
st.json(result)
|
99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
if __name__ == "__main__":
|
101 |
main()
|