Repository navigation
Expand file tree
/
Copy pathmain.py
More file actions
84 lines (60 loc) · 2.25 KB
/
Copy pathmain.py
File metadata and controls
84 lines (60 loc) · 2.25 KB
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
from __future__ import annotations
import logging
import os
from typing import Any, Dict, List, Tuple
from dotenv import load_dotenv
from agents import agents_bundle
from tasks import run_pipeline_fallback
from tools import extract_profile_from_resume, read_resume_text, send_email
def setup_logging() -> None:
level = os.getenv("LOG_LEVEL", "INFO").upper().strip()
logging.basicConfig(level=getattr(logging, level, logging.INFO))
def load_inputs() -> Tuple[str, str, str, List[str], str, str]:
return (
os.getenv("RESUME_PATH", "resume.txt"),
os.getenv("TARGET_ROLE", "Machine Learning Engineer"),
os.getenv("TARGET_LOCATION", "Remote"),
os.getenv("TARGET_KEYWORDS", "Python,LLM,Agents").split(","),
os.getenv("SEARCH_PROVIDER", "mock"),
os.getenv("OUTREACH_MODE", "simulate"),
)
def print_results(results: List[Dict[str, Any]]) -> None:
for r in results:
print("\n==============================")
print(f"{r['job_title']} @ {r['company']}")
print(f"Match: {r['match_score']} | Risk: {r['risk_score']}")
print(r["generated_email"])
def maybe_send_emails(results: List[Dict[str, Any]], outreach_mode: str):
to_email = os.getenv("TEST_RECIPIENT_EMAIL", "").strip()
for r in results:
send_email(
to_email=to_email,
subject=f"Interest in {r['job_title']}",
body=r["generated_email"],
mode=outreach_mode,
gmail_sender=os.getenv("GMAIL_SENDER"),
client_secrets_path=os.getenv("GMAIL_OAUTH_CLIENT_SECRETS"),
token_path=os.getenv("GMAIL_OAUTH_TOKEN"),
)
def main():
load_dotenv()
setup_logging()
agents_bundle()
resume_path, role, location, keywords, provider, outreach = load_inputs()
resume_text = read_resume_text(resume_path)
profile = extract_profile_from_resume(
resume_text,
target_role=role,
target_location=location,
target_keywords=keywords,
)
query = f"{role} jobs in {location}"
results = run_pipeline_fallback(
profile=profile,
search_provider=provider,
query=query,
)
print_results(results)
maybe_send_emails(results, outreach)
if __name__ == "__main__":
main()