import gradio as gr import openai import PyPDF2 import os 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 perfect job roles for based on resume informations:{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(""" """) with gr.Row(): with gr.Column(elem_id="col-container"): gr.HTML("""