import streamlit as st import os import asyncio import warnings from crewai import Agent, Task, Crew from langchain_google_genai import ChatGoogleGenerativeAI from crewai_tools import FileReadTool, ScrapeWebsiteTool, SerperDevTool # Set a dummy key to prevent KeyError os.environ['OPENAI_API_KEY'] = 'dummy_key' # Warning control warnings.filterwarnings('ignore') # Set the Google API key directly in the code google_api_key = "AIzaSyCeZHse0Jr8PXBQoKFJg7fZkV_t5w6ViBM" # Function to initialize the Gemini model with an event loop async def initialize_llm(): return ChatGoogleGenerativeAI( model="gemini-1.5-flash", verbose=True, temperature=0.5, google_api_key=google_api_key ) # Run the initialization within the event loop if not hasattr(st, 'llm'): loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) st.llm = loop.run_until_complete(initialize_llm()) # Initialize tools search_tool = SerperDevTool() scrape_tool = ScrapeWebsiteTool() read_resume = FileReadTool(file_path='./content/fake_resume.md') # Define agents researcher = Agent( role="Tech Job Researcher", goal="Make sure to do amazing analysis on job posting to help job applicants", tools=[scrape_tool, search_tool], verbose=True, backstory=( "As a Job Researcher, your prowess in navigating and extracting critical " "information from job postings is unmatched. Your skills help pinpoint the necessary " "qualifications and skills sought by employers, forming the foundation for effective application tailoring." ), llm=st.llm ) profiler = Agent( role="Personal Profiler for Engineers", goal="Do incredible research on job applicants to help them stand out in the job market", tools=[scrape_tool, search_tool, read_resume], verbose=True, backstory=( "Equipped with analytical prowess, you dissect and synthesize information " "from diverse sources to craft comprehensive personal and professional profiles, laying the " "groundwork for personalized resume enhancements." ), llm=st.llm ) resume_strategist = Agent( role="Resume Strategist for Engineers", goal="Find all the best ways to make a resume stand out in the job market.", tools=[scrape_tool, search_tool, read_resume], verbose=True, backstory=( "With a strategic mind and an eye for detail, you excel at refining resumes to highlight the most " "relevant skills and experiences, ensuring they resonate perfectly with the job's requirements." ), llm=st.llm ) interview_preparer = Agent( role="Engineering Interview Preparer", goal="Create interview questions and talking points based on the resume and job requirements", tools=[scrape_tool, search_tool, read_resume], verbose=True, backstory=( "Your role is crucial in anticipating the dynamics of interviews. With your ability to formulate key questions " "and talking points, you prepare candidates for success, ensuring they can confidently address all aspects of the " "job they are applying for." ), llm=st.llm ) # Define tasks research_task = Task( description=( "Analyze the job posting URL provided ({job_posting_url}) " "to extract key skills, experiences, and qualifications required. Use the tools to gather content and identify " "and categorize the requirements." ), expected_output=( "A structured list of job requirements, including necessary skills, qualifications, and experiences." ), agent=researcher, async_execution=True ) profile_task = Task( description=( "Compile a detailed personal and professional profile using the GitHub ({github_url}) URLs, LinkedIn ({linkedin_url}) URL, and personal write-up " "({personal_writeup}). Utilize tools to extract and synthesize information from these sources." ), expected_output=( "A comprehensive profile document that includes skills, project experiences, contributions, interests, and " "communication style." ), agent=profiler, async_execution=True ) resume_strategy_task = Task( description=( "Using the profile and job requirements obtained from previous tasks, tailor the resume to highlight the most " "relevant areas. Employ tools to adjust and enhance the resume content. Make sure this is the best resume even but " "don't make up any information. Update every section, including the initial summary, work experience, skills, " "and education. All to better reflect the candidate's abilities and how it matches the job posting." ), expected_output=( "An updated resume that effectively highlights the candidate's qualifications and experiences relevant to the job." ), output_file="tailored_resume.md", context=[research_task, profile_task], agent=resume_strategist ) interview_preparation_task = Task( description=( "Create a set of potential interview questions and talking points based on the tailored resume and job requirements. " "Utilize tools to generate relevant questions and discussion points. Make sure to use these questions and talking points to " "help the candidate highlight the main points of the resume and how it matches the job posting." ), expected_output=( "A document containing key questions and talking points that the candidate should prepare for the initial interview." ), output_file="interview_materials.md", context=[research_task, profile_task, resume_strategy_task], agent=interview_preparer ) # Crew Setup job_application_crew = Crew( agents=[researcher, profiler, resume_strategist, interview_preparer], tasks=[research_task, profile_task, resume_strategy_task, interview_preparation_task], verbose=True ) # Job Application Inputs job_application_inputs = { 'job_posting_url': 'https://www.linkedin.com/jobs/collections/recommended/?currentJobId=3971777873&eBP=CwEAAAGQrDjDbzY9VTxQvSF6zCLu0cNQm7McJPCymw_4YJ8KCIVPoQei_6I17FtkEl3pSY6WlAKOhS8fRwXHDF_xfH_JEO-gDqRBLJxgqKKft7TD6vMZusTgtuTByPjJcH6zhNVaUF9wssog8T3wU8gdHVraMmgTdanjeQTJcRy0CP6ynYmlo1mw_XPetqaclf8h5vamDp-M0z-Y5BwEaHiVCSUNf2mfJ7VyAnsInisr2wGPmC0YhFdQzsgRTkdFGFMoejs-xM_lYDnc_22gM5pV4mHXGetgnDxK6Oot_Ip3PHd6jjKJbvcRoLDxK5640RvxV4EkNEUU7cPtw0FcWbg74hvggF1VJquPVNAhNjZpLxh8Hbe94JsEvWQyGiuTSHpG2v0STF8SvT6g3sy04uZwxF7B5dQIAyEcqbrT6hFhpEeWvUtVW30e_Ezehz8T7hLWUV2p_uXW6ZQCKjyPqVwQkre26YtDqQSi38X722bq1qD5Y0wV0cms&refId=TV8NgrFTQZQm7k6gZko9FQ%3D%3D&trackingId=j%2FkIgFHDTmriZJHR%2BxOhOA%3D%3D', 'github_url': 'https://github.com/PrathameshK', 'linkedin_url': 'https://www.linkedin.com/in/prathameshkhade/', 'personal_writeup': './content/fake_resume.md' } # Running Tasks results = job_application_crew.run_tasks(inputs=job_application_inputs) # Display Results st.write(results)