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", )