Spaces:
Sleeping
Sleeping
Ahmad-Moiz
commited on
Commit
•
e5b583f
1
Parent(s):
8c7677c
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from pathlib import Path
|
3 |
+
from typing import List, Optional
|
4 |
+
from llama_index.llms.base import LLM
|
5 |
+
from llama_index.llms import OpenAI
|
6 |
+
from llama_index.readers import PDFReader
|
7 |
+
from llama_index.llama_pack.base import BaseLlamaPack
|
8 |
+
from llama_index.schema import NodeWithScore
|
9 |
+
from llama_index.response_synthesizers import TreeSummarize
|
10 |
+
from pydantic import BaseModel, Field
|
11 |
+
|
12 |
+
QUERY_TEMPLATE = """
|
13 |
+
You are an expert resume reviewer.
|
14 |
+
Your job is to decide if the candidate passes the resume screen given the job description and a list of criteria:
|
15 |
+
|
16 |
+
### Job Description
|
17 |
+
{job_description}
|
18 |
+
|
19 |
+
### Screening Criteria
|
20 |
+
{criteria_str}
|
21 |
+
"""
|
22 |
+
|
23 |
+
# Define the BaseModel and other classes you provided
|
24 |
+
|
25 |
+
|
26 |
+
# Function to format criteria list into a string
|
27 |
+
def _format_criteria_str(criteria: List[str]) -> str:
|
28 |
+
criteria_str = ""
|
29 |
+
for criterion in criteria:
|
30 |
+
criteria_str += f"- {criterion}\n"
|
31 |
+
return criteria_str
|
32 |
+
|
33 |
+
|
34 |
+
class ResumeScreenerPack(BaseLlamaPack):
|
35 |
+
# ... (your existing code for ResumeScreenerPack)
|
36 |
+
|
37 |
+
|
38 |
+
def main():
|
39 |
+
st.title("Resume Screener")
|
40 |
+
|
41 |
+
job_description = st.text_area("Job Description")
|
42 |
+
criteria = st.text_area("Screening Criteria (Separate by new lines)")
|
43 |
+
|
44 |
+
criteria_list = criteria.split('\n') if criteria else []
|
45 |
+
|
46 |
+
def run_resume_screener(resume_path):
|
47 |
+
screener = ResumeScreenerPack(job_description, criteria_list)
|
48 |
+
output = screener.run(resume_path)
|
49 |
+
st.json(output) # Displaying JSON output for example
|
50 |
+
|
51 |
+
uploaded_file = st.file_uploader("Upload a resume", type=['pdf'])
|
52 |
+
|
53 |
+
if uploaded_file:
|
54 |
+
st.write("Resume uploaded!")
|
55 |
+
run_resume_screener(uploaded_file)
|
56 |
+
|
57 |
+
if __name__ == "__main__":
|
58 |
+
main()
|