Spaces:
Sleeping
Sleeping
File size: 3,807 Bytes
c51a48f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | import streamlit as st
import random
import time
# --- Mock AI for CV Generation ---
# In a real application, this function would call a generative AI model API
# (e.g., Google's Gemini API, OpenAI's GPT) to create the CV content.
def generate_cv(data):
"""
Generates a CV in Markdown format based on user input data.
This is a mock function that simulates a generative AI response.
"""
st.info("Generating your CV... Please wait.")
# Simulate an API call delay
with st.spinner('Thinking...'):
time.sleep(random.uniform(2, 5))
cv_text = f"""
# {data['name']}
**Contact:** {data['contact']}
---
### Professional Summary
{data['summary']}
---
### Skills
{data['skills']}
---
### Work Experience
"""
for exp in data['experience']:
cv_text += f"""
**{exp['title']}** at *{exp['company']}* ({exp['dates']})
- {exp['description']}
"""
cv_text += f"""
---
### Education
**{data['education']['degree']}** in {data['education']['field']}
{data['education']['school']} ({data['education']['year']})
"""
return cv_text
# --- Streamlit UI ---
st.set_page_config(
page_title="Generative CV Maker",
layout="wide",
initial_sidebar_state="expanded",
)
st.title("📄 AI-Powered CV Maker")
st.markdown("Enter your details and let our AI assistant generate a professional CV for you.")
# --- User Input Form (in sidebar) ---
st.sidebar.header("Your Information")
with st.sidebar.form("cv_form"):
name = st.text_input("Full Name", "John Doe")
contact = st.text_input("Contact Info", "john.doe@email.com | +1234567890")
summary = st.text_area("Professional Summary", "A highly motivated and results-oriented professional with a strong background in...")
st.subheader("Skills")
skills = st.text_area("List your skills (comma-separated)", "Python, Data Analysis, Machine Learning, Streamlit, Git")
st.subheader("Work Experience")
num_experience = st.number_input("Number of experiences", min_value=1, max_value=5, value=1)
experiences = []
for i in range(num_experience):
st.markdown(f"**Experience {i+1}**")
exp_title = st.text_input(f"Job Title ({i+1})", "Data Scientist")
exp_company = st.text_input(f"Company ({i+1})", "Tech Solutions Inc.")
exp_dates = st.text_input(f"Dates ({i+1})", "Jan 2020 - Present")
exp_description = st.text_area(f"Description ({i+1})", "• Performed data analysis using Python and Pandas.\n• Built and deployed machine learning models to solve business problems.")
experiences.append({
"title": exp_title,
"company": exp_company,
"dates": exp_dates,
"description": exp_description,
})
st.subheader("Education")
edu_degree = st.text_input("Degree", "Master of Science")
edu_field = st.text_input("Field of Study", "Computer Science")
edu_school = st.text_input("University/College", "State University")
edu_year = st.text_input("Year of Graduation", "2019")
education = {
"degree": edu_degree,
"field": edu_field,
"school": edu_school,
"year": edu_year,
}
# Every form must have a submit button.
submitted = st.form_submit_button("Generate CV")
# --- Display Generated CV ---
if submitted:
user_data = {
"name": name,
"contact": contact,
"summary": summary,
"skills": skills,
"experience": experiences,
"education": education,
}
cv_content = generate_cv(user_data)
st.header("✨ Your AI-Generated CV")
st.markdown("---")
st.markdown(cv_content)
st.download_button(
label="Download CV",
data=cv_content,
file_name="my_generated_cv.md",
mime="text/markdown",
) |