| | import streamlit as st |
| | import os |
| | from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace |
| | from langchain.prompts import PromptTemplate, ChatPromptTemplate |
| | from langchain_community.document_loaders import UnstructuredPDFLoader |
| | import tempfile |
| |
|
| | |
| | hk = os.getenv('hf') |
| | os.environ['HUGGINGFACEHUB_API_TOKEN'] = hk |
| | os.environ['HF_TOKEN'] = hk |
| |
|
| | |
| | llm_skeleton = HuggingFaceEndpoint( |
| | repo_id='meta-llama/Llama-3.2-3B-Instruct', |
| | provider='novita', |
| | temperature=0.7, |
| | max_new_tokens=150, |
| | task='conversational' |
| | ) |
| | llm = ChatHuggingFace( |
| | llm=llm_skeleton, |
| | repo_id='meta-llama/Llama-3.2-3B-Instruct', |
| | provider='novita', |
| | temperature=0.7, |
| | max_new_tokens=150, |
| | task='conversational' |
| | ) |
| |
|
| | |
| | st.title("📄 Resume & Job Description Extractor") |
| |
|
| | |
| | resume_file = st.file_uploader("Upload Resume (PDF)", type=["pdf"]) |
| |
|
| | |
| | jd_file = st.file_uploader("Upload Job Description (PDF)", type=["pdf"]) |
| |
|
| | |
| | jd_text = st.text_area("Or paste Job Description text here") |
| |
|
| | if st.button("Extract Data"): |
| | if resume_file: |
| | |
| | with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp_resume: |
| | tmp_resume.write(resume_file.read()) |
| | resume_path = tmp_resume.name |
| | |
| | |
| | loader = UnstructuredPDFLoader(resume_path) |
| | resume_text = loader.load()[0].page_content |
| | |
| | |
| | resume_prompt = f""" |
| | Extract the following from the resume: |
| | 1. Name |
| | 2. Education |
| | 3. Experience |
| | 4. Skills |
| | 5. Project Names and Results |
| | |
| | Resume: |
| | {resume_text} |
| | """ |
| | resume_data = llm.invoke(resume_prompt) |
| | st.subheader("Extracted Resume Data") |
| | st.write(resume_data) |
| |
|
| | |
| | os.unlink(resume_path) |
| |
|
| | if jd_file or jd_text: |
| | if jd_file: |
| | with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp_jd: |
| | tmp_jd.write(jd_file.read()) |
| | jd_path = tmp_jd.name |
| |
|
| | loader = UnstructuredPDFLoader(jd_path) |
| | jd_text_extracted = loader.load()[0].page_content |
| | os.unlink(jd_path) |
| | else: |
| | jd_text_extracted = jd_text |
| |
|
| | |
| | jd_prompt = f""" |
| | Extract the following from the job description: |
| | 1. Job ID |
| | 2. Company Name |
| | 3. Role |
| | 4. Experience Required |
| | 5. Skills Required |
| | 6. Education Required |
| | 7. Location |
| | |
| | Job Description: |
| | {jd_text_extracted} |
| | """ |
| | jd_data = llm.invoke(jd_prompt) |
| | st.subheader("Extracted Job Description Data") |
| | st.write(jd_data) |
| |
|