File size: 3,309 Bytes
ff7b177
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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()