Navya-Sree commited on
Commit
5beb457
Β·
verified Β·
1 Parent(s): 9b92590

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -0
app.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from datetime import datetime
3
+ from utils import generate_cover_letter
4
+
5
+ # Custom CSS for modern styling
6
+ custom_css = """
7
+ #title { text-align: center; }
8
+ .footer { font-size: 0.8em !important; }
9
+ .important { color: #d35400 !important; }
10
+ textarea { font-size: 14px !important; }
11
+ """
12
+
13
+ def generate(job_desc, resume, name, email, phone, company, hiring_manager):
14
+ # Generate cover letter body using NLP
15
+ letter_body = generate_cover_letter(job_desc, resume)
16
+
17
+ # Format final letter
18
+ today = datetime.today().strftime("%B %d, %Y")
19
+ return f"""
20
+ {today}
21
+
22
+ {hiring_manager or "Hiring Manager"}
23
+ {company or "Company Name"}
24
+
25
+ Dear {hiring_manager.split()[0] + ',' if hiring_manager else "Hiring Manager,"}
26
+
27
+ {letter_body}
28
+
29
+ Sincerely,
30
+ {name}
31
+ {email} | {phone}
32
+ """
33
+
34
+ with gr.Blocks(css=custom_css, title="Cover Letter Generator") as demo:
35
+ gr.Markdown("""# ✨ AI Cover Letter Generator""", elem_id="title")
36
+
37
+ with gr.Row():
38
+ with gr.Column():
39
+ job_desc = gr.Textbox(label="πŸ“ Job Description", lines=8, placeholder="Paste the job description here...")
40
+ resume = gr.Textbox(label="πŸ“„ Your Resume/CV", lines=10, placeholder="Paste your resume content here...")
41
+ gr.Examples(
42
+ examples=[["assets/example_resume.pdf"]],
43
+ inputs=[resume],
44
+ label="Example Resume"
45
+ )
46
+
47
+ with gr.Column():
48
+ name = gr.Textbox(label="πŸ‘€ Full Name")
49
+ email = gr.Textbox(label="βœ‰οΈ Email")
50
+ phone = gr.Textbox(label="πŸ“± Phone")
51
+ company = gr.Textbox(label="🏒 Company (Optional)")
52
+ hiring_manager = gr.Textbox(label="πŸ‘” Hiring Manager (Optional)")
53
+ btn = gr.Button("Generate Cover Letter", variant="primary")
54
+
55
+ output = gr.Textbox(label="πŸ“œ Your Custom Cover Letter", lines=15, interactive=True)
56
+ footer = gr.Markdown("""
57
+ <div class="footer">
58
+ <p>πŸ’‘ Tip: Paste your full resume for best results. The AI will match your skills to the job requirements.</p>
59
+ <p class="important">⚠️ Always review generated content before sending!</p>
60
+ </div>
61
+ """)
62
+
63
+ btn.click(
64
+ generate,
65
+ inputs=[job_desc, resume, name, email, phone, company, hiring_manager],
66
+ outputs=output
67
+ )
68
+
69
+ if __name__ == "__main__":
70
+ demo.launch()