Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,57 @@
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from typing import List
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
app = FastAPI()
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
from ranker import rank_resume
|
| 10 |
from embeddings import rank_jobs
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from typing import List
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
import shutil
|
| 6 |
+
|
| 7 |
+
from langchain_docling import DoclingLoader
|
| 8 |
+
from langchain_docling.loader import ExportType
|
| 9 |
|
| 10 |
|
| 11 |
app = FastAPI()
|
| 12 |
|
| 13 |
+
resumes = []
|
| 14 |
+
jobs = []
|
| 15 |
+
|
| 16 |
+
UPLOAD_DIR = Path("uploads")
|
| 17 |
+
UPLOAD_DIR.mkdir(exist_ok=True)
|
| 18 |
+
|
| 19 |
+
@app.post("/upload")
|
| 20 |
+
async def upload_file(file: UploadFile = File(...)):
|
| 21 |
+
file_path = UPLOAD_DIR / file.filename
|
| 22 |
+
with file_path.open("wb") as buffer:
|
| 23 |
+
shutil.copyfileobj(file.file, buffer)
|
| 24 |
+
|
| 25 |
+
# result = process_with_langchain(file_path)
|
| 26 |
+
|
| 27 |
+
loader = DoclingLoader(file_path=FILE_PATH, export_type=ExportType.MARKDOWN)
|
| 28 |
+
docs = loader.load()
|
| 29 |
+
# docs = docs.model_dump()
|
| 30 |
+
return {
|
| 31 |
+
"code":201,
|
| 32 |
+
"message":"Request was successful.",
|
| 33 |
+
"data": docs[0].model_dump()
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
# return {"filename": file.filename, "path": str(file_path), "status": "uploaded"}
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
# class InputResume(BaseModel):
|
| 40 |
+
# content: str
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
# @app.post("/suggest/")
|
| 45 |
+
# async def suggestion(data: InputResume):
|
| 46 |
+
# return {
|
| 47 |
+
# "code":201,
|
| 48 |
+
# "message":"Request was successful.",
|
| 49 |
+
# "data": InputResume.model_dump_json()
|
| 50 |
+
# }
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
|
| 55 |
|
| 56 |
from ranker import rank_resume
|
| 57 |
from embeddings import rank_jobs
|