|
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='karthikeyan-adople/hudsonhayes-gray') as app: |
|
gr.HTML("""<center class="darkblue" style='background-color:rgb(0,1,36); text-align:center;padding:30px;'><center> |
|
<img class="leftimage" align="left" src="https://companieslogo.com/img/orig/RAND.AS_BIG-0f1935a4.png?t=1651813778" alt="Image" width="210" height="210"> |
|
<h1 class ="center" style="color:#fff">ADOPLE AI</h1></center> |
|
<br><center><h1 style="color:#fff">Designation Finder</h1></center>""") |
|
with gr.Row(): |
|
with gr.Column(elem_id="col-container"): |
|
gr.HTML("""<center><h1>Designation Finder</h1></center>""") |
|
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() |
|
|