Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,53 @@
|
|
| 1 |
from transformers import pipeline
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
generator = pipeline("text-generation", model="tiiuae/falcon-rw-1b", device=-1)
|
| 5 |
|
| 6 |
-
def
|
| 7 |
prompt = f"""
|
| 8 |
-
|
| 9 |
|
| 10 |
-
Name: {name}
|
| 11 |
-
|
| 12 |
Education: {education}
|
| 13 |
Experience: {experience}
|
| 14 |
Skills: {skills}
|
| 15 |
-
|
| 16 |
-
CV:
|
| 17 |
"""
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
-
fn=
|
| 23 |
inputs=[
|
| 24 |
gr.Textbox(label="Full Name"),
|
| 25 |
-
gr.Textbox(label="Job Title
|
| 26 |
gr.Textbox(label="Education"),
|
| 27 |
gr.Textbox(label="Work Experience"),
|
| 28 |
gr.Textbox(label="Skills")
|
| 29 |
],
|
| 30 |
-
outputs="
|
| 31 |
-
title="Free CV Builder (
|
| 32 |
-
description="
|
| 33 |
)
|
| 34 |
|
| 35 |
-
|
|
|
|
| 1 |
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()
|