Spaces:
Runtime error
Runtime error
| from fastapi import FastAPI, File, UploadFile, Form | |
| from fastapi.responses import JSONResponse | |
| import google.generativeai as genai | |
| import os | |
| import PyPDF2 as pdf | |
| from dotenv import load_dotenv | |
| load_dotenv() # Load environment variables | |
| genai.configure(api_key=os.getenv("GOOGLE_API_KEY")) | |
| app = FastAPI() | |
| def get_gemini_response(input): | |
| model = genai.GenerativeModel('gemini-pro') | |
| response = model.generate_content(input) | |
| return response.text | |
| def read_pdf_text(file): | |
| text = "" | |
| reader = pdf.PdfReader(file) | |
| for page in range(len(reader.pages)): | |
| page = reader.pages[page] | |
| text += str(page.extract_text()) | |
| return text | |
| async def response(jd:str = Form(...), file: UploadFile = File(...)): | |
| try: | |
| text = read_pdf_text(file.file) | |
| jd = jd | |
| input_prompt=""" | |
| 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 in one single string having the structure | |
| {{"JD Match":"%","MissingKeywords:[]","Profile Summary":""}} | |
| """ | |
| gemini_response = get_gemini_response(input_prompt) | |
| return JSONResponse(content={"result": gemini_response}, status_code=200) | |
| except Exception as e: | |
| return JSONResponse(content={"error": str(e)}, status_code=500) | |