1
1
import asyncio
2
2
import traceback
3
- from typing import Any , Dict , Optional
3
+ from typing import Any , Optional , dict
4
4
5
5
from pydantic import BaseModel
6
6
10
10
11
11
class Qualifications (BaseModel ):
12
12
degree : Optional [str ] = None
13
- yearsOfExperience : Optional [float ] = None # Representing the number
13
+ years_of_experience : Optional [float ] = None # Representing the number
14
14
15
15
16
16
class JobDetails (BaseModel ):
17
- applicationDeadline : Optional [str ] = None
18
- minimumQualifications : Qualifications
19
- preferredQualifications : Qualifications
17
+ application_deadline : Optional [str ] = None
18
+ minimum_qualifications : Qualifications
19
+ preferred_qualifications : Qualifications
20
20
21
21
22
- def is_job_details_valid (details : Dict [str , Any ]) -> bool :
22
+ def is_job_details_valid (details : dict [str , Any ]) -> bool :
23
23
"""
24
24
Validates that each top-level field in the extracted job details is not None.
25
- For nested dictionary values, each sub-value must be non-null and a string or a number.
25
+ For nested dictionary values, each sub-value must be non-null and a string
26
+ or a number.
26
27
"""
27
28
if not details :
28
29
return False
29
- for key , value in details .items ():
30
+ for _key , value in details .items ():
30
31
if value is None :
31
32
return False
32
33
if isinstance (value , dict ):
@@ -53,9 +54,9 @@ async def google_jobs(model_name: str, logger, use_text_extract: bool) -> dict:
53
54
4. Extracting job posting details using an AI-driven extraction schema.
54
55
55
56
The extraction schema requires:
56
- - applicationDeadline : The opening date until which applications are accepted.
57
- - minimumQualifications : An object with degree and yearsOfExperience .
58
- - preferredQualifications : An object with degree and yearsOfExperience .
57
+ - application_deadline : The opening date until which applications are accepted.
58
+ - minimum_qualifications : An object with degree and years_of_experience .
59
+ - preferred_qualifications : An object with degree and years_of_experience .
59
60
60
61
Returns a dictionary containing:
61
62
- _success (bool): Whether valid job details were extracted.
@@ -90,8 +91,9 @@ async def google_jobs(model_name: str, logger, use_text_extract: bool) -> dict:
90
91
job_details = await stagehand .page .extract (
91
92
ExtractOptions (
92
93
instruction = (
93
- "Extract the following details from the job posting: application deadline, "
94
- "minimum qualifications (degree and years of experience), and preferred qualifications "
94
+ "Extract the following details from the job posting: "
95
+ "application deadline, minimum qualifications "
96
+ "(degree and years of experience), and preferred qualifications "
95
97
"(degree and years of experience)"
96
98
),
97
99
schemaDefinition = JobDetails .model_json_schema (),
0 commit comments