-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_application.py
More file actions
executable file
·185 lines (152 loc) · 5.89 KB
/
generate_application.py
File metadata and controls
executable file
·185 lines (152 loc) · 5.89 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/usr/bin/env python3
"""
Job Application Assistant - AI-Powered CV & Cover Letter Generator
Main application script using agent-based architecture
"""
import argparse
import sys
from pathlib import Path
# Import the agent
from agent import run_job_assistant
def print_banner():
"""Print application banner."""
banner = """
╔════════════════════════════════════════════════════════════════╗
║ ║
║ JOB APPLICATION ASSISTANT - AI-Powered Generator ║
║ ║
║ Generate Professional CVs & Cover Letters ║
║ Tailored to Your Target Job ║
║ ║
║ Version 2.0 - Agent-Based Architecture ║
║ ║
╚════════════════════════════════════════════════════════════════╝
"""
print(banner)
def main():
"""Main application entry point."""
parser = argparse.ArgumentParser(
description="Generate AI-powered CV and cover letter for job applications",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
# Generate CV and cover letter from input files
python generate_application.py --profile my_profile.txt --job job_posting.txt
# Generate LaTeX/PDF versions
python generate_application.py --profile my_profile.txt --job job_posting.txt --latex
# Generate PDF CV with photo
python generate_application.py --profile my_profile.txt --job job_posting.txt --latex --photo Photos/my_photo.jpg
# Specify custom output directory
python generate_application.py --profile my_profile.txt --job job_posting.txt --output my_output
# Generate only CV (no cover letter)
python generate_application.py --profile my_profile.txt --job job_posting.txt --cv-only
# Generate in markdown format
python generate_application.py --profile my_profile.txt --job job_posting.txt --format markdown
"""
)
parser.add_argument(
'--profile', '-p',
required=True,
help='Path to your profile text file (use data/user_profile_template.txt as template)'
)
parser.add_argument(
'--job', '-j',
required=True,
help='Path to job posting text file (use data/job_posting_template.txt as template)'
)
parser.add_argument(
'--output', '-o',
default='outputs',
help='Output directory for generated files (default: outputs/)'
)
parser.add_argument(
'--format', '-f',
choices=['text', 'markdown'],
default='text',
help='CV output format (default: text)'
)
parser.add_argument(
'--cv-only',
action='store_true',
help='Generate only CV (skip cover letter)'
)
parser.add_argument(
'--cover-letter-only',
action='store_true',
help='Generate only cover letter (skip CV)'
)
parser.add_argument(
'--no-banner',
action='store_true',
help='Suppress banner display'
)
parser.add_argument(
'--latex',
action='store_true',
help='Generate LaTeX/PDF output (requires pdflatex)'
)
parser.add_argument(
'--photo',
help='Path to photo file for CV with photo (use with --latex)'
)
args = parser.parse_args()
# Print banner
if not args.no_banner:
print_banner()
# Validate input files
profile_path = Path(args.profile)
job_path = Path(args.job)
if not profile_path.exists():
print(f"\nError: Profile file not found: {args.profile}")
print(f"\nPlease create your profile using the template at:")
print(f" data/user_profile_template.txt\n")
sys.exit(1)
if not job_path.exists():
print(f"\nError: Job posting file not found: {args.job}")
print(f"\nPlease create your job posting file using the template at:")
print(f" data/job_posting_template.txt\n")
sys.exit(1)
# Determine what to generate
generate_cv = not args.cover_letter_only
generate_cover_letter = not args.cv_only
# Validate photo path if provided
photo_path = None
with_photo = False
if args.photo:
photo_file = Path(args.photo)
if not photo_file.exists():
print(f"\nError: Photo file not found: {args.photo}\n")
sys.exit(1)
photo_path = str(photo_file)
with_photo = True
if not args.latex:
print("\nWARNING: --photo option only works with --latex. Adding --latex automatically.\n")
args.latex = True
# Run the agent
try:
results = run_job_assistant(
profile_path=str(profile_path),
job_path=str(job_path),
output_dir=args.output,
cv_format=args.format,
generate_cv=generate_cv,
generate_cover_letter=generate_cover_letter,
latex_output=args.latex,
with_photo=with_photo,
photo_path=photo_path
)
# Exit with appropriate code
if results['status'] == 'success':
sys.exit(0)
else:
sys.exit(1)
except KeyboardInterrupt:
print("\n\nWARNING: Operation cancelled by user.")
sys.exit(0)
except Exception as e:
print(f"\nError: Unexpected error: {e}")
import traceback
traceback.print_exc()
sys.exit(1)
if __name__ == "__main__":
main()