-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
285 lines (205 loc) Β· 6 KB
/
Copy pathapp.py
File metadata and controls
285 lines (205 loc) Β· 6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
import streamlit as st
import plotly.graph_objects as go
from resume_parser import extract_text
from resume_to_json import parse_resume
from ats import ats_score
from interview import generate_questions, evaluate_answer
import plotly.express as px
st.set_page_config(
page_title="AI Interview Assistant",
page_icon="π€",
layout="wide"
)
# ---------------- Sidebar ---------------- #
st.sidebar.title("π€ AI Interview Assistant")
st.sidebar.markdown("""
### Features
- π Resume Parsing
- π― ATS Score
- πΌ Skill Match Analysis
- β AI Interview Questions
- β AI Answer Evaluation
---
Built using:
- Streamlit
- Gemini AI
- PyMuPDF
""")
if st.sidebar.button("π Start New Analysis"):
st.session_state.clear()
st.rerun()
hide_streamlit_style = """
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
header {visibility: hidden;}
</style>
"""
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
# ---------------- Main UI ---------------- #
st.title(
"π€ Smart AI Interview Assistant"
)
st.caption(
"Resume Analysis β’ ATS Matching β’ AI Mock Interview"
)
resume_file = st.file_uploader(
"Upload Resume (PDF)",
type=["pdf"]
)
job = st.text_area("Paste Job Description")
if not resume_file:
st.info("π Please upload your resume.")
elif not job.strip():
st.info("πΌ Please paste a job description.")
else:
st.success(f"Uploaded: {resume_file.name}")
with open("temp_resume.pdf", "wb") as f:
f.write(resume_file.read())
# ---------- Resume Parsing ---------- #
if "resume_json" not in st.session_state:
with st.spinner("Analyzing resume..."):
resume = extract_text("temp_resume.pdf")
st.session_state.resume_json = parse_resume(resume)
resume_json = st.session_state.resume_json
st.subheader("π Resume Summary")
c1, c2, c3 = st.columns(3)
with c1:
st.metric(
"Skills",
len(resume_json.get("skills", []))
)
with c2:
st.metric(
"Projects",
len(resume_json.get("projects", []))
)
with c3:
st.metric(
"Education",
len(resume_json.get("education", []))
)
with st.expander("View Parsed Resume JSON"):
st.json(resume_json)
# ---------- ATS ---------- #
if "ats_result" not in st.session_state:
with st.spinner("Calculating ATS Score..."):
st.session_state.ats_result = ats_score(
resume_json,
job
)
result = st.session_state.ats_result
st.subheader("π― ATS Score")
fig = go.Figure(
go.Indicator(
mode="gauge+number",
value=result["score"],
number={"suffix": "%"},
title={"text": "ATS Score"},
gauge={
"axis": {"range": [0, 100]},
"bar": {"color": "green"}
}
)
)
st.plotly_chart(fig, use_container_width=True)
score = result["score"]
if score >= 80:
st.success("π Excellent Resume")
elif score >= 60:
st.warning("π Good Resume")
else:
st.error("β Needs Improvement")
col1, col2 = st.columns(2)
with col1:
st.success("Matched Skills")
for skill in result["matched_skills"]:
st.write(f"β
{skill}")
with col2:
st.error("Missing Skills")
for skill in result["missing_skills"]:
st.write(f"β {skill}")
report = f"""
ATS SCORE: {result['score']}%
Matched Skills:
{result['matched_skills']}
Missing Skills:
{result['missing_skills']}
"""
fig = px.pie(
names=["Matched", "Missing"],
values=[
len(result["matched_skills"]),
len(result["missing_skills"])
],
hole=0.6
)
st.plotly_chart(fig, use_container_width=True)
st.download_button(
"π₯ Download ATS Report",
report,
file_name="ATS_Report.txt"
)
# ---------- Interview ---------- #
if st.button("Generate Interview Questions"):
try:
with st.spinner("Generating Interview Questions..."):
st.session_state.questions = generate_questions(
resume_json,
job
)["questions"]
except Exception:
st.error(
"Unable to generate interview questions right now."
)
# ---------- Interview ---------- #
if "questions" in st.session_state:
st.header("π€ AI Interview")
for i, q in enumerate(st.session_state.questions):
st.divider()
st.subheader(
f"π― Technical Question {i+1}"
)
st.info(q)
ans = st.text_area(
"Your Answer",
key=f"ans{i}",
height=150
)
if st.button(
"Evaluate Answer",
key=f"btn{i}"
):
if not ans.strip():
st.warning("Please type your answer before evaluation.")
continue
try:
with st.spinner("Evaluating your answer..."):
evaluation = evaluate_answer(q, ans)
st.metric(
label="Interview Score",
value=f"{evaluation['score']}/10"
)
with st.expander(
"π Feedback",
expanded=True
):
st.write(
evaluation["feedback"]
)
with st.expander(
"π‘ Ideal Answer"
):
st.write(
evaluation["ideal_answer"]
)
except Exception:
st.error(
"Unable to evaluate your answer right now. "
"Please try again later."
)
# ---------- Footer ---------- #
st.divider()
st.caption(
"Developed by Avani Rathi β’ AI Interview Assistant β’ Powered by Gemini AI"
)