File size: 7,555 Bytes
5a90530 a839913 5a90530 0839406 ae37458 a839913 63bf957 0839406 ae37458 05d4db1 a839913 0839406 a839913 63bf957 a839913 05d4db1 a839913 464c674 a839913 464c674 a839913 464c674 a839913 025c126 a839913 025c126 a839913 05d4db1 a839913 05d4db1 a839913 5a90530 08462f0 | 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 | """
MATCH.AI β AI Resume Screener & Feedback System
Hugging Face Gradio Space Entry Point
"""
import os
import gradio as gr
try:
import spaces
except ImportError:
class spaces:
@staticmethod
def GPU(fn):
return fn
from resume_scanner.assessor import ResumeAssessor
from resume_scanner.extractor import extract_text_from_file, prepare_scanner_inputs
@spaces.GPU
def scan_resume_gradio(resume_file, jd_file, jd_text) -> tuple:
if not resume_file:
return (
"β οΈ Error: Please upload a candidate resume file (.pdf, .docx, or .txt).",
0,
"No evaluation rationale.",
"",
"",
"",
)
try:
resume_path = resume_file.name
jd_path = jd_file.name if jd_file else resume_path
if jd_file:
resume_extracted, jd_extracted = prepare_scanner_inputs(resume_path, jd_path)
elif jd_text and jd_text.strip():
resume_extracted = extract_text_from_file(resume_path, label="Resume")
jd_extracted = jd_text.strip()
else:
return (
"β οΈ Error: Please provide either a Job Description file or paste Job Description text.",
0,
"",
"",
"",
"",
)
assessor = ResumeAssessor()
result = assessor.assess(resume_extracted, jd_extracted)
score = result.match_score
rationale = result.score_rationale
matched = "\n".join([f"β
{item}" for item in result.matched_requirements]) or "None"
missing = "\n".join([f"β οΈ {item}" for item in result.missing_requirements]) or "None"
suggestions = "\n".join([f"π‘ {item}" for item in result.suggestions]) or "None"
status_msg = f"π Scan Complete! Match Score: {score}/100"
return status_msg, score, rationale, matched, missing, suggestions
except Exception as exc:
return f"β Error during assessment: {str(exc)}", 0, str(exc), "", "", ""
def run_demo_gradio() -> tuple:
try:
sample_resume = "data/sample_resume.txt"
sample_jd = "data/sample_jd.txt"
resume_extracted, jd_extracted = prepare_scanner_inputs(sample_resume, sample_jd)
assessor = ResumeAssessor()
result = assessor.assess(resume_extracted, jd_extracted)
score = result.match_score
rationale = result.score_rationale
matched = "\n".join([f"β
{item}" for item in result.matched_requirements]) or "None"
missing = "\n".join([f"β οΈ {item}" for item in result.missing_requirements]) or "None"
suggestions = "\n".join([f"π‘ {item}" for item in result.suggestions]) or "None"
return (
f"β‘ 1-Click Demo Assessment Complete! Score: {score}/100",
score,
rationale,
matched,
missing,
suggestions,
)
except Exception as exc:
return f"β Demo error: {str(exc)}", 0, str(exc), "", "", ""
CUSTOM_CSS = """
.gradio-container {
background: radial-gradient(circle at 10% 20%, rgb(11, 15, 25) 0%, rgb(17, 24, 39) 90%) !important;
color: #f3f4f6 !important;
font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
}
.hero-banner {
background: linear-gradient(135deg, rgba(6, 182, 212, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
border: 1px solid rgba(6, 182, 212, 0.3);
border-radius: 16px;
padding: 24px;
margin-bottom: 20px;
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
backdrop-filter: blur(12px);
}
.hero-title {
background: linear-gradient(135deg, #22d3ee 0%, #c084fc 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-size: 2.2rem;
font-weight: 800;
margin-bottom: 8px;
}
button.primary {
background: linear-gradient(135deg, #06b6d4 0%, #8b5cf6 100%) !important;
border: none !important;
color: white !important;
font-weight: 700 !important;
box-shadow: 0 0 15px rgba(6, 182, 212, 0.4) !important;
transition: all 0.3s ease !important;
}
button.primary:hover {
transform: translateY(-2px) !important;
box-shadow: 0 0 25px rgba(139, 92, 246, 0.7) !important;
}
"""
with gr.Blocks(
title="MATCH.AI β Executive AI Resume Screener Studio",
theme=gr.themes.Base(
primary_hue="cyan",
secondary_hue="purple",
neutral_hue="slate",
font=[gr.themes.GoogleFont("Inter"), "ui-sans-serif", "system-ui"],
),
css=CUSTOM_CSS,
) as demo:
gr.HTML('''
<div class="hero-banner">
<div class="hero-title">π MATCH.AI β Executive AI Resume Screener Studio</div>
<p style="color: #cbd5e1; font-size: 1.05rem; margin: 0;">
Enterprise deterministic AI screening powered by <b>Google Gemini Flash</b> & <b>Pydantic AI</b>.
Equipped with Hallucination Grounding Verification & Zero-Bias Structured Analysis.
</p>
</div>
''')
with gr.Row():
with gr.Column(scale=5):
gr.Markdown("### π Candidate Documents")
resume_input = gr.File(
label="Upload Candidate Resume (.pdf, .docx, .doc, .txt)",
file_types=[".pdf", ".docx", ".doc", ".txt"],
)
jd_input = gr.File(
label="Upload Job Description (.pdf, .docx, .doc, .txt) [Optional if pasting text below]",
file_types=[".pdf", ".docx", ".doc", ".txt"],
)
jd_text_input = gr.Textbox(
label="Or Paste Job Description Text",
lines=5,
placeholder="Paste job requirements here...",
)
with gr.Row():
scan_btn = gr.Button("β‘ Run AI Scan", variant="primary")
demo_btn = gr.Button("π 1-Click Sample Demo", variant="secondary")
with gr.Column(scale=6):
gr.Markdown("### π AI Executive Assessment Results")
status_output = gr.Textbox(label="Status", interactive=False)
score_output = gr.Number(label="Match Score (0 - 100)", interactive=False)
rationale_output = gr.Textbox(
label="Executive Evaluation Rationale", lines=4, interactive=False
)
with gr.Row():
matched_output = gr.Textbox(
label="β
Matched Qualifications", lines=5, interactive=False
)
missing_output = gr.Textbox(
label="β οΈ Identified Skill Gaps", lines=5, interactive=False
)
suggestions_output = gr.Textbox(
label="π‘ Actionable Presentation Suggestions", lines=4, interactive=False
)
scan_btn.click(
fn=scan_resume_gradio,
inputs=[resume_input, jd_input, jd_text_input],
outputs=[
status_output,
score_output,
rationale_output,
matched_output,
missing_output,
suggestions_output,
],
show_api=False,
)
demo_btn.click(
fn=run_demo_gradio,
inputs=[],
outputs=[
status_output,
score_output,
rationale_output,
matched_output,
missing_output,
suggestions_output,
],
show_api=False,
)
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", server_port=7860, show_api=False)
|