Spaces:
Sleeping
Sleeping
File size: 1,521 Bytes
1595f22 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | import json
from pathlib import Path
from typing import List, Dict, Any
from crewai.tools import tool
from core.jd_processor import generate_jd_rubric
from core.resume_parser import parse_resume
from core.matcher import match_candidate_to_jd
from core.ranking import build_ranking
from utils.file_loader import load_text_from_file
@tool("generate_jd_rubric_tool")
def generate_jd_rubric_tool(jd_text: str) -> str:
"""Generate a structured JD rubric JSON (string) from JD text."""
rubric = generate_jd_rubric(jd_text)
return json.dumps(rubric, ensure_ascii=False)
@tool("parse_resume_tool")
def parse_resume_tool(resume_text: str, filename: str) -> str:
"""Parse a resume into candidate JSON (string) from resume text."""
candidate = parse_resume(resume_text, filename)
return json.dumps(candidate, ensure_ascii=False)
@tool("match_candidate_tool")
def match_candidate_tool(jd_rubric_json: str, candidate_json: str) -> str:
"""Match a candidate against JD rubric; returns match JSON (string)."""
jd_rubric = json.loads(jd_rubric_json)
candidate = json.loads(candidate_json)
match_result = match_candidate_to_jd(jd_rubric, candidate)
return json.dumps(match_result, ensure_ascii=False)
@tool("build_ranking_tool")
def build_ranking_tool(top_k: int) -> str:
"""Build ranking from data/matches; returns ranking JSON (string)."""
ranking = build_ranking(top_k=int(top_k))
return json.dumps(ranking, ensure_ascii=False)
|