Skip to content

Commit

Permalink
Merge branch 'sarob-patch05' of https://github.com/sarob/Auto_Jobs_Ap…
Browse files Browse the repository at this point in the history
…plier_AIHawk into sarob-patch05
  • Loading branch information
sarob committed Oct 27, 2024
2 parents 3442557 + c3c9879 commit 534152d
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 24 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -555,12 +555,22 @@ Using this folder as a guide can be particularly helpful for:
0. **Account language**
To ensure the bot works, your account language must be set to English.

2. **Data Folder:**
1. **Data Folder:**
Ensure that your data_folder contains the following files:
- `secrets.yaml`
- `config.yaml`
- `plain_text_resume.yaml`

2. **Output Folder:**
Contains the output of the bot.
- `data.json` results of the --collect mode
- `failed.json` failed applications
- `open_ai_calls.json` all the calls made to the LLM model
- `skipped.json` applications that were skipped
- `success.json` successful applications

**Note:** `answers.json` is not part of the output folder and can be found in the root of the project. It is used to store the answers of the questions asked to the user. Can be used to update the bot with corrected answers. Search for `Select an option`, `0`, `Authorized`, and `how many years of` to verify correct answers.

3. **Run the Bot:**

Auto_Jobs_Applier_AIHawk offers flexibility in how it handles your pdf resume:
Expand Down
3 changes: 3 additions & 0 deletions data_folder/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ title_blacklist:
- word1
- word2

location_blacklist:
- Brazil

job_applicants_threshold:
min_applicants: 0
max_applicants: 30
Expand Down
3 changes: 3 additions & 0 deletions data_folder_example/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ title_blacklist:
- word1
- word2

location_blacklist:
- Brazil

job_applicants_threshold:
min_applicants: 0
max_applicants: 30
Expand Down
11 changes: 6 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,22 @@ def validate_config(config_yaml_path: Path) -> dict:
'date': dict,
'positions': list,
'locations': list,
'location_blacklist': list,
'distance': int,
'companyBlacklist': list,
'titleBlacklist': list,
'company_blacklist': list,
'title_blacklist': list,
'llm_model_type': str,
'llm_model': str
}

for key, expected_type in required_keys.items():
if key not in parameters:
if key in ['companyBlacklist', 'titleBlacklist']:
if key in ['company_blacklist', 'title_blacklist', 'location_blacklist']:
parameters[key] = []
else:
raise ConfigError(f"Missing or invalid key '{key}' in config file {config_yaml_path}")
elif not isinstance(parameters[key], expected_type):
if key in ['companyBlacklist', 'titleBlacklist'] and parameters[key] is None:
if key in ['company_blacklist', 'title_blacklist', 'location_blacklist'] and parameters[key] is None:
parameters[key] = []
else:
raise ConfigError(f"Invalid type for key '{key}' in config file {config_yaml_path}. Expected {expected_type}.")
Expand Down Expand Up @@ -97,7 +98,7 @@ def validate_config(config_yaml_path: Path) -> dict:
raise ConfigError(f"Invalid distance value in config file {config_yaml_path}. Must be one of: {approved_distances}")

# Ensure blacklists are lists
for blacklist in ['companyBlacklist', 'titleBlacklist']:
for blacklist in ['company_blacklist', 'title_blacklist','location_blacklist']:
if not isinstance(parameters.get(blacklist), list):
raise ConfigError(f"'{blacklist}' must be a list in config file {config_yaml_path}")
if parameters[blacklist] is None:
Expand Down
10 changes: 0 additions & 10 deletions src/aihawk_easy_applier.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,15 +839,6 @@ def _save_questions_to_json(self, question_data: dict) -> None:
output_file = 'answers.json'
question_data['question'] = self._sanitize_text(question_data['question'])

# Check if the question already exists in the JSON file and bail out if it does
for item in self.all_data:
if self._sanitize_text(item['question']) == question_data['question'] and item['type'] == question_data['type']:
logger.debug(f"Question already exists in answers.json. Aborting save of: {item['question']}")
return
if self.current_job.company in item['answer']:
logger.debug(f"Answer contains the Company name. Aborting save of: {item['question']}")
return

logger.debug(f"Saving question data to JSON: {question_data}")
try:
try:
Expand All @@ -865,7 +856,6 @@ def _save_questions_to_json(self, question_data: dict) -> None:
data.append(question_data)
with open(output_file, 'w') as f:
json.dump(data, f, indent=4)
self.all_data = data
logger.debug("Question data saved successfully to JSON")
except Exception:
tb_str = traceback.format_exc()
Expand Down
18 changes: 10 additions & 8 deletions src/aihawk_job_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def set_parameters(self, parameters):
logger.debug("Setting parameters for AIHawkJobManager")
self.company_blacklist = parameters.get('company_blacklist', []) or []
self.title_blacklist = parameters.get('title_blacklist', []) or []
self.location_blacklist = parameters.get('location_blacklist', []) or []
self.positions = parameters.get('positions', [])
self.locations = parameters.get('locations', [])
self.apply_once_at_company = parameters.get('apply_once_at_company', False)
Expand Down Expand Up @@ -276,8 +277,8 @@ def read_jobs(self):
raise Exception("No job class elements found on page")
job_list = [Job(*self.extract_job_information_from_tile(job_element)) for job_element in job_list_elements]
for job in job_list:
if self.is_blacklisted(job.title, job.company, job.link):
utils.printyellow(f"Blacklisted {job.title} at {job.company}, skipping...")
if self.is_blacklisted(job.title, job.company, job.link, job.location):
utils.printyellow(f"Blacklisted {job.title} at {job.company} in {job.location}, skipping...")
self.write_to_file(job, "skipped")
continue
try:
Expand Down Expand Up @@ -361,8 +362,8 @@ def apply_jobs(self):
"""


if self.is_blacklisted(job.title, job.company, job.link):
logger.debug(f"Job blacklisted: {job.title} at {job.company}")
if self.is_blacklisted(job.title, job.company, job.link, job.location):
logger.debug(f"Job blacklisted: {job.title} at {job.company} in {job.location}")
self.write_to_file(job, "skipped")
continue
if self.is_already_applied_to_job(job.title, job.company, job.link):
Expand Down Expand Up @@ -467,16 +468,17 @@ def extract_job_information_from_tile(self, job_tile):

return job_title, company, job_location, link, apply_method

def is_blacklisted(self, job_title, company, link):
logger.debug(f"Checking if job is blacklisted: {job_title} at {company}")
def is_blacklisted(self, job_title, company, link, job_location):
logger.debug(f"Checking if job is blacklisted: {job_title} at {company} in {job_location}")
job_title_words = job_title.lower().split(' ')
title_blacklisted = any(word in job_title_words for word in map(str.lower, self.title_blacklist))
company_blacklisted = company.strip().lower() in (word.strip().lower() for word in self.company_blacklist)
location_blacklisted= job_location.strip().lower() in (word.strip().lower() for word in self.location_blacklist)
link_seen = link in self.seen_jobs
is_blacklisted = title_blacklisted or company_blacklisted or link_seen
is_blacklisted = title_blacklisted or company_blacklisted or location_blacklisted or link_seen
logger.debug(f"Job blacklisted status: {is_blacklisted}")

return title_blacklisted or company_blacklisted or link_seen
return title_blacklisted or company_blacklisted or location_blacklisted or link_seen

def is_already_applied_to_job(self, job_title, company, link):
link_seen = link in self.seen_jobs
Expand Down

0 comments on commit 534152d

Please sign in to comment.