import gradio as gr import openai import os import fitz # PyMuPDF # Set OpenAI API key openai.api_key = os.getenv("sk-1E6ExsyFb-cdU8jPNDP1dsEq_ra_bazU-EXQZQ86pJT3BlbkFJ4zURsV0t--3qNM7A-P57NUqZIBosrL7POwzpjR5EQA") def extract_text_from_pdf(pdf_file): # Open the PDF file document = fitz.open(pdf_file) text = "" # Extract text from each page for page_num in range(len(document)): page = document.load_page(page_num) text += page.get_text() return text def evaluate_resume(pdf_file, job_description): # Extract text from PDF resume_text = extract_text_from_pdf(pdf_file) prompt = f""" As an experienced Applicant Tracking System (ATS) analyst, with profound knowledge in technology, software engineering, data science, and big data engineering, your role involves evaluating resumes against job descriptions. Recognizing the competitive job market, provide top-notch assistance for resume improvement. Your goal is to analyze the resume against the given job description, assign a percentage match based on key criteria, and pinpoint missing keywords accurately. resume:{resume_text} description:{job_description} I want the response in one single string having the structure {{"Job Description Match":"%","Missing Keywords":"","Candidate Summary":"","Experience":""}} """ response = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": prompt} ] ) return response.choices[0].message['content'] iface = gr.Interface( fn=evaluate_resume, inputs=[ gr.File(label="Upload Resume PDF"), gr.Textbox(lines=10, label="Job Description") ], outputs="text", title="Resume Evaluator" ) iface.launch()