tensorgirl's picture
Update main.py
7ee90a2 verified
import google.generativeai as genai
import os
import PyPDF2 as pdf
import json
from fastapi import FastAPI, Request, UploadFile, File
app = FastAPI()
#Prompt Template
input_prompt="""
Hey Act Like a skilled or very experience ATS(Application Tracking System)
with a deep understanding of tech field,software engineering,data science ,data analyst
and big data engineer. Your task is to evaluate the resume based on the given job description.
You must consider the job market is very competitive and you should provide
best assistance for improving thr resumes. Assign the percentage Matching based
on Jd and
the missing keywords with high accuracy
resume:{text}
description:{jd}
I want the response as per below structure
{{"JD Match": "%", "MissingKeywords": [], "Profile Summary": ""}}
"""
genai.configure(api_key=os.environ.get("API_TOKEN"))
def get_gemini_repsonse(input):
model=genai.GenerativeModel('gemini-pro')
response=model.generate_content(input)
return response.text
def input_pdf_text(uploaded_file):
reader=pdf.PdfReader(uploaded_file)
text=""
for page in range(len(reader.pages)):
page=reader.pages[page]
text+=str(page.extract_text())
return text
@app.get("/")
async def root():
return {"Text Emotion Classification":"Version 1.5 'Text'"}
@app.post("/resume_parser/")
def process_pdf_file(file: UploadFile = File(...)):
contents = file.file.read()
with open(file.filename, 'wb') as f:
f.write(contents)
return process_pdf(file.filename)
def process_pdf(pdf_source):
text=input_pdf_text(pdf_source)
response=get_gemini_repsonse(input_prompt)
return response