File size: 1,019 Bytes
62d3b3c
 
 
 
9956d52
adf36ef
 
 
 
 
62d3b3c
 
 
 
 
 
 
 
9956d52
 
 
 
 
62d3b3c
9956d52
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
from fastapi import APIRouter, UploadFile, File
from typing import Annotated

from app.modules.question_retrieval.models.jd2text import jobdes2text
from app.modules.question_retrieval.models.text2tector import text2vector

qtretrieval_router = APIRouter(prefix="/qtretrieval", tags=["qtretrieval"])

@qtretrieval_router.get("/")
async def index():
    return {"message": "Welcome to question retrieval page"}

@qtretrieval_router.post("/send_jd")
# only upload .txt file
async def send_jd(txt_file: Annotated[UploadFile, File(..., description="The JD file", media_type=["text/plain"])]):
    try:
        # read the txt file with format
        jobdes = txt_file.file.read().decode("utf-8")
        sumaryjd_text = jobdes2text(jobdes)
        print("sumaryjd_text: ", sumaryjd_text)
        sumaryjd_vector = text2vector(sumaryjd_text)
        print("sumaryjd_vector: ", sumaryjd_vector)
        return {"message": "Send JD successfully"}
    except Exception as e:
        return {"message": "Error", "error": str(e)}