Spaces:
Running on Zero
Running on Zero
fix(title): strip company pipes and modality tags from jobRole, refresh existing records on upload, and remove ZeroGPU requirement from demo
Browse filesFiles changed (4)
20 unmodified lines21222324252627282 unmodified lines3132333435363720 unmodified linesimport gradio as grfrom app.server import app as fastapi_app, adapter@spaces.GPU(duration=60)def evaluate_candidate_gpu(job_description: str, resume_text: str):res = adapter.evaluate_candidate(job_title="Candidate Evaluation",job_description=job_description or "Software Engineer",2 unmodified linesreturn json.dumps(res, indent=2)demo = gr.Interface(fn=evaluate_candidate_gpu,inputs=[gr.Textbox(label="Job Description", lines=4, placeholder="Enter job description..."),gr.Textbox(label="Resume Text", lines=4, placeholder="Enter resume text...")20 unmodified lines212223242526272 unmodified lines3031323334353620 unmodified linesimport gradio as grfrom app.server import app as fastapi_app, adapterdef evaluate_candidate_app(job_description: str, resume_text: str):res = adapter.evaluate_candidate(job_title="Candidate Evaluation",job_description=job_description or "Software Engineer",2 unmodified linesreturn json.dumps(res, indent=2)demo = gr.Interface(fn=evaluate_candidate_app,inputs=[gr.Textbox(label="Job Description", lines=4, placeholder="Enter job description..."),gr.Textbox(label="Resume Text", lines=4, placeholder="Enter resume text...")
209 unmodified lines2102112122132142152162172182 unmodified lines221222223224225226227228229230231232233234209 unmodified linesdef clean_title(title_str: Optional[str]) -> Optional[str]:"""Cleans up job titles while STRICTLY PRESERVING parenthesized tech stacks.For example: 'Full-Stack Developer (TypeScript / Node.js / React)' is kept intact.Strips leading/trailing bullets, quotes, dashes, colons, and residual artifacts."""if not title_str:return None2 unmodified linesif cleaned.lower() in EM_DASH_PLACEHOLDERS:return None# Strip only leading/trailing punctuation, bullets, quotes, and dashes (NEVER parens!)cleaned = cleaned.strip(" \t\n\r,.:;|–-—•*#\"'")# Remove residual zero-width or replacement artifacts and normalize non-breaking spacescleaned = cleaned.replace("\u00a0", " ")cleaned = re.sub(r"[\u200b\u200e\u200f\ufeff\ufffd]", "", cleaned)cleaned = re.sub(r"[ \t]+", " ", cleaned).strip()if not cleaned or cleaned.lower() in EM_DASH_PLACEHOLDERS:return None209 unmodified lines2102112122132142152162172182192202212222 unmodified lines225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259209 unmodified linesdef clean_title(title_str: Optional[str]) -> Optional[str]:"""Cleans up job titles:- Strips pipe delimiters and company/location suffixes (e.g. 'Role | Company' -> 'Role')- Strips employment modalities (e.g. '(On-site)', '(Remote)', '(Hybrid)', '(Full-time)')- Strips 'at <Company>' or '@ <Company>' suffixes- Cleans unclosed parentheses (e.g. 'Role (On-site Intern' -> 'Role')- STRICTLY PRESERVES parenthesized tech stacks (e.g. 'Full-Stack Developer (TypeScript / React)')- Strips leading/trailing bullets, quotes, dashes, colons, and residual artifacts."""if not title_str:return None2 unmodified linesif cleaned.lower() in EM_DASH_PLACEHOLDERS:return None# Remove residual zero-width or replacement artifacts and normalize non-breaking spacescleaned = cleaned.replace("\u00a0", " ")cleaned = re.sub(r"[\u200b\u200e\u200f\ufeff\ufffd]", "", cleaned)cleaned = re.sub(r"[ \t]+", " ", cleaned).strip()# 1. Split on pipe '|' delimiter (e.g. 'Generative AI Intern | Datapattern' -> 'Generative AI Intern')if "|" in cleaned:parts = [p.strip() for p in cleaned.split("|") if p.strip()]if parts:cleaned = parts[0]# 2. Strip employment modalities in parentheses (e.g. (On-site...), (Remote...), (Hybrid...))cleaned = re.sub(r"\(?\s*\b(on-?site|remote|hybrid|wfh|full-?time|part-?time|contract|freelance)\b[^\)]*\)?","",cleaned,flags=re.I,)# 3. Strip ' at <Company>' or ' @ <Company>' at end if presentcleaned = re.sub(r"\s+(?:at|@)\s+[A-Z][A-Za-z0-9\s.,&-]+$", "", cleaned)# 4. Clean unclosed trailing parentheses (e.g. 'Role (On-site Intern' -> 'Role')if "(" in cleaned and ")" not in cleaned:cleaned = re.sub(r"\(.*$", "", cleaned)# 5. Strip leading/trailing punctuation, bullets, quotes, and dashescleaned = cleaned.strip(" \t\n\r,.:;|–-—•*#\"'")if not cleaned or cleaned.lower() in EM_DASH_PLACEHOLDERS:return None
18 unmodified lines192021222324251 unmodified line27282930313218 unmodified lines' "email": "email@example.com",\n'' "phone": "+1234567890",\n'' "location": "City, Country",\n'' "jobTitle": "Target or Current Role",\n'' "skills": ["Skill 1", "Skill 2"],\n'' "education": [{"degree": "B.Tech/BS/MS", "institution": "Institution Name", "fieldOfStudy": "Field", "year": "2022"}],\n'' "workExperience": [{"title": "Job Title", "company": "Company", "dates": "2020-2023", "durationYears": 3.0, "isCurrent": false, "description": "Key accomplishments"}],\n'1 unmodified line' "projects": ["Project Name: Description"]\n'"}\n""IMPORTANT RULES:\n""- 'education', 'workExperience', and 'projects' MUST be arrays/lists of objects, NEVER dictionary mappings.\n""- Return ONLY raw minified JSON. Do not include markdown codeblocks (no ```json), explanations, or preambles.")18 unmodified lines192021222324251 unmodified line2728293031323318 unmodified lines' "email": "email@example.com",\n'' "phone": "+1234567890",\n'' "location": "City, Country",\n'' "jobTitle": "Clean Professional Job Title Only",\n'' "skills": ["Skill 1", "Skill 2"],\n'' "education": [{"degree": "B.Tech/BS/MS", "institution": "Institution Name", "fieldOfStudy": "Field", "year": "2022"}],\n'' "workExperience": [{"title": "Job Title", "company": "Company", "dates": "2020-2023", "durationYears": 3.0, "isCurrent": false, "description": "Key accomplishments"}],\n'1 unmodified line' "projects": ["Project Name: Description"]\n'"}\n""IMPORTANT RULES:\n""- 'jobTitle': Extract ONLY the professional title (e.g. 'Generative AI Intern' or 'Software Engineer'). DO NOT include company names, pipe characters ('|'), locations, or modalities like '(On-site Intern)'.\n""- 'education', 'workExperience', and 'projects' MUST be arrays/lists of objects, NEVER dictionary mappings.\n""- Return ONLY raw minified JSON. Do not include markdown codeblocks (no ```json), explanations, or preambles.")
157 unmodified lines158159160161162163157 unmodified linesexisting_has_data = bool(existing.get("extractedData")) if existing else Falseif existing and existing_has_data and (extractor_version is None or existing_version == extractor_version):logger.info(f"[Storage] Duplicate resume detected for hash {file_hash[:12]}... (Candidate ID: {existing.get('id')})")return {"candidateId": str(existing.get("id")),157 unmodified lines158159160161162163164165166167168169170171172173174175176177157 unmodified linesexisting_has_data = bool(existing.get("extractedData")) if existing else Falseif existing and existing_has_data and (extractor_version is None or existing_version == extractor_version):# Refresh jobRole / extractedData if newly parsed values are cleaner or updatedif job_role and job_role != existing.get("jobRole"):try:table = _get_table_ref(supabase, "CandidateResume")upd_payload = {"jobRole": job_role}if extracted_data:upd_payload["extractedData"] = extracted_datatable.update(upd_payload).eq("id", existing.get("id")).execute()existing["jobRole"] = job_roleif extracted_data:existing["extractedData"] = extracted_dataexcept Exception as upd_err:logger.warning(f"[Storage] Failed to refresh existing candidate jobRole: {upd_err}")logger.info(f"[Storage] Duplicate resume detected for hash {file_hash[:12]}... (Candidate ID: {existing.get('id')})")return {"candidateId": str(existing.get("id")),
app.py+2-3
app/services/post_processor.py+31-6
app/services/prompt_templates.py+2-1
app/storage/resume_storage.py+14