ishaq101's picture
update Criteria field type
b0853c5
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="-")