riteshkokam commited on
Commit
389e4f5
·
verified ·
1 Parent(s): 9f98eac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -73,6 +73,8 @@ def scrape_linkedin(keywords, location, start=0):
73
 
74
  # 4. Semantic ranking
75
  def rank_jobs(resume_text, jobs):
 
 
76
  r_emb = embedder.encode([resume_text])
77
  j_embs = embedder.encode([j["description"] for j in jobs])
78
  sims = cosine_similarity(r_emb, j_embs)[0]
@@ -94,13 +96,21 @@ def find_jobs(file, add_keywords, location, use_ai):
94
  txt = extract_text(file)
95
  keywords = " ".join(add_keywords) if add_keywords else " ".join(extract_keywords(txt)[:3])
96
  jobs = scrape_linkedin(keywords, location)
 
 
 
97
  ranked = rank_jobs(txt, jobs)
 
 
 
98
  table = [{
99
  "Role": j["title"], "Company": j["company"],
100
  "Location": j["location"], "Posted": j["date"],
101
  "Score": f"{s*100:.1f}%", "Apply": j["url"]
102
  } for j, s in ranked]
103
- return table, refine_with_ai(ranked, txt) if use_ai else ""
 
 
104
 
105
  # 7. Gradio UI
106
  with gr.Blocks(theme=gr.themes.Base()) as demo:
 
73
 
74
  # 4. Semantic ranking
75
  def rank_jobs(resume_text, jobs):
76
+ if not jobs:
77
+ return []
78
  r_emb = embedder.encode([resume_text])
79
  j_embs = embedder.encode([j["description"] for j in jobs])
80
  sims = cosine_similarity(r_emb, j_embs)[0]
 
96
  txt = extract_text(file)
97
  keywords = " ".join(add_keywords) if add_keywords else " ".join(extract_keywords(txt)[:3])
98
  jobs = scrape_linkedin(keywords, location)
99
+ if not jobs:
100
+ return [], "No jobs found—check your keywords or location."
101
+
102
  ranked = rank_jobs(txt, jobs)
103
+ if not ranked:
104
+ return [], "Job listing found, but no matchable descriptions available."
105
+
106
  table = [{
107
  "Role": j["title"], "Company": j["company"],
108
  "Location": j["location"], "Posted": j["date"],
109
  "Score": f"{s*100:.1f}%", "Apply": j["url"]
110
  } for j, s in ranked]
111
+
112
+ ai_note = refine_with_ai(ranked, txt) if use_ai else ""
113
+ return table, ai_note
114
 
115
  # 7. Gradio UI
116
  with gr.Blocks(theme=gr.themes.Base()) as demo: