import asyncio import re from pydantic_ai.result import ResultData, RunResult import streamlit as st from pydantic_ai import Agent,RunContext, Tool from pydantic_ai.models.groq import GroqModel import nest_asyncio from pydantic_ai.messages import ModelMessage import pdfplumber import os from streamlit_pdf_viewer import pdf_viewer from dataclasses import dataclass #api_key #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 api_key = os.getenv("api_key") data = [] model = GroqModel("llama-3.3-70b-versatile", api_key = api_key) async def resume_AI(data): agent = Agent(model=model, system_prompt=( "Act as a professional resume editor and career consultant. Analyze the provided resume and improve it", "Rewrite the following bullet points to make them more impactful, concise, and result-oriented. Use action verbs and quantify achievements wherever possible.", "Review this resume for grammar, clarity, and conciseness.", "Rewrite my resume to be more concise and impactful", "Use strong action verbs and quantify my accomplishments whenever possible.", "Correct any grammar, spelling, or punctuation errors.", "Improve sentence structure for clarity and professionalism.", "Incorporate industry-specific keywords and phrases to make the resume ATS-friendly.", "Create a compelling summary/profile section that reflects my career goals.", # "Incorporate keywords relevant to the target industry and roles", #"Optimize the resume for Applicant Tracking Systems (ATS)." "Your answer should be a new and improve resume in markdown formate", #"Answer should be in markdown formate" ) ) cover_letter_agent = Agent(model=model, system_prompt=( "Act as a professional career consultant and cover letter writer. Based on the provided resume", "Clearly states the applicant’s interest in the role and the company.", "Summarizes the applicant's most relevant skills, experiences, and achievements.", "Provides specific examples or metrics to demonstrate impact and success.", "Reiterates excitement for the opportunity.", "Invites further discussion and expresses gratitude for consideration.", "Provides a professional closing, including the applicant’s name and contact information.", "Use the following structure:", "1. Greeting: Address the hiring manager by name, if available.", "2. Opening Paragraph: State interest in the role and company.", "3. Middle Paragraphs: Highlight key qualifications and experiences, tailored to the job description.", "4. Closing Paragraph: Express enthusiasm and invite further discussion." ) ) result = agent.run_sync(user_prompt=f"Improve this resume: {data}") result_1 = cover_letter_agent.run_sync(user_prompt= f"Write cover letter for this resume {result.data}") st.markdown(result.data) st.text(result_1.data) print("Done") def extract_data(feed): with pdfplumber.open(feed) as pdf: pages = pdf.pages for p in pages: data.append(p.extract_text()) return None def ai_resume(data): asyncio.run(resume_AI(data=data)) def main(): st.title("🚀 Elevate Your Job Applications with AI-Powered Tools") st.header("Resume Builder & Cover Letter Assistant") uploaded_file = st.file_uploader('Choose your .pdf file', type="pdf") if uploaded_file is not None: extract_data(uploaded_file) binary_data = uploaded_file.getvalue() pdf_viewer(input=binary_data, width=700) if st.button("Improve Resume and Cover letter",type='primary'): ai_resume(data) if __name__ == '__main__': import asyncio nest_asyncio.apply() main()