sancharikadebnath commited on
Commit
4a2e94e
·
1 Parent(s): 261e2bf

Add application file

Browse files
Files changed (3) hide show
  1. app.py +43 -0
  2. ats.py +118 -0
  3. requirements.txt +11 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import streamlit as st
3
+ import pdfplumber
4
+ import ats
5
+ import docx
6
+
7
+ st.set_page_config(page_title='CareerEnchanter', page_icon='🤖', layout='centered')
8
+
9
+ st.title("Enchant your Career")
10
+
11
+ uploaded_file = st.file_uploader("Choose a document file", type=["pdf", "txt", "csv", "docx"])
12
+ text = ''
13
+ if uploaded_file is not None:
14
+ st.write("File uploaded successfully!")
15
+
16
+ file_extension = uploaded_file.name.split(".")[-1]
17
+
18
+ if file_extension == "pdf":
19
+ with pdfplumber.open(uploaded_file) as pdf:
20
+ pages = pdf.pages
21
+ for page in pages:
22
+ text = page.extract_text()
23
+
24
+ elif file_extension == "txt":
25
+ text = uploaded_file.getvalue().decode("utf-8")
26
+
27
+ elif file_extension == "docx":
28
+ docx_text = docx.Document(uploaded_file)
29
+ full_text = []
30
+ for para in docx_text.paragraphs:
31
+ full_text.append(para.text)
32
+ text = "\n".join(full_text)
33
+
34
+ st.text_area("Extracted From Document",value=text)
35
+ st.session_state['doc_text'] = text
36
+
37
+ col1, col2, col3 = st.columns([3, 3,3])
38
+ option = st.radio("I want to use: ", ("ATS"), horizontal=True)
39
+
40
+
41
+ if option == "ATS":
42
+ ats.run_ats(st.session_state['doc_text'])
43
+
ats.py ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import pyperclip
3
+ import streamlit as st
4
+ from dotenv import load_dotenv
5
+ import speech_recognition as sr
6
+ import google.generativeai as genai
7
+ from langchain.prompts import PromptTemplate
8
+ from langchain_google_genai import ChatGoogleGenerativeAI
9
+
10
+
11
+ class ATS(object):
12
+ def __init__(self, title="ATS Tracking System"):
13
+ self.title = title
14
+
15
+ @staticmethod
16
+ def model():
17
+ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
18
+ return ChatGoogleGenerativeAI(model="gemini-pro")
19
+
20
+ @staticmethod
21
+ def get_gemini_response(llm, input_text, doc, template, info=''):
22
+ formated_prompt = template.format(doc=doc, input_text=input_text)
23
+ response = llm.invoke(formated_prompt)
24
+ return response.content
25
+ # return formated_prompt
26
+
27
+ @staticmethod
28
+ def copy_text(answer, copy_button=False):
29
+ pyperclip.copy(answer)
30
+ if copy_button:
31
+ st.toast("Text copied to clipboard!", icon="📋")
32
+
33
+ @staticmethod
34
+ def record_audio():
35
+ r = sr.Recognizer()
36
+ with st.spinner("Recording..."):
37
+ with sr.Microphone() as source:
38
+ r.adjust_for_ambient_noise(source)
39
+ with st.spinner("Say Something..."):
40
+ audio = r.listen(source, timeout=5)
41
+ with st.spinner("Processing..."):
42
+ try:
43
+ text = r.recognize_google(audio)
44
+ st.session_state['input_text'] = text
45
+ return text
46
+ except sr.UnknownValueError:
47
+ st.write("Sorry, I could not understand what you said. Please try again or write in text box.")
48
+ return ""
49
+ except sr.RequestError as e:
50
+ st.write(f"Could not request results; {e}")
51
+ return ""
52
+
53
+ @staticmethod
54
+ def input_state(input_text):
55
+ if isinstance(input_text, str):
56
+ st.session_state['input_text'] = input_text
57
+
58
+
59
+ def run_ats(doc=''):
60
+ load_dotenv()
61
+ ats = ATS()
62
+ st.header(ats.title + " 🤖", divider='rainbow')
63
+ input_text=st.text_area("Job Description: ",key="input")
64
+ # uploaded_file=st.file_uploader("Upload your resume(PDF)...",type=["pdf"])
65
+
66
+
67
+ # if uploaded_file is not None:
68
+ # st.write("PDF Uploaded Successfully")
69
+
70
+
71
+ with st.sidebar:
72
+ st.title(' :blue[_AI Generated ATS] 🤖')
73
+ st.subheader('Parameters')
74
+
75
+ with st.spinner("Loading Model..."):
76
+ llm = ats.model()
77
+ submit1 = st.button("Tell Me About the Resume")
78
+
79
+ # submit2 = st.button("How Can I Improvise my Skills")
80
+
81
+ submit3 = st.button("Percentage match")
82
+
83
+ input_prompt1 = """
84
+ You are an experienced Technical Human Resource Manager,your task is to review the provided resume against the job description.
85
+ Please share your professional evaluation on whether the candidate's profile aligns with the role.
86
+ Highlight the strengths and weaknesses of the applicant in relation to the specified job requirements.
87
+
88
+ Job Description: {input_text}
89
+ Resume: {doc}
90
+ """
91
+
92
+ input_prompt3 = """
93
+ You are an skilled ATS (Applicant Tracking System) scanner with a deep understanding of data science and ATS functionality,
94
+ your task is to evaluate the resume against the provided job description. give me the percentage of match if the resume matches
95
+ the job description. First the output should come as percentage and then keywords missing and last final thoughts.
96
+
97
+ Job Description: {input_text}
98
+ Resume: {doc}
99
+ """
100
+
101
+ if submit1:
102
+ if doc is not None:
103
+ response=ats.get_gemini_response(llm=llm,template=input_prompt1,doc=doc,input_text=input_text)
104
+ st.subheader("The Repsonse is")
105
+ st.write(response)
106
+ else:
107
+ st.write("Please uplaod the resume")
108
+
109
+ elif submit3:
110
+ if doc is not None:
111
+ response=ats.get_gemini_response(llm=llm,template=input_prompt3,doc=doc,input_text=input_text)
112
+ st.subheader("The Repsonse is")
113
+ st.write(response)
114
+ else:
115
+ st.write("Please uplaod the resume")
116
+
117
+ if __name__ == "__main__":
118
+ run_ats()
requirements.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ google-generativeai
2
+ langchain-google-genai
3
+ langchain
4
+ streamlit
5
+ pyperclip
6
+ huggingface_hub
7
+ python-dotenv
8
+ SpeechRecognition
9
+ PyAudio
10
+ pdfplumber
11
+ python-docx