Spaces:
Runtime error
Runtime error
File size: 1,542 Bytes
c1ae082 | 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 | from typing import Annotated, Optional
import pydantic
import uvicorn
from fastapi import FastAPI, UploadFile, Body, File
from resume_parser import ResumeParser, pdf_to_string
from resume_template import Resume
app = FastAPI()
@app.get("/")
async def root():
return "OK"
@app.post("/parse_resume/")
async def parse_resume(resume_file: UploadFile, use_openai:bool=True):
content = await resume_file.read()
await resume_file.close()
p = ResumeParser(use_openai)
resume_text = pdf_to_string(content)
resume = p.extract_resume_fields(resume_text)
return resume
@app.post("/match_resume_job/")
async def match_resume_job(resume_file: UploadFile, job_description:Annotated[str, Body(embed=True)], use_openai:bool=True):
content = await resume_file.read()
await resume_file.close()
p = ResumeParser(use_openai)
resume_text = pdf_to_string(content)
res = p.match_resume_with_job_description(resume_text, job_description)
return res
@app.post("/match_resume_job_file/")
async def match_resume_job(resume_file: UploadFile, job_description_file:UploadFile, use_openai:bool=True):
content = await resume_file.read()
await resume_file.close()
p = ResumeParser(use_openai)
resume_text = pdf_to_string(content)
job_description_text = await job_description_file.read()
await job_description_file.close()
res = p.match_resume_with_job_description(resume_text, job_description_text)
return res
if __name__ == '__main__':
uvicorn.run(app, host="0.0.0.0", port=8000) |