rca123456 commited on
Commit
fa13b9f
Β·
verified Β·
1 Parent(s): efaec8c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -26
app.py CHANGED
@@ -8,15 +8,13 @@ from langchain_groq import ChatGroq
8
  from sklearn.metrics.pairwise import cosine_similarity
9
  import numpy as np
10
  from dotenv import load_dotenv
11
- load_dotenv()
12
-
13
  import os
 
 
 
14
  groq_api_key = os.getenv("GROQ_API_KEY")
15
  os.environ["GROQ_API_KEY"] = groq_api_key
16
 
17
- import os
18
- import tempfile
19
-
20
  def extract_text_from_pdf(pdf_file):
21
  with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as temp:
22
  temp.write(pdf_file)
@@ -61,7 +59,7 @@ def generate_skill_gap_report(user_skills, job_skills, missing_skills, match_per
61
 
62
  def process_skill_gap(resume_pdf, jd_pdf):
63
  if resume_pdf is None or jd_pdf is None:
64
- return "❌ Please upload both Resume and Job Description PDFs.", "", "", ""
65
 
66
  resume_text = extract_text_from_pdf(resume_pdf)
67
  jd_text = extract_text_from_pdf(jd_pdf)
@@ -78,23 +76,34 @@ def process_skill_gap(resume_pdf, jd_pdf):
78
 
79
  report = generate_skill_gap_report(user_skills, job_skills, missing_skills, match_percent)
80
 
81
- return f"βœ… Skill Match: {match_percent}%", f"❌ Missing Skills: {', '.join(missing_skills) if missing_skills else 'None'}", f"πŸ”Ž Similarity Score: {similarity_percent}%", report
82
-
83
- demo = gr.Interface(
84
- fn=process_skill_gap,
85
- inputs=[
86
- gr.File(label="Upload Resume (PDF)", type="binary"),
87
- gr.File(label="Upload Job Description (PDF)", type="binary")
88
- ],
89
- outputs=[
90
- gr.Textbox(label="Skill Match Percentage"),
91
- gr.Textbox(label="Missing Skills"),
92
- gr.Textbox(label="Similarity Score"),
93
- gr.Textbox(label="AI-Generated Skill Gap Report")
94
- ],
95
- title="πŸ“„ Skill Gap AI Checker (Gradio + LangChain + Groq LLaMA3)",
96
- description="Upload your Resume PDF and Job Description PDF to analyze your skill match percentage, missing skills, and get an AI-generated report using Groq's LLaMA3 model."
97
- )
98
-
99
- if __name__ == "__main__":
100
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
8
  from sklearn.metrics.pairwise import cosine_similarity
9
  import numpy as np
10
  from dotenv import load_dotenv
 
 
11
  import os
12
+ import tempfile
13
+
14
+ load_dotenv()
15
  groq_api_key = os.getenv("GROQ_API_KEY")
16
  os.environ["GROQ_API_KEY"] = groq_api_key
17
 
 
 
 
18
  def extract_text_from_pdf(pdf_file):
19
  with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as temp:
20
  temp.write(pdf_file)
 
59
 
60
  def process_skill_gap(resume_pdf, jd_pdf):
61
  if resume_pdf is None or jd_pdf is None:
62
+ return 0, "❌ Please upload both Resume and Job Description PDFs.", "", "", ""
63
 
64
  resume_text = extract_text_from_pdf(resume_pdf)
65
  jd_text = extract_text_from_pdf(jd_pdf)
 
76
 
77
  report = generate_skill_gap_report(user_skills, job_skills, missing_skills, match_percent)
78
 
79
+ skill_text = f"βœ… Skill Match: {match_percent}%"
80
+ missing_text = f"❌ Missing Skills: {', '.join(missing_skills) if missing_skills else 'None'}"
81
+ similarity_text = f"πŸ”Ž Resume vs JD Similarity Score: {similarity_percent}%"
82
+
83
+ return match_percent, skill_text, missing_text, similarity_text, report
84
+
85
+ with gr.Blocks() as demo:
86
+ gr.Markdown("# 🧠 AI Skill Gap Checker")
87
+ gr.Markdown("Upload your **Resume PDF** and **Job Description PDF**. The AI will analyze your skill match and generate an improvement report.")
88
+
89
+ with gr.Row():
90
+ resume_file = gr.File(label="πŸ“„ Upload Resume (PDF)", type="binary")
91
+ jd_file = gr.File(label="πŸ“„ Upload Job Description (PDF)", type="binary")
92
+
93
+ submit_btn = gr.Button("πŸš€ Analyze Skill Gap")
94
+
95
+ gr.Markdown("## 🎯 Match Percentage")
96
+ match_slider = gr.Slider(minimum=0, maximum=100, step=1, label="Job Match Percentage (%)", interactive=False)
97
+
98
+ skill_match_text = gr.Textbox(label="Skill Match Details", interactive=False)
99
+ missing_skills_text = gr.Textbox(label="Missing Skills", interactive=False)
100
+ similarity_text = gr.Textbox(label="Resume-JD Similarity Score", interactive=False)
101
+ report_output = gr.Textbox(label="AI-Generated Skill Gap Report", lines=10, interactive=False)
102
+
103
+ submit_btn.click(
104
+ fn=process_skill_gap,
105
+ inputs=[resume_file, jd_file],
106
+ outputs=[match_slider, skill_match_text, missing_skills_text, similarity_text, report_output]
107
+ )
108
+
109
+ demo.launch()