omaralaa2004 commited on
Commit
532ace3
·
verified ·
1 Parent(s): a673074

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -20
app.py CHANGED
@@ -2,52 +2,76 @@ from transformers import pipeline
2
  from docx import Document
3
  import gradio as gr
4
 
 
5
  generator = pipeline("text-generation", model="tiiuae/falcon-rw-1b", device=-1)
6
 
7
- def generate_cv_docx(name, title, education, experience, skills):
8
- prompt = f"""
9
- You are a CV assistant. Generate a clean, structured CV in this format:
10
-
11
- Full Name: {name}
12
- Title: {title}
13
- Education: {education}
14
- Experience: {experience}
15
- Skills: {skills}
16
- """
17
- result = generator(prompt, max_length=512, do_sample=True, temperature=0.7)[0]['generated_text']
18
 
19
- # Generate Word doc
20
  doc = Document()
 
 
21
  doc.add_heading(name, level=1)
22
- doc.add_paragraph(title, style='Intense Quote')
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  doc.add_heading("Education", level=2)
25
  doc.add_paragraph(education)
26
 
 
 
 
27
  doc.add_heading("Experience", level=2)
28
  doc.add_paragraph(experience)
29
 
30
- doc.add_heading("Skills", level=2)
31
- doc.add_paragraph(skills)
 
 
 
32
 
33
- # Save document
34
  filepath = "generated_cv.docx"
35
  doc.save(filepath)
36
 
37
  return filepath
38
 
 
39
  interface = gr.Interface(
40
  fn=generate_cv_docx,
41
  inputs=[
42
  gr.Textbox(label="Full Name"),
43
  gr.Textbox(label="Job Title"),
44
- gr.Textbox(label="Education"),
45
- gr.Textbox(label="Work Experience"),
46
- gr.Textbox(label="Skills")
 
 
 
 
 
 
 
 
 
 
47
  ],
48
  outputs=gr.File(label="Download Your CV (.docx)"),
49
  title="Free CV Builder (Download as Word)",
50
- description="This tool creates a structured Word CV using free AI and lets you download it."
51
  )
52
 
53
  interface.launch()
 
2
  from docx import Document
3
  import gradio as gr
4
 
5
+ # Load lightweight model for basic text polishing (optional, not used heavily)
6
  generator = pipeline("text-generation", model="tiiuae/falcon-rw-1b", device=-1)
7
 
8
+ def generate_cv_docx(name, title, location, email, linkedin, github, portfolio,
9
+ summary, tech_skills, soft_skills, education,
10
+ languages, experience, projects, certifications):
 
 
 
 
 
 
 
 
11
 
12
+ # Create document
13
  doc = Document()
14
+
15
+ # Header
16
  doc.add_heading(name, level=1)
17
+ doc.add_paragraph(f"{title}")
18
+ doc.add_paragraph(f"{location} | {email}")
19
+ doc.add_paragraph(f"LinkedIn: {linkedin} | GitHub: {github} | Portfolio: {portfolio}")
20
+
21
+ # Sections
22
+ doc.add_heading("Professional Summary", level=2)
23
+ doc.add_paragraph(summary)
24
+
25
+ doc.add_heading("Technical Skills", level=2)
26
+ doc.add_paragraph(tech_skills)
27
+
28
+ doc.add_heading("Soft Skills", level=2)
29
+ doc.add_paragraph(soft_skills)
30
 
31
  doc.add_heading("Education", level=2)
32
  doc.add_paragraph(education)
33
 
34
+ doc.add_heading("Languages", level=2)
35
+ doc.add_paragraph(languages)
36
+
37
  doc.add_heading("Experience", level=2)
38
  doc.add_paragraph(experience)
39
 
40
+ doc.add_heading("Key Projects", level=2)
41
+ doc.add_paragraph(projects)
42
+
43
+ doc.add_heading("Certifications", level=2)
44
+ doc.add_paragraph(certifications)
45
 
46
+ # Save the file
47
  filepath = "generated_cv.docx"
48
  doc.save(filepath)
49
 
50
  return filepath
51
 
52
+ # Gradio UI
53
  interface = gr.Interface(
54
  fn=generate_cv_docx,
55
  inputs=[
56
  gr.Textbox(label="Full Name"),
57
  gr.Textbox(label="Job Title"),
58
+ gr.Textbox(label="Location"),
59
+ gr.Textbox(label="Email"),
60
+ gr.Textbox(label="LinkedIn URL"),
61
+ gr.Textbox(label="GitHub URL"),
62
+ gr.Textbox(label="Portfolio URL"),
63
+ gr.Textbox(label="Professional Summary", lines=4, placeholder="Write 2–4 lines about your profile..."),
64
+ gr.Textbox(label="Technical Skills (Languages, Libraries, Tools)", lines=3),
65
+ gr.Textbox(label="Soft Skills", lines=2),
66
+ gr.Textbox(label="Education", lines=3),
67
+ gr.Textbox(label="Languages Known", lines=2),
68
+ gr.Textbox(label="Experience (Job Title, Company, Dates, Bullets)", lines=4),
69
+ gr.Textbox(label="Key Projects", lines=4),
70
+ gr.Textbox(label="Certifications", lines=3)
71
  ],
72
  outputs=gr.File(label="Download Your CV (.docx)"),
73
  title="Free CV Builder (Download as Word)",
74
+ description="🧠 Build your CV using a clean form and download it as a Word document powered by open-source AI, no payment required!"
75
  )
76
 
77
  interface.launch()