nadish1210 commited on
Commit
6f3126a
Β·
verified Β·
1 Parent(s): 2790b20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -38
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
- if not job_description or len(job_description.strip()) < 20:
 
13
  return "❌ Job description too short", None, None
14
 
15
- results, summary, _, zip_path = screen_resumes_backend(
16
- job_description,
17
- files,
18
- model_option,
19
- threshold
20
- )
21
-
22
- df = pd.DataFrame(results) if results else None
23
-
24
- return summary, df, zip_path
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.HTML("""
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
- model_choice = gr.Dropdown(
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, step=0.05, label="Threshold")
52
 
53
- file_input = gr.File(
54
- label="Upload CVs (PDF/DOCX)",
55
- file_count="multiple"
56
- )
 
 
 
 
 
57
 
58
  btn = gr.Button("Process")
59
 
60
  output_text = gr.Markdown()
61
  output_table = gr.DataFrame()
62
- download_file = gr.File()
63
 
64
  btn.click(
65
  process,
66
- inputs=[job_desc, file_input, model_choice, threshold],
67
- outputs=[output_text, output_table, download_file]
68
  )
69
 
70
- if __name__ == "__main__":
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()