import streamlit as st from langchain.schema.messages import HumanMessage, SystemMessage, AIMessage from streamlit_chat import message import PyPDF2 from langchain.prompts import PromptTemplate from dotenv import load_dotenv import os from langchain_community.chat_models import ChatOpenAI import json load_dotenv() os.getenv('OPENAI_API_KEY') chat_bot = ChatOpenAI(temperature=0.5) def streamlit_init(): st.set_page_config( page_title = "Resume GPT", page_icon= '🤖' ) st.header("Your Resume GPT 🤖") if 'flowmessages' not in st.session_state: st.session_state['flowmessages'] = [SystemMessage( content='''You are a resume consultant, good at pointing out keywords and other points how users can update their resume for a particualr job profile.''' )] description = st.text_input('Add a job profile here (LinkedIn)...') resume = st.file_uploader('Add your resume here', type='pdf') return description,resume def getTextFromPDF(resume): pdf_reader = PyPDF2.PdfReader(resume) extracted_text = "" for page_num in range(len(pdf_reader.pages)): page = pdf_reader.pages[page_num] extracted_text += page.extract_text() return extracted_text def chatBot(resume, description): answer = chat_bot.invoke(f''' 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 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:{resume} description:{description} I want the response in one single string having the structure {{"JD Match":"%","MissingKeywords:[]", "ResumeSuggestions": [], Profile Summary":""}} ''') return answer.content description, resume = streamlit_init() submit = st.button("Analyze") if submit: if resume is not None and description != "": extract_resume = getTextFromPDF(resume) answer = chatBot(extract_resume, description) json_answer = json.loads(answer) st.subheader('Job Description Match - ') st.write(json_answer['JD Match']) st.subheader('Missing Key Words - ') formatted_keywords = "\n".join([f"{i+1}. {keyword}" for i, keyword in enumerate(json_answer['MissingKeywords'])]) st.write(formatted_keywords) st.subheader('Resume Suggestions - ') formatted_keywords = "\n".join([f"{i+1}. {keyword}" for i, keyword in enumerate(json_answer['ResumeSuggestions'])]) st.write(formatted_keywords) st.subheader('Profile Summary - ') st.write(json_answer['Profile Summary'])