Update app.py
Browse files
app.py
CHANGED
|
@@ -4,24 +4,37 @@ import traceback
|
|
| 4 |
from model import screen_resumes_backend
|
| 5 |
|
| 6 |
|
| 7 |
-
def process(job_description, files, model_option, threshold):
|
| 8 |
-
try:
|
| 9 |
-
if not files:
|
| 10 |
-
return "β Upload CV files first", None, None
|
| 11 |
|
| 12 |
-
|
|
|
|
| 13 |
return "β Job description too short", None, None
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
except Exception as e:
|
| 27 |
return f"β Error: {str(e)}\n{traceback.format_exc()}", None, None
|
|
@@ -30,42 +43,37 @@ def process(job_description, files, model_option, threshold):
|
|
| 30 |
# ================= UI =================
|
| 31 |
with gr.Blocks(title="AI Resume Screener") as demo:
|
| 32 |
|
| 33 |
-
gr.
|
| 34 |
-
<h1 style="text-align:center; color:#2563eb;">
|
| 35 |
-
π§ AI Resume Screening System
|
| 36 |
-
</h1>
|
| 37 |
-
""")
|
| 38 |
|
| 39 |
-
job_desc = gr.Textbox(
|
| 40 |
-
label="Job Description",
|
| 41 |
-
lines=8,
|
| 42 |
-
placeholder="Enter job requirements..."
|
| 43 |
-
)
|
| 44 |
|
| 45 |
-
|
| 46 |
["Fast (MiniLM)", "Balanced (Recommended)", "High Accuracy"],
|
| 47 |
-
value="Balanced (Recommended)"
|
| 48 |
-
label="Model"
|
| 49 |
)
|
| 50 |
|
| 51 |
-
threshold = gr.Slider(0.4, 0.9, value=0.6
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
btn = gr.Button("Process")
|
| 59 |
|
| 60 |
output_text = gr.Markdown()
|
| 61 |
output_table = gr.DataFrame()
|
| 62 |
-
|
| 63 |
|
| 64 |
btn.click(
|
| 65 |
process,
|
| 66 |
-
inputs=[job_desc,
|
| 67 |
-
outputs=[output_text, output_table,
|
| 68 |
)
|
| 69 |
|
| 70 |
-
|
| 71 |
-
demo.launch()
|
|
|
|
| 4 |
from model import screen_resumes_backend
|
| 5 |
|
| 6 |
|
| 7 |
+
def process(job_description, files, model_option, threshold, gmail, password):
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
try:
|
| 10 |
+
if not job_description or len(job_description) < 20:
|
| 11 |
return "β Job description too short", None, None
|
| 12 |
|
| 13 |
+
# if email provided β use Gmail mode
|
| 14 |
+
if gmail and password:
|
| 15 |
+
results, report, zip_path = screen_resumes_backend(
|
| 16 |
+
job_description,
|
| 17 |
+
files=None,
|
| 18 |
+
model_name=model_option,
|
| 19 |
+
threshold=threshold,
|
| 20 |
+
gmail=gmail,
|
| 21 |
+
password=password
|
| 22 |
+
)
|
| 23 |
+
else:
|
| 24 |
+
# file upload mode
|
| 25 |
+
if not files:
|
| 26 |
+
return "β Upload files or provide email", None, None
|
| 27 |
+
|
| 28 |
+
results, report, zip_path = screen_resumes_backend(
|
| 29 |
+
job_description,
|
| 30 |
+
files,
|
| 31 |
+
model_option,
|
| 32 |
+
threshold
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
df = pd.DataFrame(results)
|
| 36 |
+
|
| 37 |
+
return "β
Process Completed", df, zip_path
|
| 38 |
|
| 39 |
except Exception as e:
|
| 40 |
return f"β Error: {str(e)}\n{traceback.format_exc()}", None, None
|
|
|
|
| 43 |
# ================= UI =================
|
| 44 |
with gr.Blocks(title="AI Resume Screener") as demo:
|
| 45 |
|
| 46 |
+
gr.Markdown("# π§ AI Resume Screening System")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
job_desc = gr.Textbox(label="Job Description", lines=6)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
model = gr.Dropdown(
|
| 51 |
["Fast (MiniLM)", "Balanced (Recommended)", "High Accuracy"],
|
| 52 |
+
value="Balanced (Recommended)"
|
|
|
|
| 53 |
)
|
| 54 |
|
| 55 |
+
threshold = gr.Slider(0.4, 0.9, value=0.6)
|
| 56 |
|
| 57 |
+
# π₯ NEW: EMAIL SECTION
|
| 58 |
+
gr.Markdown("## π§ Email Integration (Optional)")
|
| 59 |
+
|
| 60 |
+
gmail = gr.Textbox(label="Gmail Address")
|
| 61 |
+
password = gr.Textbox(label="App Password (NOT normal password)", type="password")
|
| 62 |
+
|
| 63 |
+
gr.Markdown("OR Upload Files Below π")
|
| 64 |
+
|
| 65 |
+
files = gr.File(file_count="multiple", label="Upload CVs (PDF/DOCX)")
|
| 66 |
|
| 67 |
btn = gr.Button("Process")
|
| 68 |
|
| 69 |
output_text = gr.Markdown()
|
| 70 |
output_table = gr.DataFrame()
|
| 71 |
+
download_zip = gr.File()
|
| 72 |
|
| 73 |
btn.click(
|
| 74 |
process,
|
| 75 |
+
inputs=[job_desc, files, model, threshold, gmail, password],
|
| 76 |
+
outputs=[output_text, output_table, download_zip]
|
| 77 |
)
|
| 78 |
|
| 79 |
+
demo.launch()
|
|
|