Skip to content

Commit 6b9a34c

Browse files
committed
feat: add new upskilling endpoints for both profile and job and the text geocoding endpoint
draft
1 parent 49ef7a2 commit 6b9a34c

File tree

7 files changed

+161
-0
lines changed

7 files changed

+161
-0
lines changed

hrflow/core/validation.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ def validate_limit(value):
9090

9191
return value
9292

93+
def validate_score(value):
94+
if value < 0 or value > 1:
95+
raise ValueError("score must be between 0 and 1")
96+
97+
return value
9398

9499
def validate_provider_keys(value):
95100
if not value or not all(isinstance(elt, str) for elt in value):

hrflow/job/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from .scoring import JobScoring
77
from .searching import JobSearching
88
from .storing import JobStoring
9+
from .upskilling import JobUpskilling
910

1011

1112
class Job:
@@ -19,3 +20,4 @@ def __init__(self, client):
1920
self.reasoning = JobReasoning(self.client)
2021
self.storing = JobStoring(self.client)
2122
self.matching = JobMatching(self.client)
23+
self.upskilling = JobUpskilling(self.client)

hrflow/job/upskilling.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import typing as t
2+
3+
from ..core.rate_limit import rate_limiter
4+
from ..core.validation import (
5+
6+
KEY_REGEX,
7+
validate_key,
8+
validate_response,
9+
validate_score,
10+
)
11+
class JobUpskilling:
12+
def __init__(self, api):
13+
self.client = api
14+
15+
@rate_limiter
16+
def get(
17+
self,
18+
board_key: str,
19+
job_key: str,
20+
source_key: str,
21+
profile_key: str,
22+
score: float,
23+
output_lang: str = "en",
24+
) -> t.Dict[str, t.Any]:
25+
"""
26+
🧠Get the SWOT explaining a Job recommendation for a Profile.
27+
(https://api.hrflow.ai/v1/job/upskilling)
28+
Args:
29+
source_key: <str>
30+
The key of the Source associated to the profile.
31+
profile_key: <str>
32+
The Profile unique identifier.
33+
board_key: <str>
34+
The key of the Board associated to the job.
35+
job_key: <str>
36+
The Job unique identifier.
37+
score: <float>
38+
Matching score of the Job according to the Profile. The Score value is between 0 and 1.
39+
output_lang: <str>
40+
The language of the output. Default is 'en'.
41+
42+
Returns:
43+
`/job/upskilling` response
44+
"""
45+
46+
params = dict(
47+
source_key=validate_key("Source", source_key, regex=KEY_REGEX),
48+
profile_key=validate_key("Profile", profile_key, regex=KEY_REGEX),
49+
board_key=validate_key("Board", board_key, regex=KEY_REGEX),
50+
job_key=validate_key("Job", job_key, regex=KEY_REGEX),
51+
score=validate_score(score),
52+
output_lang=output_lang,
53+
)
54+
55+
response = self.client.get("job/upskilling", query_params=params)
56+
57+
return validate_response(response)

hrflow/profile/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from .searching import ProfileSearching
1313
from .storing import ProfileStoring
1414
from .unfolding import ProfileUnfolding
15+
from .upskilling import ProfileUpskilling
1516

1617

1718
class Profile(object):
@@ -39,3 +40,4 @@ def __init__(self, client):
3940
self.unfolding = ProfileUnfolding(self.client)
4041
self.matching = ProfileMatching(self.client)
4142
self.grading = ProfileGrading(self.client)
43+
self.upskilling = ProfileUpskilling(self.client)

hrflow/profile/upskilling.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import typing as t
2+
3+
from ..core.rate_limit import rate_limiter
4+
from ..core.validation import (
5+
6+
KEY_REGEX,
7+
validate_key,
8+
validate_response,
9+
validate_score,
10+
)
11+
12+
13+
class ProfileUpskilling:
14+
def __init__(self, api):
15+
self.client = api
16+
17+
@rate_limiter
18+
def get(
19+
self,
20+
board_key: str,
21+
job_key: str,
22+
source_key: str,
23+
profile_key: str,
24+
score: float,
25+
output_lang: str = "en",
26+
) -> t.Dict[str, t.Any]:
27+
"""
28+
🧠Get the SWOT explaining a Profile recommendation for a Job.
29+
(https://api.hrflow.ai/v1/profile/upskilling)
30+
Args:
31+
board_key: <str>
32+
The key of the Board associated to the job.
33+
job_key: <str>
34+
The Job unique identifier.
35+
source_key: <str>
36+
The key of the Source associated to the profile.
37+
profile_key: <str>
38+
The Profile unique identifier.
39+
score: <float>
40+
Matching score of the Profile according to the Job. The Score value is between 0 and 1.
41+
output_lang: <str>
42+
The language of the output. Default is 'en'.
43+
44+
Returns:
45+
`/profile/upskilling` response
46+
"""
47+
48+
params = dict(
49+
board_key=validate_key("Board", board_key, regex=KEY_REGEX),
50+
job_key=validate_key("Job", job_key, regex=KEY_REGEX),
51+
source_key=validate_key("Source", source_key, regex=KEY_REGEX),
52+
profile_key=validate_key("Profile", profile_key, regex=KEY_REGEX),
53+
score=validate_score(score),
54+
output_lang=output_lang,
55+
)
56+
57+
response = self.client.get("profile/upskilling", query_params=params)
58+
59+
return validate_response(response)

hrflow/text/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Profile related calls."""
22

33
from .embedding import TextEmbedding
4+
from .geocoding import TextGeocoding
45
from .imaging import TextImaging
56
from .linking import TextLinking
67
from .ocr import TextOCR
@@ -29,3 +30,4 @@ def __init__(self, client):
2930
self.tagging = TextTagging(self.client)
3031
self.ocr = TextOCR(self.client)
3132
self.imaging = TextImaging(self.client)
33+
self.geocoding = TextGeocoding(self.client)

hrflow/text/geocoding.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import typing as t
2+
3+
from ..core.rate_limit import rate_limiter
4+
from ..core.validation import validate_response
5+
6+
7+
class TextGeocoding:
8+
"""Manage geocoding related calls."""
9+
10+
def __init__(self, api):
11+
"""Init."""
12+
self.client = api
13+
14+
@rate_limiter
15+
def post(
16+
self,
17+
texts: t.List[str],
18+
) -> t.Dict[str, t.Any]:
19+
"""
20+
Geocode a list of texts.
21+
22+
Args:
23+
texts: <list[str]>
24+
Geocode a list of texts. Example: ["112 avenue charles de gaulle 92200 neuilly-sur-seine", "New York", "7 rue 4 septembre Paris"].
25+
26+
Returns:
27+
`/text/geocoding` response
28+
"""
29+
payload = dict(
30+
texts=texts,
31+
)
32+
33+
response = self.client.post("text/geocoding", json=payload)
34+
return validate_response(response)

0 commit comments

Comments
 (0)