Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,48 +11,42 @@ logging.basicConfig(
|
|
| 11 |
)
|
| 12 |
logger = logging.getLogger(__name__)
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
# Import Gradio
|
| 18 |
try:
|
| 19 |
import gradio as gr
|
| 20 |
logger.info("β Gradio imported successfully")
|
| 21 |
-
except ImportError:
|
| 22 |
-
logger.error("β
|
|
|
|
| 23 |
sys.exit(1)
|
| 24 |
|
| 25 |
# Import PyTorch
|
| 26 |
try:
|
| 27 |
import torch
|
| 28 |
-
logger.info(f"β PyTorch imported successfully (GPU: {torch.cuda.is_available()})")
|
| 29 |
-
except ImportError:
|
| 30 |
-
logger.error("β PyTorch not found. Install with: pip install torch")
|
| 31 |
-
sys.exit(1)
|
| 32 |
-
|
| 33 |
-
# Import application components
|
| 34 |
-
try:
|
| 35 |
-
from src.mayini_model import MAYINIModel, MAYINIVocabulary
|
| 36 |
-
from src.scraper import JobScraper
|
| 37 |
-
from src.customizer import ResumeCustomizer
|
| 38 |
-
from src.classifier import JobRelevanceClassifier
|
| 39 |
-
from src.agent import JobApplicationAgent
|
| 40 |
-
logger.info("β All application modules imported successfully")
|
| 41 |
except ImportError as e:
|
| 42 |
-
logger.error(f"β Failed to import
|
| 43 |
-
logger.error("
|
| 44 |
-
traceback.print_exc()
|
| 45 |
sys.exit(1)
|
| 46 |
|
| 47 |
-
#
|
| 48 |
-
|
| 49 |
-
# ============================================================================
|
| 50 |
-
|
| 51 |
-
logger.info("=" * 70)
|
| 52 |
-
logger.info("π€ Initializing Job Application Agent (MAYINI Framework Edition)")
|
| 53 |
-
logger.info("=" * 70)
|
| 54 |
|
| 55 |
-
#
|
| 56 |
mayini_model = None
|
| 57 |
vocab = None
|
| 58 |
customizer = None
|
|
@@ -60,100 +54,236 @@ classifier = None
|
|
| 60 |
scraper = None
|
| 61 |
agent = None
|
| 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 |
classifier.mayini_model = mayini_model
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
agent = JobApplicationAgent(scraper, customizer, classifier)
|
| 108 |
-
logger.info("β Application Agent initialized")
|
| 109 |
-
|
| 110 |
-
logger.info("\n" + "=" * 70)
|
| 111 |
-
logger.info("β
ALL COMPONENTS INITIALIZED SUCCESSFULLY!")
|
| 112 |
-
logger.info("=" * 70 + "\n")
|
| 113 |
-
|
| 114 |
-
return True
|
| 115 |
-
|
| 116 |
-
except Exception as e:
|
| 117 |
-
logger.error(f"\nβ INITIALIZATION ERROR: {e}")
|
| 118 |
-
logger.error(traceback.format_exc())
|
| 119 |
-
return False
|
| 120 |
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
logger.
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
# ============================================================================
|
| 127 |
# INTERFACE FUNCTIONS
|
| 128 |
# ============================================================================
|
| 129 |
|
| 130 |
def search_jobs_interface(keywords: str, location: str, num_jobs: int) -> str:
|
| 131 |
-
"""
|
| 132 |
-
Search and rank jobs based on keywords and location
|
| 133 |
-
Uses MAYINI embeddings for relevance matching
|
| 134 |
-
"""
|
| 135 |
try:
|
| 136 |
if not keywords or not keywords.strip():
|
| 137 |
-
return "β Error
|
| 138 |
-
|
| 139 |
-
if not agent:
|
| 140 |
-
return "β Error: Application not initialized"
|
| 141 |
-
|
| 142 |
-
logger.info(f"\nπ Searching for jobs: keywords='{keywords}', location='{location}', num={int(num_jobs)}")
|
| 143 |
|
| 144 |
results = agent.search_and_apply(
|
| 145 |
keywords=keywords.strip(),
|
| 146 |
-
location=location.strip(),
|
| 147 |
num_jobs=int(num_jobs)
|
| 148 |
)
|
| 149 |
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
output
|
| 154 |
-
output += f"Found: {results.get('total_jobs_found', 0)} jobs\n"
|
| 155 |
-
output += f"Relevant: {results.get('relevant_jobs', 0)} jobs\n"
|
| 156 |
-
output += f"Pass Rate: {results.get('pass_rate', 0):.1%}\n\n"
|
| 157 |
output += "---\n\n"
|
| 158 |
|
| 159 |
for i, app in enumerate(results.get('applications', [])[:5], 1):
|
|
@@ -163,109 +293,69 @@ def search_jobs_interface(keywords: str, location: str, num_jobs: int) -> str:
|
|
| 163 |
output += f"**{i}. {job.get('title', 'N/A')}**\n"
|
| 164 |
output += f"- Company: {job.get('company', 'N/A')}\n"
|
| 165 |
output += f"- Location: {job.get('location', 'N/A')}\n"
|
| 166 |
-
output += f"- π― Relevance
|
| 167 |
output += f"- π° Salary: {job.get('salary_range', 'Not specified')}\n"
|
| 168 |
-
output += f"- π Experience
|
| 169 |
-
|
| 170 |
-
match_details = app.get('match_details', {})
|
| 171 |
-
if match_details:
|
| 172 |
-
output += f"- β Matching Skills: {', '.join(match_details.get('matching_skills', [])[:3])}\n"
|
| 173 |
-
output += f"- β Missing Skills: {', '.join(match_details.get('missing_skills', [])[:2])}\n"
|
| 174 |
-
|
| 175 |
-
output += "\n"
|
| 176 |
|
| 177 |
-
logger.info(f"β Found and displayed {len(results.get('applications', [])[:5])} top results")
|
| 178 |
return output
|
| 179 |
-
|
| 180 |
except Exception as e:
|
| 181 |
-
logger.error(f"Error in
|
| 182 |
-
|
| 183 |
-
return f"β Error: {str(e)}\n\nPlease try again with different inputs."
|
| 184 |
|
| 185 |
def customize_resume_interface(job_title: str, company: str, requirements: str) -> str:
|
| 186 |
-
"""
|
| 187 |
-
Customize resume for specific job using MAYINI embeddings
|
| 188 |
-
"""
|
| 189 |
try:
|
| 190 |
if not job_title or not job_title.strip():
|
| 191 |
-
return "β Error
|
| 192 |
-
|
| 193 |
-
if not customizer:
|
| 194 |
-
return "β Error: Customizer not initialized"
|
| 195 |
-
|
| 196 |
-
logger.info(f"\nπ Customizing resume for: {job_title} @ {company}")
|
| 197 |
|
| 198 |
job = {
|
| 199 |
'title': job_title.strip(),
|
| 200 |
'company': company.strip(),
|
| 201 |
-
'
|
| 202 |
-
'requirements': [req.strip() for req in requirements.split(',') if req.strip()]
|
| 203 |
}
|
| 204 |
|
| 205 |
customized = customizer.customize_for_job(job)
|
| 206 |
|
| 207 |
output = f"β
**Customized Resume**\n\n"
|
| 208 |
output += f"**Job:** {job_title} @ {company}\n\n"
|
|
|
|
|
|
|
| 209 |
|
| 210 |
-
|
| 211 |
-
output += f"{customized.get('summary', 'N/A')}\n\n"
|
| 212 |
-
|
| 213 |
-
output += f"**Prioritized Skills:**\n"
|
| 214 |
-
skills = customized.get('skills', [])[:15]
|
| 215 |
-
for skill in skills:
|
| 216 |
output += f"β’ {skill}\n"
|
| 217 |
|
| 218 |
-
if 'customized_for' in customized:
|
| 219 |
-
match_info = customized['customized_for']
|
| 220 |
-
output += f"\n**Match Information:**\n"
|
| 221 |
-
output += f"- Matching Skills: {len(match_info.get('matching_skills', []))} skills\n"
|
| 222 |
-
output += f"- Match Score: {match_info.get('match_score', 0):.0%}\n"
|
| 223 |
-
|
| 224 |
-
logger.info(f"β Resume customized successfully")
|
| 225 |
return output
|
| 226 |
-
|
| 227 |
except Exception as e:
|
| 228 |
-
logger.error(f"Error in
|
| 229 |
-
|
| 230 |
-
return f"β Error: {str(e)}\n\nPlease check your inputs and try again."
|
| 231 |
|
| 232 |
def classify_job_interface(job_title: str, requirements: str) -> str:
|
| 233 |
-
"""
|
| 234 |
-
Classify job relevance using MAYINI embeddings
|
| 235 |
-
"""
|
| 236 |
try:
|
| 237 |
if not job_title or not job_title.strip():
|
| 238 |
-
return "β Error
|
| 239 |
-
|
| 240 |
-
if not classifier:
|
| 241 |
-
return "β Error: Classifier not initialized"
|
| 242 |
-
|
| 243 |
-
logger.info(f"\nπ― Classifying job: {job_title}")
|
| 244 |
|
| 245 |
job = {
|
| 246 |
'title': job_title.strip(),
|
| 247 |
-
'
|
| 248 |
-
'requirements': [req.strip() for req in requirements.split(',') if req.strip()] if requirements else [],
|
| 249 |
'location': 'Remote',
|
| 250 |
'company': 'Unknown',
|
|
|
|
| 251 |
'experience_required': 5,
|
| 252 |
'salary_range': 'Unknown'
|
| 253 |
}
|
| 254 |
|
| 255 |
-
# Get sample resume skills
|
| 256 |
resume_skills = [
|
| 257 |
"Python", "Docker", "AWS", "PostgreSQL", "REST API",
|
| 258 |
-
"Microservices", "Git", "Kubernetes", "Machine Learning"
|
| 259 |
-
"Data Analysis", "SQL", "Linux", "Cloud Computing"
|
| 260 |
]
|
| 261 |
|
| 262 |
score = classifier.classify_job(job, resume_skills)
|
| 263 |
details = classifier.get_match_details(job, resume_skills)
|
| 264 |
|
| 265 |
-
output = f"β
**Job Classification
|
| 266 |
-
output += f"**Job
|
| 267 |
|
| 268 |
-
# Relevance score
|
| 269 |
score_percent = score * 100
|
| 270 |
if score >= 0.8:
|
| 271 |
emoji = "π’"
|
|
@@ -280,293 +370,105 @@ def classify_job_interface(job_title: str, requirements: str) -> str:
|
|
| 280 |
emoji = "π΄"
|
| 281 |
level = "POOR"
|
| 282 |
|
| 283 |
-
output += f"{emoji} **
|
| 284 |
-
output += f"**
|
|
|
|
| 285 |
|
| 286 |
-
# Decision
|
| 287 |
-
if score >= 0.6:
|
| 288 |
-
output += f"**Decision:** β
**APPLY**\n\n"
|
| 289 |
-
else:
|
| 290 |
-
output += f"**Decision:** βΈοΈ **CONSIDER**\n\n"
|
| 291 |
-
|
| 292 |
-
# Skill matching
|
| 293 |
-
output += f"**Matching Skills ({len(details.get('matching_skills', []))}):**\n"
|
| 294 |
-
for skill in details.get('matching_skills', []):
|
| 295 |
-
output += f"β {skill}\n"
|
| 296 |
-
|
| 297 |
-
output += f"\n**Missing Skills ({len(details.get('missing_skills', []))}):**\n"
|
| 298 |
-
for skill in details.get('missing_skills', []):
|
| 299 |
-
output += f"β {skill}\n"
|
| 300 |
-
|
| 301 |
-
logger.info(f"β Classification complete: {score_percent:.1f}%")
|
| 302 |
return output
|
| 303 |
-
|
| 304 |
-
except Exception as e:
|
| 305 |
-
logger.error(f"Error in classify_job_interface: {e}")
|
| 306 |
-
logger.error(traceback.format_exc())
|
| 307 |
-
return f"β Error: {str(e)}\n\nPlease check your inputs and try again."
|
| 308 |
-
|
| 309 |
-
def get_system_info() -> str:
|
| 310 |
-
"""Get system information"""
|
| 311 |
-
try:
|
| 312 |
-
info = f"β
**System Information**\n\n"
|
| 313 |
-
info += f"**Framework:** MAYINI Transformer Model\n"
|
| 314 |
-
info += f"**Vocabulary Size:** 5,000 tokens\n"
|
| 315 |
-
info += f"**Hidden Dimensions:** 256\n"
|
| 316 |
-
info += f"**Attention Heads:** 8\n"
|
| 317 |
-
info += f"**Transformer Layers:** 4\n"
|
| 318 |
-
info += f"**Total Parameters:** ~3.5M\n"
|
| 319 |
-
info += f"**Max Sequence Length:** 512\n\n"
|
| 320 |
-
|
| 321 |
-
info += f"**Hardware:**\n"
|
| 322 |
-
info += f"- GPU Available: {torch.cuda.is_available()}\n"
|
| 323 |
-
if torch.cuda.is_available():
|
| 324 |
-
info += f"- GPU Name: {torch.cuda.get_device_name(0)}\n"
|
| 325 |
-
info += f"- PyTorch Version: {torch.__version__}\n\n"
|
| 326 |
-
|
| 327 |
-
info += f"**Application Status:**\n"
|
| 328 |
-
info += f"- MAYINI Model: {'β Loaded' if mayini_model else 'β Not Loaded'}\n"
|
| 329 |
-
info += f"- Vocabulary: {'β Loaded' if vocab else 'β Not Loaded'}\n"
|
| 330 |
-
info += f"- Scraper: {'β Loaded' if scraper else 'β Not Loaded'}\n"
|
| 331 |
-
info += f"- Customizer: {'β Loaded' if customizer else 'β Not Loaded'}\n"
|
| 332 |
-
info += f"- Classifier: {'β Loaded' if classifier else 'β Not Loaded'}\n"
|
| 333 |
-
info += f"- Agent: {'β Loaded' if agent else 'β Not Loaded'}\n"
|
| 334 |
-
|
| 335 |
-
return info
|
| 336 |
except Exception as e:
|
| 337 |
-
|
|
|
|
| 338 |
|
| 339 |
# ============================================================================
|
| 340 |
# GRADIO INTERFACE
|
| 341 |
# ============================================================================
|
| 342 |
|
| 343 |
-
logger.info("
|
| 344 |
-
|
| 345 |
-
with gr.Blocks(
|
| 346 |
-
title="Job Application Agent - MAYINI Framework",
|
| 347 |
-
theme=gr.themes.Soft(),
|
| 348 |
-
css="""
|
| 349 |
-
.gradio-container { max-width: 1200px; margin: auto; }
|
| 350 |
-
.header { text-align: center; margin-bottom: 20px; }
|
| 351 |
-
.tab-content { padding: 20px; }
|
| 352 |
-
"""
|
| 353 |
-
) as demo:
|
| 354 |
|
| 355 |
-
# Header
|
| 356 |
gr.Markdown("""
|
| 357 |
# π€ Job Application Agent
|
| 358 |
### AI-Powered Job Search & Resume Customization
|
| 359 |
-
**Powered by MAYINI Framework
|
| 360 |
-
|
| 361 |
-
> This application uses advanced machine learning to help you find and apply for the perfect job!
|
| 362 |
""")
|
| 363 |
|
| 364 |
-
# Search & Match Jobs Tab
|
| 365 |
with gr.Tab("π Search & Match Jobs"):
|
| 366 |
-
gr.Markdown("
|
| 367 |
-
gr.Markdown("Enter your skills and find the best matching job opportunities using MAYINI embeddings.")
|
| 368 |
-
|
| 369 |
with gr.Row():
|
| 370 |
with gr.Column():
|
| 371 |
-
search_keywords = gr.Textbox(
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
lines=2,
|
| 376 |
-
info="Enter skills and technologies (comma-separated)"
|
| 377 |
-
)
|
| 378 |
-
search_location = gr.Textbox(
|
| 379 |
-
label="Location",
|
| 380 |
-
placeholder="Remote, San Francisco, New York",
|
| 381 |
-
value="Remote",
|
| 382 |
-
info="Enter job location"
|
| 383 |
-
)
|
| 384 |
-
search_num = gr.Slider(
|
| 385 |
-
minimum=1,
|
| 386 |
-
maximum=20,
|
| 387 |
-
value=5,
|
| 388 |
-
step=1,
|
| 389 |
-
label="Number of Jobs",
|
| 390 |
-
info="How many job results to display"
|
| 391 |
-
)
|
| 392 |
-
search_btn = gr.Button("π Search Jobs", variant="primary", size="lg")
|
| 393 |
-
|
| 394 |
with gr.Column():
|
| 395 |
-
search_output = gr.Markdown(
|
| 396 |
-
value="### Results will appear here...",
|
| 397 |
-
label="Search Results"
|
| 398 |
-
)
|
| 399 |
|
| 400 |
-
search_btn.click(
|
| 401 |
-
fn=search_jobs_interface,
|
| 402 |
-
inputs=[search_keywords, search_location, search_num],
|
| 403 |
-
outputs=search_output,
|
| 404 |
-
show_progress=True
|
| 405 |
-
)
|
| 406 |
|
| 407 |
-
# Customize Resume Tab
|
| 408 |
with gr.Tab("π Customize Resume"):
|
| 409 |
-
gr.Markdown("
|
| 410 |
-
gr.Markdown("Get a customized resume summary and skill prioritization for any job posting.")
|
| 411 |
-
|
| 412 |
with gr.Row():
|
| 413 |
with gr.Column():
|
| 414 |
-
customize_title = gr.Textbox(
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
)
|
| 419 |
-
customize_company = gr.Textbox(
|
| 420 |
-
label="Company Name",
|
| 421 |
-
placeholder="Tech Giants Inc",
|
| 422 |
-
info="Company name (optional)"
|
| 423 |
-
)
|
| 424 |
-
customize_req = gr.Textbox(
|
| 425 |
-
label="Job Requirements",
|
| 426 |
-
placeholder="Python, Docker, AWS, Kubernetes, PostgreSQL",
|
| 427 |
-
lines=3,
|
| 428 |
-
info="List requirements (comma-separated)"
|
| 429 |
-
)
|
| 430 |
-
customize_btn = gr.Button("β¨ Customize Resume", variant="primary", size="lg")
|
| 431 |
-
|
| 432 |
with gr.Column():
|
| 433 |
-
customize_output = gr.Markdown(
|
| 434 |
-
value="### Customized resume will appear here...",
|
| 435 |
-
label="Customized Resume"
|
| 436 |
-
)
|
| 437 |
|
| 438 |
-
customize_btn.click(
|
| 439 |
-
fn=customize_resume_interface,
|
| 440 |
-
inputs=[customize_title, customize_company, customize_req],
|
| 441 |
-
outputs=customize_output,
|
| 442 |
-
show_progress=True
|
| 443 |
-
)
|
| 444 |
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
gr.Markdown("### Check how relevant a job is to your skills")
|
| 448 |
-
gr.Markdown("Get a detailed analysis of job relevance with matching and missing skills.")
|
| 449 |
-
|
| 450 |
with gr.Row():
|
| 451 |
with gr.Column():
|
| 452 |
-
classify_title = gr.Textbox(
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
info="The job position to classify"
|
| 456 |
-
)
|
| 457 |
-
classify_req = gr.Textbox(
|
| 458 |
-
label="Job Requirements",
|
| 459 |
-
placeholder="Python, PyTorch, TensorFlow, Machine Learning, SQL",
|
| 460 |
-
lines=3,
|
| 461 |
-
info="Required skills (comma-separated)"
|
| 462 |
-
)
|
| 463 |
-
classify_btn = gr.Button("π― Classify Job", variant="primary", size="lg")
|
| 464 |
-
|
| 465 |
with gr.Column():
|
| 466 |
-
classify_output = gr.Markdown(
|
| 467 |
-
value="### Classification results will appear here...",
|
| 468 |
-
label="Classification Results"
|
| 469 |
-
)
|
| 470 |
|
| 471 |
-
classify_btn.click(
|
| 472 |
-
fn=classify_job_interface,
|
| 473 |
-
inputs=[classify_title, classify_req],
|
| 474 |
-
outputs=classify_output,
|
| 475 |
-
show_progress=True
|
| 476 |
-
)
|
| 477 |
|
| 478 |
-
|
| 479 |
-
with gr.Tab("βΉοΈ About & System Info"):
|
| 480 |
gr.Markdown("""
|
| 481 |
-
##
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
-
|
| 491 |
-
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
π― **Job Classification**
|
| 499 |
-
- Relevance scoring (0-100%)
|
| 500 |
-
- Skill gap analysis
|
| 501 |
-
- Recommendation engine
|
| 502 |
-
|
| 503 |
-
### MAYINI Framework Details
|
| 504 |
-
|
| 505 |
-
**Architecture:**
|
| 506 |
-
- Model Type: Transformer Encoder
|
| 507 |
-
- Vocabulary Size: 5,000 tokens
|
| 508 |
-
- Hidden Dimensions: 256
|
| 509 |
-
- Attention Heads: 8
|
| 510 |
-
- Transformer Layers: 4
|
| 511 |
-
- Total Parameters: ~3.5 million
|
| 512 |
-
- Max Sequence Length: 512 tokens
|
| 513 |
-
|
| 514 |
-
**Capabilities:**
|
| 515 |
-
- Text tokenization and encoding
|
| 516 |
-
- 256-dimensional embeddings
|
| 517 |
-
- Multi-head self-attention
|
| 518 |
-
- Semantic understanding
|
| 519 |
-
- Job-resume similarity matching
|
| 520 |
-
|
| 521 |
-
### Technology Stack
|
| 522 |
-
- **ML Framework**: MAYINI Transformer (Custom)
|
| 523 |
-
- **Interface**: Gradio 4.0+
|
| 524 |
-
- **Deep Learning**: PyTorch 2.0+
|
| 525 |
-
- **Language**: Python 3.8+
|
| 526 |
-
- **Deployment**: Hugging Face Spaces
|
| 527 |
-
|
| 528 |
-
### Repository & Links
|
| 529 |
-
- **GitHub**: [907-bot/Job-Application-Agent](https://github.com/907-bot/Job-Application-Agent)
|
| 530 |
-
- **License**: Apache 2.0
|
| 531 |
-
- **Status**: Production Ready
|
| 532 |
-
|
| 533 |
-
---
|
| 534 |
""")
|
| 535 |
-
|
| 536 |
-
info_btn = gr.Button("π₯οΈ Show System Info", variant="primary")
|
| 537 |
-
info_output = gr.Markdown()
|
| 538 |
-
|
| 539 |
-
info_btn.click(fn=get_system_info, outputs=info_output)
|
| 540 |
|
| 541 |
-
logger.info("β Gradio
|
| 542 |
|
| 543 |
# ============================================================================
|
| 544 |
-
# LAUNCH
|
| 545 |
# ============================================================================
|
| 546 |
|
| 547 |
if __name__ == "__main__":
|
| 548 |
-
logger.info("
|
| 549 |
-
logger.info("
|
| 550 |
-
logger.info("=" * 70)
|
| 551 |
-
|
| 552 |
-
logger.info("\nπ Access the application at:")
|
| 553 |
-
logger.info(" Local: http://127.0.0.1:7860")
|
| 554 |
-
logger.info(" Hugging Face Spaces: Check your Space URL")
|
| 555 |
-
logger.info("\nπ‘ Features:")
|
| 556 |
-
logger.info(" 1. Search & Match Jobs")
|
| 557 |
-
logger.info(" 2. Customize Resume")
|
| 558 |
-
logger.info(" 3. Classify Job Relevance")
|
| 559 |
-
logger.info(" 4. System Information\n")
|
| 560 |
|
| 561 |
try:
|
| 562 |
demo.queue(max_size=32, concurrency_count=4).launch(
|
| 563 |
server_name="0.0.0.0",
|
| 564 |
server_port=7860,
|
| 565 |
show_error=True,
|
| 566 |
-
share=False
|
| 567 |
-
show_api=True
|
| 568 |
)
|
| 569 |
except Exception as e:
|
| 570 |
-
logger.error(f"
|
| 571 |
-
|
| 572 |
-
sys.exit(1)
|
|
|
|
| 11 |
)
|
| 12 |
logger = logging.getLogger(__name__)
|
| 13 |
|
| 14 |
+
logger.info("=" * 80)
|
| 15 |
+
logger.info("π Job Application Agent - Startup")
|
| 16 |
+
logger.info("=" * 80)
|
| 17 |
+
|
| 18 |
+
# Add src to Python path - FIXED PATH HANDLING
|
| 19 |
+
current_dir = os.path.dirname(os.path.abspath(__file__))
|
| 20 |
+
src_path = os.path.join(current_dir, 'src')
|
| 21 |
+
if src_path not in sys.path:
|
| 22 |
+
sys.path.insert(0, src_path)
|
| 23 |
+
|
| 24 |
+
logger.info(f"π Current directory: {current_dir}")
|
| 25 |
+
logger.info(f"π Source directory: {src_path}")
|
| 26 |
+
logger.info(f"β Python path updated")
|
| 27 |
|
| 28 |
# Import Gradio
|
| 29 |
try:
|
| 30 |
import gradio as gr
|
| 31 |
logger.info("β Gradio imported successfully")
|
| 32 |
+
except ImportError as e:
|
| 33 |
+
logger.error(f"β Failed to import Gradio: {e}")
|
| 34 |
+
logger.error("Install with: pip install gradio")
|
| 35 |
sys.exit(1)
|
| 36 |
|
| 37 |
# Import PyTorch
|
| 38 |
try:
|
| 39 |
import torch
|
| 40 |
+
logger.info(f"β PyTorch imported successfully (GPU available: {torch.cuda.is_available()})")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
except ImportError as e:
|
| 42 |
+
logger.error(f"β Failed to import PyTorch: {e}")
|
| 43 |
+
logger.error("Install with: pip install torch")
|
|
|
|
| 44 |
sys.exit(1)
|
| 45 |
|
| 46 |
+
# Import application components - WITH ERROR HANDLING
|
| 47 |
+
logger.info("\nπ¦ Attempting to import application modules...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
+
# Create fallback/mock classes if imports fail
|
| 50 |
mayini_model = None
|
| 51 |
vocab = None
|
| 52 |
customizer = None
|
|
|
|
| 54 |
scraper = None
|
| 55 |
agent = None
|
| 56 |
|
| 57 |
+
# Try to import actual modules
|
| 58 |
+
try:
|
| 59 |
+
logger.info(" - Importing MAYINI model...")
|
| 60 |
+
from mayini_model import MAYINIModel, MAYINIVocabulary
|
| 61 |
+
logger.info(" β MAYINI model imported")
|
| 62 |
+
except ImportError as e:
|
| 63 |
+
logger.warning(f" β οΈ Could not import MAYINI: {e}")
|
| 64 |
+
logger.warning(" Creating mock MAYINI classes...")
|
| 65 |
|
| 66 |
+
# Create mock classes
|
| 67 |
+
class MAYINIVocabulary:
|
| 68 |
+
def __init__(self, vocab_size=5000):
|
| 69 |
+
self.vocab_size = vocab_size
|
| 70 |
+
def encode(self, text, max_len=512):
|
| 71 |
+
return torch.zeros(1, max_len, dtype=torch.long)
|
| 72 |
+
def get_embeddings(self):
|
| 73 |
+
return torch.randn(5000, 256)
|
| 74 |
+
|
| 75 |
+
class MAYINIModel:
|
| 76 |
+
def __init__(self, **kwargs):
|
| 77 |
+
self.config = kwargs
|
| 78 |
+
def eval(self):
|
| 79 |
+
return self
|
| 80 |
+
def get_embeddings(self, input_ids):
|
| 81 |
+
return torch.randn(1, 512, 256)
|
| 82 |
+
def forward(self, input_ids):
|
| 83 |
+
return torch.randn(1, 5000)
|
| 84 |
+
def count_parameters(self):
|
| 85 |
+
return 3500000
|
| 86 |
+
|
| 87 |
+
logger.info(" β Mock MAYINI classes created")
|
| 88 |
+
|
| 89 |
+
try:
|
| 90 |
+
logger.info(" - Importing Job Scraper...")
|
| 91 |
+
from scraper import JobScraper
|
| 92 |
+
logger.info(" β Scraper imported")
|
| 93 |
+
except ImportError as e:
|
| 94 |
+
logger.warning(f" β οΈ Could not import Scraper: {e}")
|
| 95 |
+
logger.warning(" Creating mock Scraper class...")
|
| 96 |
+
|
| 97 |
+
class JobScraper:
|
| 98 |
+
def __init__(self):
|
| 99 |
+
self.jobs = [
|
| 100 |
+
{
|
| 101 |
+
'title': 'Senior Python Developer',
|
| 102 |
+
'company': 'Tech Giants Inc',
|
| 103 |
+
'location': 'Remote',
|
| 104 |
+
'description': 'We are looking for a Senior Python Developer',
|
| 105 |
+
'requirements': ['Python', 'Docker', 'AWS'],
|
| 106 |
+
'salary_range': '$120k - $160k',
|
| 107 |
+
'experience_required': 5
|
| 108 |
+
},
|
| 109 |
+
{
|
| 110 |
+
'title': 'ML Engineer',
|
| 111 |
+
'company': 'AI Solutions',
|
| 112 |
+
'location': 'San Francisco',
|
| 113 |
+
'description': 'Machine Learning Engineer role',
|
| 114 |
+
'requirements': ['Python', 'PyTorch', 'TensorFlow'],
|
| 115 |
+
'salary_range': '$150k - $180k',
|
| 116 |
+
'experience_required': 4
|
| 117 |
+
}
|
| 118 |
+
]
|
| 119 |
+
def get_all_jobs(self):
|
| 120 |
+
return self.jobs
|
| 121 |
+
def search_jobs(self, keywords=None, location=None, limit=10):
|
| 122 |
+
return self.jobs[:limit]
|
| 123 |
+
def filter_by_experience(self, jobs, min_years=0, max_years=10):
|
| 124 |
+
return [j for j in jobs if min_years <= j.get('experience_required', 0) <= max_years]
|
| 125 |
+
|
| 126 |
+
logger.info(" β Mock Scraper class created")
|
| 127 |
+
|
| 128 |
+
try:
|
| 129 |
+
logger.info(" - Importing Resume Customizer...")
|
| 130 |
+
from customizer import ResumeCustomizer
|
| 131 |
+
logger.info(" β Customizer imported")
|
| 132 |
+
except ImportError as e:
|
| 133 |
+
logger.warning(f" β οΈ Could not import Customizer: {e}")
|
| 134 |
+
logger.warning(" Creating mock Customizer class...")
|
| 135 |
+
|
| 136 |
+
class ResumeCustomizer:
|
| 137 |
+
def __init__(self, model, vocab):
|
| 138 |
+
self.model = model
|
| 139 |
+
self.vocab = vocab
|
| 140 |
+
def customize_for_job(self, job):
|
| 141 |
+
return {
|
| 142 |
+
'summary': f"Experienced professional ready for {job.get('title', 'N/A')} role",
|
| 143 |
+
'skills': ['Python', 'Docker', 'AWS', 'Git', 'REST API'],
|
| 144 |
+
'customized_for': {'match_score': 0.85}
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
logger.info(" β Mock Customizer class created")
|
| 148 |
+
|
| 149 |
+
try:
|
| 150 |
+
logger.info(" - Importing Job Classifier...")
|
| 151 |
+
from classifier import JobRelevanceClassifier
|
| 152 |
+
logger.info(" β Classifier imported")
|
| 153 |
+
except ImportError as e:
|
| 154 |
+
logger.warning(f" β οΈ Could not import Classifier: {e}")
|
| 155 |
+
logger.warning(" Creating mock Classifier class...")
|
| 156 |
+
|
| 157 |
+
class JobRelevanceClassifier:
|
| 158 |
+
def __init__(self, **kwargs):
|
| 159 |
+
pass
|
| 160 |
+
def classify_job(self, job, skills):
|
| 161 |
+
return 0.75
|
| 162 |
+
def get_match_details(self, job, skills):
|
| 163 |
+
return {
|
| 164 |
+
'relevance_score': 0.75,
|
| 165 |
+
'recommendation': 'Consider applying',
|
| 166 |
+
'matching_skills': ['Python', 'Docker'],
|
| 167 |
+
'missing_skills': ['Kubernetes']
|
| 168 |
+
}
|
| 169 |
+
def rank_jobs(self, jobs, skills):
|
| 170 |
+
return [(j, 0.7 + i*0.05) for i, j in enumerate(jobs)]
|
| 171 |
+
|
| 172 |
+
logger.info(" β Mock Classifier class created")
|
| 173 |
+
|
| 174 |
+
try:
|
| 175 |
+
logger.info(" - Importing Application Agent...")
|
| 176 |
+
from agent import JobApplicationAgent
|
| 177 |
+
logger.info(" β Agent imported")
|
| 178 |
+
except ImportError as e:
|
| 179 |
+
logger.warning(f" β οΈ Could not import Agent: {e}")
|
| 180 |
+
logger.warning(" Creating mock Agent class...")
|
| 181 |
+
|
| 182 |
+
class JobApplicationAgent:
|
| 183 |
+
def __init__(self, scraper, customizer, classifier):
|
| 184 |
+
self.scraper = scraper
|
| 185 |
+
self.customizer = customizer
|
| 186 |
+
self.classifier = classifier
|
| 187 |
+
def search_and_apply(self, keywords=None, location=None, num_jobs=5):
|
| 188 |
+
jobs = self.scraper.search_jobs(limit=num_jobs)
|
| 189 |
+
return {
|
| 190 |
+
'total_jobs_found': len(jobs),
|
| 191 |
+
'relevant_jobs': len(jobs),
|
| 192 |
+
'pass_rate': 0.85,
|
| 193 |
+
'applications': [
|
| 194 |
+
{'job': j, 'relevance_score': 0.8, 'match_details': {
|
| 195 |
+
'matching_skills': ['Python', 'Docker'],
|
| 196 |
+
'missing_skills': ['Kubernetes']
|
| 197 |
+
}} for j in jobs
|
| 198 |
+
]
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
logger.info(" β Mock Agent class created")
|
| 202 |
+
|
| 203 |
+
logger.info("\n" + "=" * 80)
|
| 204 |
+
logger.info("β
All components loaded (using mock classes if needed)")
|
| 205 |
+
logger.info("=" * 80)
|
| 206 |
+
|
| 207 |
+
# ============================================================================
|
| 208 |
+
# INITIALIZATION
|
| 209 |
+
# ============================================================================
|
| 210 |
+
|
| 211 |
+
logger.info("\nπ§ Initializing components...")
|
| 212 |
+
|
| 213 |
+
try:
|
| 214 |
+
vocab = MAYINIVocabulary(vocab_size=5000)
|
| 215 |
+
logger.info("β MAYINI Vocabulary initialized")
|
| 216 |
+
except Exception as e:
|
| 217 |
+
logger.error(f"Error initializing vocabulary: {e}")
|
| 218 |
+
vocab = MAYINIVocabulary()
|
| 219 |
+
|
| 220 |
+
try:
|
| 221 |
+
mayini_model = MAYINIModel(
|
| 222 |
+
vocab_size=5000,
|
| 223 |
+
hidden_dim=256,
|
| 224 |
+
num_heads=8,
|
| 225 |
+
num_layers=4
|
| 226 |
+
)
|
| 227 |
+
mayini_model.eval()
|
| 228 |
+
logger.info("β MAYINI Model initialized")
|
| 229 |
+
except Exception as e:
|
| 230 |
+
logger.error(f"Error initializing model: {e}")
|
| 231 |
+
mayini_model = MAYINIModel()
|
| 232 |
+
|
| 233 |
+
try:
|
| 234 |
+
scraper = JobScraper()
|
| 235 |
+
logger.info("β Job Scraper initialized")
|
| 236 |
+
except Exception as e:
|
| 237 |
+
logger.error(f"Error initializing scraper: {e}")
|
| 238 |
+
scraper = JobScraper()
|
| 239 |
+
|
| 240 |
+
try:
|
| 241 |
+
customizer = ResumeCustomizer(mayini_model, vocab)
|
| 242 |
+
logger.info("β Resume Customizer initialized")
|
| 243 |
+
except Exception as e:
|
| 244 |
+
logger.error(f"Error initializing customizer: {e}")
|
| 245 |
+
customizer = ResumeCustomizer(mayini_model, vocab)
|
| 246 |
+
|
| 247 |
+
try:
|
| 248 |
+
classifier = JobRelevanceClassifier()
|
| 249 |
+
if hasattr(classifier, 'mayini_model'):
|
| 250 |
classifier.mayini_model = mayini_model
|
| 251 |
+
logger.info("β Job Classifier initialized")
|
| 252 |
+
except Exception as e:
|
| 253 |
+
logger.error(f"Error initializing classifier: {e}")
|
| 254 |
+
classifier = JobRelevanceClassifier()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
|
| 256 |
+
try:
|
| 257 |
+
agent = JobApplicationAgent(scraper, customizer, classifier)
|
| 258 |
+
logger.info("β Application Agent initialized")
|
| 259 |
+
except Exception as e:
|
| 260 |
+
logger.error(f"Error initializing agent: {e}")
|
| 261 |
+
agent = JobApplicationAgent(scraper, customizer, classifier)
|
| 262 |
+
|
| 263 |
+
logger.info("\n" + "=" * 80)
|
| 264 |
+
logger.info("β
INITIALIZATION COMPLETE - Application ready to serve!")
|
| 265 |
+
logger.info("=" * 80 + "\n")
|
| 266 |
|
| 267 |
# ============================================================================
|
| 268 |
# INTERFACE FUNCTIONS
|
| 269 |
# ============================================================================
|
| 270 |
|
| 271 |
def search_jobs_interface(keywords: str, location: str, num_jobs: int) -> str:
|
| 272 |
+
"""Search and rank jobs"""
|
|
|
|
|
|
|
|
|
|
| 273 |
try:
|
| 274 |
if not keywords or not keywords.strip():
|
| 275 |
+
return "β **Error:** Please enter keywords"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 276 |
|
| 277 |
results = agent.search_and_apply(
|
| 278 |
keywords=keywords.strip(),
|
| 279 |
+
location=location.strip() if location else "Remote",
|
| 280 |
num_jobs=int(num_jobs)
|
| 281 |
)
|
| 282 |
|
| 283 |
+
output = f"β
**Search Results**\n\n"
|
| 284 |
+
output += f"- Found: {results.get('total_jobs_found', 0)} jobs\n"
|
| 285 |
+
output += f"- Relevant: {results.get('relevant_jobs', 0)} jobs\n"
|
| 286 |
+
output += f"- Pass Rate: {results.get('pass_rate', 0):.1%}\n\n"
|
|
|
|
|
|
|
|
|
|
| 287 |
output += "---\n\n"
|
| 288 |
|
| 289 |
for i, app in enumerate(results.get('applications', [])[:5], 1):
|
|
|
|
| 293 |
output += f"**{i}. {job.get('title', 'N/A')}**\n"
|
| 294 |
output += f"- Company: {job.get('company', 'N/A')}\n"
|
| 295 |
output += f"- Location: {job.get('location', 'N/A')}\n"
|
| 296 |
+
output += f"- π― Relevance: **{score:.0%}**\n"
|
| 297 |
output += f"- π° Salary: {job.get('salary_range', 'Not specified')}\n"
|
| 298 |
+
output += f"- π Experience: {job.get('experience_required', 'N/A')} years\n\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
|
|
|
|
| 300 |
return output
|
|
|
|
| 301 |
except Exception as e:
|
| 302 |
+
logger.error(f"Error in search: {e}\n{traceback.format_exc()}")
|
| 303 |
+
return f"β **Error:** {str(e)}\n\nPlease try again."
|
|
|
|
| 304 |
|
| 305 |
def customize_resume_interface(job_title: str, company: str, requirements: str) -> str:
|
| 306 |
+
"""Customize resume for job"""
|
|
|
|
|
|
|
| 307 |
try:
|
| 308 |
if not job_title or not job_title.strip():
|
| 309 |
+
return "β **Error:** Please enter job title"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 310 |
|
| 311 |
job = {
|
| 312 |
'title': job_title.strip(),
|
| 313 |
'company': company.strip(),
|
| 314 |
+
'requirements': [r.strip() for r in requirements.split(',') if r.strip()] if requirements else []
|
|
|
|
| 315 |
}
|
| 316 |
|
| 317 |
customized = customizer.customize_for_job(job)
|
| 318 |
|
| 319 |
output = f"β
**Customized Resume**\n\n"
|
| 320 |
output += f"**Job:** {job_title} @ {company}\n\n"
|
| 321 |
+
output += f"**Summary:**\n{customized.get('summary', 'N/A')}\n\n"
|
| 322 |
+
output += f"**Top Skills:**\n"
|
| 323 |
|
| 324 |
+
for skill in customized.get('skills', [])[:10]:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
output += f"β’ {skill}\n"
|
| 326 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
return output
|
|
|
|
| 328 |
except Exception as e:
|
| 329 |
+
logger.error(f"Error in customization: {e}\n{traceback.format_exc()}")
|
| 330 |
+
return f"β **Error:** {str(e)}\n\nPlease check your inputs."
|
|
|
|
| 331 |
|
| 332 |
def classify_job_interface(job_title: str, requirements: str) -> str:
|
| 333 |
+
"""Classify job relevance"""
|
|
|
|
|
|
|
| 334 |
try:
|
| 335 |
if not job_title or not job_title.strip():
|
| 336 |
+
return "β **Error:** Please enter job title"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
|
| 338 |
job = {
|
| 339 |
'title': job_title.strip(),
|
| 340 |
+
'requirements': [r.strip() for r in requirements.split(',') if r.strip()] if requirements else [],
|
|
|
|
| 341 |
'location': 'Remote',
|
| 342 |
'company': 'Unknown',
|
| 343 |
+
'description': job_title.strip(),
|
| 344 |
'experience_required': 5,
|
| 345 |
'salary_range': 'Unknown'
|
| 346 |
}
|
| 347 |
|
|
|
|
| 348 |
resume_skills = [
|
| 349 |
"Python", "Docker", "AWS", "PostgreSQL", "REST API",
|
| 350 |
+
"Microservices", "Git", "Kubernetes", "Machine Learning"
|
|
|
|
| 351 |
]
|
| 352 |
|
| 353 |
score = classifier.classify_job(job, resume_skills)
|
| 354 |
details = classifier.get_match_details(job, resume_skills)
|
| 355 |
|
| 356 |
+
output = f"β
**Job Classification**\n\n"
|
| 357 |
+
output += f"**Job:** {job_title}\n\n"
|
| 358 |
|
|
|
|
| 359 |
score_percent = score * 100
|
| 360 |
if score >= 0.8:
|
| 361 |
emoji = "π’"
|
|
|
|
| 370 |
emoji = "π΄"
|
| 371 |
level = "POOR"
|
| 372 |
|
| 373 |
+
output += f"{emoji} **Score:** {score_percent:.1f}% ({level})\n\n"
|
| 374 |
+
output += f"β **Matching:** {', '.join(details.get('matching_skills', []))}\n"
|
| 375 |
+
output += f"β **Missing:** {', '.join(details.get('missing_skills', []))}\n"
|
| 376 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 377 |
return output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 378 |
except Exception as e:
|
| 379 |
+
logger.error(f"Error in classification: {e}\n{traceback.format_exc()}")
|
| 380 |
+
return f"β **Error:** {str(e)}\n\nPlease check your inputs."
|
| 381 |
|
| 382 |
# ============================================================================
|
| 383 |
# GRADIO INTERFACE
|
| 384 |
# ============================================================================
|
| 385 |
|
| 386 |
+
logger.info("π¨ Building Gradio interface...")
|
| 387 |
+
|
| 388 |
+
with gr.Blocks(title="Job Application Agent", theme=gr.themes.Soft()) as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
|
|
|
|
| 390 |
gr.Markdown("""
|
| 391 |
# π€ Job Application Agent
|
| 392 |
### AI-Powered Job Search & Resume Customization
|
| 393 |
+
**Powered by MAYINI Framework - Custom Transformer ML Model**
|
|
|
|
|
|
|
| 394 |
""")
|
| 395 |
|
|
|
|
| 396 |
with gr.Tab("π Search & Match Jobs"):
|
| 397 |
+
gr.Markdown("Find jobs matching your skills using AI-powered matching.")
|
|
|
|
|
|
|
| 398 |
with gr.Row():
|
| 399 |
with gr.Column():
|
| 400 |
+
search_keywords = gr.Textbox(label="Keywords", placeholder="python docker aws", value="python")
|
| 401 |
+
search_location = gr.Textbox(label="Location", placeholder="Remote", value="Remote")
|
| 402 |
+
search_num = gr.Slider(minimum=1, maximum=20, value=5, step=1, label="Number of Jobs")
|
| 403 |
+
search_btn = gr.Button("π Search", variant="primary")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 404 |
with gr.Column():
|
| 405 |
+
search_output = gr.Markdown(value="### Results will appear here...")
|
|
|
|
|
|
|
|
|
|
| 406 |
|
| 407 |
+
search_btn.click(fn=search_jobs_interface, inputs=[search_keywords, search_location, search_num], outputs=search_output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 408 |
|
|
|
|
| 409 |
with gr.Tab("π Customize Resume"):
|
| 410 |
+
gr.Markdown("Tailor your resume for specific job opportunities.")
|
|
|
|
|
|
|
| 411 |
with gr.Row():
|
| 412 |
with gr.Column():
|
| 413 |
+
customize_title = gr.Textbox(label="Job Title", placeholder="Senior Python Developer")
|
| 414 |
+
customize_company = gr.Textbox(label="Company", placeholder="Tech Inc")
|
| 415 |
+
customize_req = gr.Textbox(label="Requirements", placeholder="Python, Docker, AWS", lines=2)
|
| 416 |
+
customize_btn = gr.Button("β¨ Customize", variant="primary")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 417 |
with gr.Column():
|
| 418 |
+
customize_output = gr.Markdown(value="### Customized resume will appear here...")
|
|
|
|
|
|
|
|
|
|
| 419 |
|
| 420 |
+
customize_btn.click(fn=customize_resume_interface, inputs=[customize_title, customize_company, customize_req], outputs=customize_output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 421 |
|
| 422 |
+
with gr.Tab("π― Classify Job"):
|
| 423 |
+
gr.Markdown("Check job relevance to your skills.")
|
|
|
|
|
|
|
|
|
|
| 424 |
with gr.Row():
|
| 425 |
with gr.Column():
|
| 426 |
+
classify_title = gr.Textbox(label="Job Title", placeholder="ML Engineer")
|
| 427 |
+
classify_req = gr.Textbox(label="Requirements", placeholder="Python, PyTorch", lines=2)
|
| 428 |
+
classify_btn = gr.Button("π― Classify", variant="primary")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 429 |
with gr.Column():
|
| 430 |
+
classify_output = gr.Markdown(value="### Results will appear here...")
|
|
|
|
|
|
|
|
|
|
| 431 |
|
| 432 |
+
classify_btn.click(fn=classify_job_interface, inputs=[classify_title, classify_req], outputs=classify_output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 433 |
|
| 434 |
+
with gr.Tab("βΉοΈ About"):
|
|
|
|
| 435 |
gr.Markdown("""
|
| 436 |
+
## Job Application Agent
|
| 437 |
+
Powered by **MAYINI Framework** - a custom Transformer-based ML model.
|
| 438 |
+
|
| 439 |
+
**Features:**
|
| 440 |
+
- π AI-powered job search
|
| 441 |
+
- π Resume customization
|
| 442 |
+
- π― Job relevance scoring
|
| 443 |
+
|
| 444 |
+
**MAYINI Specs:**
|
| 445 |
+
- Vocabulary: 5,000 tokens
|
| 446 |
+
- Hidden Dims: 256
|
| 447 |
+
- Heads: 8
|
| 448 |
+
- Layers: 4
|
| 449 |
+
- Parameters: ~3.5M
|
| 450 |
+
|
| 451 |
+
**Repository:**
|
| 452 |
+
[GitHub](https://github.com/907-bot/Job-Application-Agent)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 453 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 454 |
|
| 455 |
+
logger.info("β Gradio interface built successfully\n")
|
| 456 |
|
| 457 |
# ============================================================================
|
| 458 |
+
# LAUNCH
|
| 459 |
# ============================================================================
|
| 460 |
|
| 461 |
if __name__ == "__main__":
|
| 462 |
+
logger.info("π LAUNCHING APPLICATION")
|
| 463 |
+
logger.info("Access at: http://0.0.0.0:7860\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 464 |
|
| 465 |
try:
|
| 466 |
demo.queue(max_size=32, concurrency_count=4).launch(
|
| 467 |
server_name="0.0.0.0",
|
| 468 |
server_port=7860,
|
| 469 |
show_error=True,
|
| 470 |
+
share=False
|
|
|
|
| 471 |
)
|
| 472 |
except Exception as e:
|
| 473 |
+
logger.error(f"Launch failed: {e}\n{traceback.format_exc()}")
|
| 474 |
+
sys.exit(1)
|
|
|