import google.generativeai as genai import os # Configure Gemini (API key should be set as environment variable) genai.configure(api_key=os.getenv("GEMINI_API_KEY")) def generate_ats_optimized_content(cv_data, job_description): """Use Gemini to optimize CV content for a specific job description""" model = genai.GenerativeModel('gemini-pro') prompt = f""" You are an expert resume writer and ATS (Applicant Tracking System) optimization specialist. Your task is to optimize the following resume information for the given job description. Job Description: {job_description} Current Resume Information: {str(cv_data)} Please return the optimized resume information in the exact same JSON structure, but with the following improvements: 1. Tailor the professional summary to highlight relevant skills and experience for this job 2. Reorder skills to put the most relevant ones first based on the job description 3. Enhance work experience bullet points to: - Use strong action verbs - Quantify achievements where possible - Align with keywords from the job description 4. Adjust project descriptions to emphasize relevant aspects 5. Ensure all content is concise, impactful, and ATS-friendly Return ONLY the optimized JSON structure with no additional commentary or explanation. """ try: response = model.generate_content(prompt) optimized_data = eval(response.text) # Note: In production, use proper JSON parsing with error handling return optimized_data except Exception as e: print(f"Error generating optimized content: {str(e)}") return cv_data # Return original if optimization fails