from pydantic import BaseModel, Field from typing import Optional, Any # ─── JD Schemas ────────────────────────────────────────────────────────────── class JDUploadResponse(BaseModel): jd_id: str title: str engineer_type: Optional[str] min_years: float required_skills_count: int preferred_skills_count: int uploaded_at: str class JDListItem(BaseModel): jd_id: str title: str engineer_type: Optional[str] min_years: float required_skills_count: int uploaded_at: str class JDDetailResponse(JDListItem): required_skills: list[dict] preferred_skills: list[dict] responsibilities: list[str] # ─── Candidate Schemas ──────────────────────────────────────────────────────── class CandidateBatchResponse(BaseModel): batch_id: str total_count: int engineer_type_distribution: dict[str, int] uploaded_at: str class BatchListItem(BaseModel): batch_id: str total_count: int engineer_type_distribution: dict[str, int] uploaded_at: str # ─── Match Schemas ──────────────────────────────────────────────────────────── class MatchTriggerRequest(BaseModel): batch_id: str top_n: int = Field(default=10, ge=1, le=50) class MatchTriggerResponse(BaseModel): match_id: str status: str # "processing" | "completed" total_candidates: int filtered_candidates: int results: Optional[list["CandidateMatchResponse"]] = None class SkillMatchInfo(BaseModel): skill: str candidate_level: int required_level: int score: float status: str class ScoreBreakdownResponse(BaseModel): skill_score: float semantic_score: float position_score: float special_score: float final_score: float penalties: list[dict[str, Any]] class CandidateMatchResponse(BaseModel): rank: int candidate_id: str name: str current_position: str years_of_experience: float engineer_type: str final_score: float tier: str score_breakdown: ScoreBreakdownResponse matched_skills: list[SkillMatchInfo] below_level_skills: list[SkillMatchInfo] missing_skills: list[str] flags: list[str] notice_period: Optional[str] most_recent_company: Optional[str] class MatchResultsResponse(BaseModel): jd_id: str jd_title: str batch_id: str top_n: int total_matched: int candidates: list[CandidateMatchResponse] class CandidateDetailResponse(CandidateMatchResponse): explanation: Optional[str] = None explanation_cached: bool = False class StatusResponse(BaseModel): match_id: str status: str # "pending" | "processing" | "completed" | "failed" progress: Optional[float] = None message: Optional[str] = None completed_at: Optional[str] = None class ErrorResponse(BaseModel): detail: str code: Optional[str] = None # Update forward refs MatchTriggerResponse.model_rebuild()