File size: 2,296 Bytes
d6e40d7 0509292 d6e40d7 05d41aa d6e40d7 ca80545 d6e40d7 7e95e2d e7654f8 7e95e2d d6e40d7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
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()
|