CV_generator / app.py
omaralaa2004's picture
Update app.py
532ace3 verified
from transformers import pipeline
from docx import Document
import gradio as gr
# Load lightweight model for basic text polishing (optional, not used heavily)
generator = pipeline("text-generation", model="tiiuae/falcon-rw-1b", device=-1)
def generate_cv_docx(name, title, location, email, linkedin, github, portfolio,
summary, tech_skills, soft_skills, education,
languages, experience, projects, certifications):
# Create document
doc = Document()
# Header
doc.add_heading(name, level=1)
doc.add_paragraph(f"{title}")
doc.add_paragraph(f"{location} | {email}")
doc.add_paragraph(f"LinkedIn: {linkedin} | GitHub: {github} | Portfolio: {portfolio}")
# Sections
doc.add_heading("Professional Summary", level=2)
doc.add_paragraph(summary)
doc.add_heading("Technical Skills", level=2)
doc.add_paragraph(tech_skills)
doc.add_heading("Soft Skills", level=2)
doc.add_paragraph(soft_skills)
doc.add_heading("Education", level=2)
doc.add_paragraph(education)
doc.add_heading("Languages", level=2)
doc.add_paragraph(languages)
doc.add_heading("Experience", level=2)
doc.add_paragraph(experience)
doc.add_heading("Key Projects", level=2)
doc.add_paragraph(projects)
doc.add_heading("Certifications", level=2)
doc.add_paragraph(certifications)
# Save the file
filepath = "generated_cv.docx"
doc.save(filepath)
return filepath
# Gradio UI
interface = gr.Interface(
fn=generate_cv_docx,
inputs=[
gr.Textbox(label="Full Name"),
gr.Textbox(label="Job Title"),
gr.Textbox(label="Location"),
gr.Textbox(label="Email"),
gr.Textbox(label="LinkedIn URL"),
gr.Textbox(label="GitHub URL"),
gr.Textbox(label="Portfolio URL"),
gr.Textbox(label="Professional Summary", lines=4, placeholder="Write 2–4 lines about your profile..."),
gr.Textbox(label="Technical Skills (Languages, Libraries, Tools)", lines=3),
gr.Textbox(label="Soft Skills", lines=2),
gr.Textbox(label="Education", lines=3),
gr.Textbox(label="Languages Known", lines=2),
gr.Textbox(label="Experience (Job Title, Company, Dates, Bullets)", lines=4),
gr.Textbox(label="Key Projects", lines=4),
gr.Textbox(label="Certifications", lines=3)
],
outputs=gr.File(label="Download Your CV (.docx)"),
title="Free CV Builder (Download as Word)",
description="🧠 Build your CV using a clean form and download it as a Word document — powered by open-source AI, no payment required!"
)
interface.launch()