Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from langchain_google_genai import GoogleGenerativeAI | |
| import langchain | |
| import time | |
| import subprocess as s | |
| import sys | |
| from langchain_core.prompts import PromptTemplate | |
| st.title("resume creator by ahmed") | |
| api="AIzaSyB3VJeF1jN9CiKWE01koqR1SRE6k-3aIr0" | |
| time.sleep(5) | |
| llm=GoogleGenerativeAI(model="gemini-1.5-flash",google_api_key=api,temperature=0.3) | |
| choice=st.text_input("for which proffession you are creating resume") | |
| Name=st.text_input("enter name") | |
| Email=st.text_input("enter email") | |
| Phone=st.text_input("enter phone") | |
| Location=st.text_input("enter location") | |
| LinkedIn=st.text_input("enter linkedin if applicable") | |
| GitHub=st.text_input("enter github if applicable") | |
| Education=st.text_input("enter education") | |
| Skills=st.text_input("enter skills") | |
| Projects=st.text_input("enter projects") | |
| Experience=st.text_input("enter experience if applicable") | |
| Internship=st.text_input("enter internships if applicable") | |
| b=st.button("submit information") | |
| if b: | |
| if not skills: | |
| skills=f"Use skills relevant to the interest {choice}" | |
| if not LinkedIn: | |
| LinkedIn="not provided" | |
| if not GitHub: | |
| GitHub="not provided" | |
| if not Experience: | |
| Experience="not provided" | |
| if not Internship: | |
| Internship="not provided" | |
| if Name and Email and choice and Phone and Location and Education and Skills and Projects: | |
| template = '''Create a professional, ATS-friendly resume for a candidate with the following interests and background: | |
| User Interest: | |
| {choice} | |
| Candidate Details: | |
| - Name: {Name} | |
| - Email: {Email} | |
| - Phone: {Phone} | |
| - Location: {Location} | |
| - LinkedIn: {Linkedin} | |
| - GitHub: {GitHub} | |
| Instructions: | |
| - Use clear section headings | |
| - Keep the resume concise and professional | |
| - Include only sections for which information is provided | |
| - Do NOT mention missing or empty fields | |
| - Do NOT write phrases like "Not provided" | |
| - Do NOT add fake experience | |
| - Use bullet points where appropriate | |
| Content: | |
| - Education: {Education} | |
| - Skills: {Skills} | |
| - Projects: {Projects} | |
| - Experience: {Experience} | |
| - Internship: {Internship} | |
| Generate the resume now. | |
| ''' | |
| p=langchain_core.prompts.PromptTemplate(template=template) | |
| prompt=p.format(Name=Name,Education=Education,Email=Email,Experience=Experience, | |
| GitHub=GitHub, | |
| Internship=Internship, | |
| Linkedin=Linkedin, | |
| Location=Location, | |
| Phone=Phone, | |
| Projects=Projects, | |
| Skills=Skills, | |
| choice=choice) | |
| var='''You are a senior-level Python engineer with over 20 years of professional experience and a resume expert with over 20 years of experience creating industry-standard, ATS-friendly resumes. | |
| Your task is to generate a complete, executable Python program that creates a professional resume as a PDF file. | |
| Libraries and environment rules: | |
| - Use Python 3.9+ syntax | |
| - Use ReportLab (reportlab.platypus) for PDF generation | |
| - Do NOT use pdfplumber, PyPDF2, or any read-only PDF libraries | |
| - Use only standard Python libraries in addition to ReportLab | |
| - The code must be runnable in a local environment after installing dependencies via pip | |
| Strict requirements: | |
| - Automatically handle layout, spacing, and page breaks (no manual x/y positioning) | |
| - Accept resume details as input variables (name, email, phone, location, education, skills, projects, experience, internship, links) | |
| - Include only sections for which data is provided | |
| - Never write placeholders such as "Not provided" | |
| - Never invent or add fake experience, skills, or projects | |
| - Follow best practices for professional, ATS-friendly resume formatting | |
| Output rules: | |
| - Output ONLY executable Python code | |
| - Do NOT include explanations, comments, or markdown | |
| - The program must generate a resume.pdf file when run | |
| Assume the user will install dependencies using: | |
| pip install reportlab''' | |
| message=[['system message',var],['user message',prompt]] | |
| te = llm.invoke(message) | |
| cd=te.strip("```python") | |
| with open("app.py","w") as f: | |
| f.write(cd) | |
| result= s.run( | |
| [sys.executable, "app.py"], # use current Python env | |
| capture_output=True, | |
| text=True | |
| ) | |
| if result.returncode == 0: | |
| st.success("Resume PDF generated successfully!") | |
| with open("resume.pdf","rb") as f: | |
| st.download_button(label="download the resume in pdf format",data=f,file_name="resume.pdf") | |
| else: | |
| with open("app.py","r") as d: | |
| d.seek(0) | |
| st.write(d.read()) | |
| else: | |
| st.markdown("please write the above required feilds") |