Niketjain2002 commited on
Commit
58e2bc7
·
verified ·
1 Parent(s): 955e73e

Add candidate sourcing live search: src/sourcing.py

Browse files
Files changed (1) hide show
  1. src/sourcing.py +35 -1
src/sourcing.py CHANGED
@@ -10,13 +10,15 @@ from typing import Optional
10
 
11
  from .feature_extractor import LLMClient, _extract_json
12
  from .prompts.sourcing import XRAY_QUERY_GENERATION_PROMPT
 
13
 
14
 
15
  class CandidateSourcer:
16
  """Generates Google X-ray search queries to find candidates on LinkedIn."""
17
 
18
- def __init__(self, llm_client: Optional[LLMClient] = None):
19
  self.llm = llm_client or LLMClient()
 
20
 
21
  def generate_queries(
22
  self,
@@ -51,3 +53,35 @@ class CandidateSourcer:
51
  )
52
 
53
  return result
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  from .feature_extractor import LLMClient, _extract_json
12
  from .prompts.sourcing import XRAY_QUERY_GENERATION_PROMPT
13
+ from .web_search import LinkedInSearcher
14
 
15
 
16
  class CandidateSourcer:
17
  """Generates Google X-ray search queries to find candidates on LinkedIn."""
18
 
19
+ def __init__(self, llm_client: Optional[LLMClient] = None, searcher: Optional[LinkedInSearcher] = None):
20
  self.llm = llm_client or LLMClient()
21
+ self.searcher = searcher or LinkedInSearcher()
22
 
23
  def generate_queries(
24
  self,
 
53
  )
54
 
55
  return result
56
+
57
+ def find_candidates(
58
+ self,
59
+ job_description: str,
60
+ location: str = "Bangalore",
61
+ industry: str = "",
62
+ compensation_band: str = "",
63
+ company_stage: str = "",
64
+ max_queries: int = 3,
65
+ ) -> dict:
66
+ """Generate queries AND run live web search to find candidate profiles.
67
+
68
+ Returns the same dict as generate_queries() plus a 'candidates' list:
69
+ [{name, title, company, linkedin_url, snippet, source_query, matched_queries}]
70
+ """
71
+ result = self.generate_queries(
72
+ job_description=job_description,
73
+ location=location,
74
+ industry=industry,
75
+ compensation_band=compensation_band,
76
+ company_stage=company_stage,
77
+ )
78
+
79
+ # Extract raw query strings for web search
80
+ raw_queries = [q.get("query", "") for q in result.get("queries", []) if q.get("query")]
81
+
82
+ candidates = self.searcher.search_candidates(
83
+ queries=raw_queries,
84
+ max_queries=max_queries,
85
+ )
86
+ result["candidates"] = candidates
87
+ return result