File size: 13,148 Bytes
478dec6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f3bdba1
478dec6
 
 
f3bdba1
478dec6
 
 
f3bdba1
478dec6
 
 
 
 
 
e4b8ed7
 
 
 
478dec6
abc3feb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
478dec6
 
 
 
 
 
 
 
6a0f2f3
b0853c5
 
6a0f2f3
b0853c5
 
6a0f2f3
b0853c5
 
478dec6
6a0f2f3
b0853c5
 
 
 
478dec6
 
 
6a0f2f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
478dec6
 
 
 
 
 
 
 
 
 
 
6a0f2f3
478dec6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
from config.get_config import master_config
from datetime import datetime
from pydantic import Field, BaseModel
from typing import Optional, List, Literal, Dict
from typing_extensions import TypedDict
from uuid import uuid4



tzinfo = master_config.tzinfo

LOGIC_NUMERIC = Literal["greater than", 
                         "less than", 
                         "equal",
                         "greater than or equal",
                         "less than or equal" 
                         ]

LOGIC_CATEGORICAL = Literal[ 
                         "equal",
                         "similar", 
                         "not similar"]


class RawProfile(TypedDict):
    profile_id: str
    content_type: Literal["pdf", "docx", "txt"] = "pdf"
    filename: str
    content: str

class AIProfile(TypedDict):
    fullname: str = Field(description="Fullname of the candidate", default="-")
    # gender: str = Field(description="Gender of the candidate, if available", default="null")
    # age: int = Field(description="Age in number")
    gpa_edu_1: float = Field(description="""GPA of candidate's bachelor degree (same like sarjana, s1, undergradute), if exists.""", default=0)
    univ_edu_1: str = Field(description="""University where candidate take bachelor degree, if exists.""", default="-")
    major_edu_1: str = Field(description="""Major of candidate's bachelor degree, if exists.""", default="-")
    
    gpa_edu_2: float = Field(description="""GPA of candidate's master degree (same like master, s2, postgraduate), if exists.""", default=0)
    univ_edu_2: str = Field(description="""University where candidate take master degree, if exists.""", default="-")
    major_edu_2: str = Field(description="""Major of candidate's master degree, if exists.""", default="-")
    
    gpa_edu_3: float = Field(description="""GPA of candidate's doctoral or phd degree (same like phd, s3, doctoral), if exists.""", default=0)
    univ_edu_3: str = Field(description="""University where candidate take doctoral or phd degree, if exists.""", default="-")
    major_edu_3: str = Field(description="""Major of candidate's doctoral or phd degree, if exists.""", default="-")
    
    domicile: str = Field(description="Current domicile of the candidate", default="-")

    yoe: float = Field(description="The candidate's total years of experience (as an float)", default=0)
    hardskills: Optional[List[str]] = Field(description="List of the candidate's hard skills",default_factory=list)
    softskills: Optional[List[str]] = Field(description="List of the candidate's soft skills", default_factory=list)
    certifications: Optional[List[str]] = Field(description="List of the candidate's certifications", default_factory=list)
    business_domain: Optional[List[str]] = Field(description="List of the candidate's business domain experience based on working experience or project", default_factory=list)

class AIProfileTbScore(TypedDict):
    fullname: str = Field(description="Fullname of the candidate", default="-")
    # gender: str = Field(description="Gender of the candidate, if available", default="null")
    # age: int = Field(description="Age in number")
    gpa_edu_1: float = Field(description="""GPA of candidate's bachelor degree (same like sarjana, s1, undergradute), if exists.""", default=0)
    univ_edu_1: list = Field(description="""University where candidate take bachelor degree, if exists.""", default="-")
    major_edu_1: list = Field(description="""Major of candidate's bachelor degree, if exists.""", default="-")
    
    gpa_edu_2: float = Field(description="""GPA of candidate's master degree (same like master, s2, postgraduate), if exists.""", default=0)
    univ_edu_2: list = Field(description="""University where candidate take master degree, if exists.""", default="-")
    major_edu_2: list = Field(description="""Major of candidate's master degree, if exists.""", default="-")
    
    gpa_edu_3: float = Field(description="""GPA of candidate's doctoral or phd degree (same like phd, s3, doctoral), if exists.""", default=0)
    univ_edu_3: list = Field(description="""University where candidate take doctoral or phd degree, if exists.""", default="-")
    major_edu_3: list = Field(description="""Major of candidate's doctoral or phd degree, if exists.""", default="-")
    
    domicile: str = Field(description="Current domicile of the candidate", default="-")

    yoe: float = Field(description="The candidate's total years of experience (as an float)", default=0)
    hardskills: Optional[List[str]] = Field(description="List of the candidate's hard skills",default_factory=list)
    softskills: Optional[List[str]] = Field(description="List of the candidate's soft skills", default_factory=list)
    certifications: Optional[List[str]] = Field(description="List of the candidate's certifications", default_factory=list)
    business_domain: Optional[List[str]] = Field(description="List of the candidate's business domain experience based on working experience or project", default_factory=list)


class Profile(AIProfile):
    profile_id: str
    created_at: datetime = datetime.now().replace(tzinfo=tzinfo)

class Profiles(TypedDict):
    profiles: List[Profile]

class Criteria(TypedDict):
    gpa_edu_1: Optional[float] = 0
    univ_edu_1: Optional[List] = []
    major_edu_1: Optional[List] = []
    gpa_edu_2: Optional[float] = 0
    univ_edu_2: Optional[List] = []
    major_edu_2: Optional[List] = []
    gpa_edu_3: Optional[float] = 0
    univ_edu_3: Optional[List] = []
    major_edu_3: Optional[List] = []
    domicile: Optional[str] = None
    yoe: Optional[int] = 0
    hardskills: Optional[List] = []
    softskills: Optional[List] = []
    certifications: Optional[List] = []
    business_domain: Optional[List] = []


class CriteriaWeight(TypedDict):
    gpa_edu_1: Optional[float] = 0
    univ_edu_1: Optional[float] = 0
    major_edu_1: Optional[float] = 0
    gpa_edu_2: Optional[float] = 0
    univ_edu_2: Optional[float] = 0
    major_edu_2: Optional[float] = 0
    gpa_edu_3: Optional[float] = 0
    univ_edu_3: Optional[float] = 0
    major_edu_3: Optional[float] = 0
    domicile: Optional[float] = 0
    yoe: Optional[float] = 0
    hardskills: Optional[float] = 0
    softskills: Optional[float] = 0
    certifications: Optional[float] = 0
    business_domain: Optional[float] = 0


# class InputScoring(AIProfile):
#     profile_id: str = Field(description="profile id")
#     criteria: Criteria = Field(description="Criteria to be matched with the profile")
#     criteria_weight: CriteriaWeight = Field(description="Criteria weight to be applied when profile matching")

class InputScoring(TypedDict):
    profile_id: str = Field(description="profile id")
    weight_id: str =  Field(description="weight id")

class InputScoringBulk(TypedDict): #TODO: USE THIS ON /v2/calculate_score
    criteria: Criteria = Field(description="Criteria to be matched with the profile")
    criteria_weight: CriteriaWeight = Field(description="Criteria weight to be applied when profile matching")

class PayloadExtractOne(TypedDict):
    profile_id: str = str(uuid4())
    filename: str
    content_type: Literal["pdf", "docx", "txt"] = "pdf"
    content: str
class DataResponseExtractOne(TypedDict):
    profile_id: Optional[str]
class ResponseExtractOne(TypedDict):
    status: Literal["success", "failed", "canceled"]
    message: Optional[str] = "empty"
    data: Optional[DataResponseExtractOne] = None
    

# EXTRACT PROFILE BULK
class DataResponseExtractBulk(TypedDict):
    status_ids: Dict
    criteria_id: str
class PayloadExtractBulk(TypedDict):
    profile_id: str
    content_type: Literal["pdf", "docx", "txt"] = "pdf"
    content: str
class ResponseExtractBulk(TypedDict):
    status: Literal["success", "partial-success", "failed", "canceled"]
    message: Optional[str]
    data: Optional[DataResponseExtractBulk] = None


# MATCH PROFILE ONE
class PayloadMatchOne(TypedDict):
    profile_id: str
    criteria: Criteria
    criteria_weight: CriteriaWeight

class Score(TypedDict):
    profile_id: str
    score: float
class DataResponseMatchOne(TypedDict):
    profile_id: str
    criteria_id: Optional[str] = None
    matching_id: Optional[str] = None
    scoring_id: Optional[str] = None
    score: Optional[float] = None
class ResponseMatchOne(Score):
    status: Literal["success", "failed", "canceled"]
    message: Optional[str] = None
    data: Optional[DataResponseMatchOne] = None


# MATCH PROFILE BULK
class DataResponseMatchBulk(TypedDict):
    status_ids: Dict
    criteria_id: str
class PayloadMatchBulk(TypedDict):
    filter: List[str]
    criteria: Criteria
    criteria_weight: CriteriaWeight
class ResponseMatchBulk(TypedDict):
    status: Literal["success", "partial-success", "failed", "canceled"]
    message: Optional[str]
    data: Optional[DataResponseExtractBulk] = None

# class DataResponseExtractBulk(TypedDict):
#     status_ids: Dict
#     criteria_id: str
# class PayloadExtractBulk(TypedDict):
#     profile_id: str
#     content_type: Literal["pdf", "docx", "txt"] = "pdf"
#     content: str
# class ResponseExtractBulk(TypedDict):
#     status: Literal["success", "partial-success", "failed", "canceled"]
#     message: Optional[str]
#     data: Optional[DataResponseExtractBulk] = None


desc_AIMatchProfile = "choose 1 if match else 0"
class AIMatchProfile(TypedDict):
    gpa_edu_1: Optional[Literal[1, 0]] = Field(description=desc_AIMatchProfile, default=None)
    univ_edu_1: Optional[Literal[1, 0]] = Field(description=desc_AIMatchProfile, default=None)
    major_edu_1: Optional[Literal[1, 0]] = Field(description=desc_AIMatchProfile, default=None)
    gpa_edu_2: Optional[Literal[1, 0]] = Field(description=desc_AIMatchProfile, default=None)
    univ_edu_2: Optional[Literal[1, 0]] = Field(description=desc_AIMatchProfile, default=None)
    major_edu_2: Optional[Literal[1, 0]] = Field(description=desc_AIMatchProfile, default=None)
    gpa_edu_3: Optional[Literal[1, 0]] = Field(description=desc_AIMatchProfile, default=None)
    univ_edu_3: Optional[Literal[1, 0]] = Field(description=desc_AIMatchProfile, default=None)
    major_edu_3: Optional[Literal[1, 0]] = Field(description=desc_AIMatchProfile, default=None)
    domicile: Optional[Literal[1, 0]] = Field(description=desc_AIMatchProfile, default=None)
    yoe: Optional[Literal[1, 0]] = Field(description=desc_AIMatchProfile, default=None)
    hardskills: Optional[Literal[1, 0]] = Field(description=desc_AIMatchProfile, default=None)
    softskills: Optional[Literal[1, 0]] = Field(description=desc_AIMatchProfile, default=None)
    certifications: Optional[Literal[1, 0]] = Field(description=desc_AIMatchProfile, default=None)
    business_domain: Optional[Literal[1, 0]] = Field(description=desc_AIMatchProfile, default=None)


class OutProfile(BaseModel):
    fullname: str = Field(description="Fullname of the candidate", default="-")
    # gender: str = Field(description="Gender of the candidate, if available", default="null")
    # age: int = Field(description="Age in number")
    high_edu_univ_1: str = Field(description="""University where candidate take bachelor degree, if exists.""", default="-")
    high_edu_major_1: str = Field(description="""Major of candidate's bachelor degree, if exists.""", default="-")
    high_edu_gpa_1: float = Field(description="""GPA of candidate's bachelor degree, if exists.""", default=0)
    
    high_edu_univ_2: str = Field(description="""University where candidate take master degree, if exists.""", default="-")
    high_edu_major_2: str = Field(description="""Major of candidate's master degree, if exists.""", default="-")
    high_edu_gpa_2: float = Field(description="""GPA of candidate's master degree, if exists.""", default=0)
    
    high_edu_univ_3: str = Field(description="""University where candidate take doctoral or phd degree, if exists.""", default="-")
    high_edu_major_3: str = Field(description="""Major of candidate's doctoral or phd degree, if exists.""", default="-")
    high_edu_gpa_3: float = Field(description="""GPA of candidate's doctoral or phd degree, if exists.""", default=0)
    domicile: str = Field(description="Current domicile of the candidate", default="-")

    yoe: float = Field(description="The candidate's total years of experience (as an float)", default=0)
    hardskills: Optional[List[str]] = Field(description="List of the candidate's hard skills", default=[])
    softskills: Optional[List[str]] = Field(description="List of the candidate's soft skills", default=[])
    certifications: Optional[List[str]] = Field(description="List of the candidate's certifications", default=[])
    business_domain_experiences: Optional[List[str]] = Field(description="List of the candidate's business domain experience based on working experience or project", default=[])

class OutMatching(BaseModel):
    score: int = Field(description="Score of profile matching, in range 0-100. If profile and criteria is closed then will give higher score.", default=0)
    reason: str = Field(description="Reason behind why you give that such score to current profile.", default="-")