import gradio as gr import openai import PyPDF2 class JobListGenerator: def __init__(self): openai.api_key = os.getenv("OPENAI_API_KEY") self.engine = 'text-davinci-003' def _extract_text_from_pdf(self, file_path: str) -> str: with open(file_path, 'rb') as file: reader = PyPDF2.PdfReader(file) pdf_extract_text = "" for page in reader.pages: pdf_extract_text += page.extract_text() return pdf_extract_text def _generate_job_list(self, resume: str) -> str: prompt = f"List out job list based on resume. Here is the resume : {resume}" response = openai.Completion.create( engine=self.engine, prompt=prompt, max_tokens=100, temperature=0, n=1, stop=None, ) generated_text = response.choices[0].text.strip() return generated_text def job_list_interface(self, file) -> str: resume_text = self._extract_text_from_pdf(file.name) job_list = self._generate_job_list(resume_text) return job_list def launch_gradio_interface(self, share: bool = True): with gr.Blocks(css="style.css", theme=gr.themes.Soft()) as app: gr.HTML("""Image Image""") with gr.Row(): with gr.Column(elem_id="col-container"): gr.HTML("""

Designation Finder

""") input_file = gr.File(label="Upload Resume (PDF)") btn = gr.Button(value="Submit") output_text = gr.Textbox(label="Designation List") btn.click(self.job_list_interface, input_file, output_text) app.launch() job_list_generator = JobListGenerator() job_list_generator.launch_gradio_interface()