Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import io
- import os
- import PyPDF2
- import streamlit as st
- from dotenv import load_dotenv
- import openai
- from openai import api_key, OpenAI
- load_dotenv()
- st.set_page_config(page_title="AI Resume Critiquer", page_icon="", layout="centered")
- st.title("AI Resume Critiquer")
- st.markdown("Upload your resume and get AI-powered feedback tailored to your needs!")
- OPENAI_KEY = os.getenv('OPENAI_API_KEY')
- uplodaded_file = st.file_uploader("Upload your resume (PDF or TXT", type=['pdf', 'txt'])
- job_role = st.text_input("Enter the jon role you're applying for: ")
- analyze_button = st.button("Analyze Resume")
- def extract_text_from_pdf_file(pdf_file_path):
- pdf_reader = PyPDF2.PdfReader(pdf_file_path)
- text = ""
- for page in pdf_reader.pages:
- text += page.extract_text() + '\n'
- return text
- def extract_text_from_file(uploaded_file):
- if uploaded_file.type == "application/pdf":
- return extract_text_from_pdf_file(io.BytesIO(uploaded_file.read()))
- return uploaded_file.read().decode('utf-8')
- if analyze_button and uplodaded_file:
- try:
- file_content = extract_text_from_file(uplodaded_file)
- if not file_content.strip():
- st.error("File does not have any content...")
- st.stop()
- prompt = f"""Please analyze this resume and provide constructive feedback.
- Focus on the following aspects:
- 1. Content clarity and impact
- 2. Skills presentation
- 3. Experience description
- 4. Specific improvements for {job_role if job_role else 'general job application!'}
- Resume content:
- {file_content}
- Please provide your analysis in a clear, structured format with specific recommendations.
- """
- open_ai_client = OpenAI(api_key=OPENAI_KEY)
- response = open_ai_client.chat.completions.create(
- model="gpt-4o-mini",
- messages=[
- {"role": "system", "content": "You are an expert resume reviewer with years of hiring and HR experience"},
- {"role": "user", "content": prompt}
- ],
- max_tokens=1000
- )
- st.markdown("Analysis Results!")
- st.markdown(response.choices[0].message.content)
- except Exception as e:
- st.error(e)
Advertisement
Add Comment
Please, Sign In to add comment